Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-13 08:35:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-13 08:41:35 +0300
commit1abd120e70faddadad1b20e2b24dd5e03229806e (patch)
treeee23344f49fa42cf69a22a70db71dc80542b12d7 /source/blender/editors/interface
parentf1a65f5750d6a7ce040325af49863a15427d39b1 (diff)
Cleanup: rename uiBlock.mx,my to bounds_offset
Use a name that related to block bounds calculation (mx/my are typically used for mouse x,y).
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c28
-rw-r--r--source/blender/editors/interface/interface_context_menu.c4
-rw-r--r--source/blender/editors/interface/interface_intern.h5
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c4
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c2
-rw-r--r--source/blender/editors/interface/interface_region_popover.c11
-rw-r--r--source/blender/editors/interface/interface_widgets.c2
7 files changed, 35 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e8c63fb0224..840c68ec747 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -495,8 +495,8 @@ static void ui_block_bounds_calc_popup(
/* offset block based on mouse position, user offset is scaled
* along in case we resized the block in ui_block_bounds_calc_text */
- raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth;
- raw_y = rect.ymin = xy[1] + block->rect.ymin + (block->my * height) / oldheight;
+ raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->bounds_offset[0] * width) / oldwidth;
+ raw_y = rect.ymin = xy[1] + block->rect.ymin + (block->bounds_offset[1] * height) / oldheight;
rect.xmax = rect.xmin + width;
rect.ymax = rect.ymin + height;
@@ -538,21 +538,33 @@ void UI_block_bounds_set_text(uiBlock *block, int addval)
}
/* used for block popups */
-void UI_block_bounds_set_popup(uiBlock *block, int addval, int mx, int my)
+void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2])
{
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MOUSE;
- block->mx = mx;
- block->my = my;
+ if (bounds_offset != NULL) {
+ block->bounds_offset[0] = bounds_offset[0];
+ block->bounds_offset[1] = bounds_offset[1];
+ }
+ else {
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
+ }
}
/* used for menu popups */
-void UI_block_bounds_set_menu(uiBlock *block, int addval, int mx, int my)
+void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2])
{
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MENU;
- block->mx = mx;
- block->my = my;
+ if (bounds_offset != NULL) {
+ block->bounds_offset[0] = bounds_offset[0];
+ block->bounds_offset[1] = bounds_offset[1];
+ }
+ else {
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
+ }
}
/* used for centered popups, i.e. splash */
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 7ed80aac28f..d075052f842 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -110,7 +110,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
- UI_block_bounds_set_popup(block, 6, -50, 26);
+ UI_block_bounds_set_popup(block, 6, (const int[2]){-50, 26});
return block;
}
@@ -159,7 +159,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
- UI_block_bounds_set_popup(block, 6, -50, 26);
+ UI_block_bounds_set_popup(block, 6, (const int[2]){-50, 26});
#ifdef USE_KEYMAP_ADD_HACK
g_kmi_id_hack = kmi_id;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 82d6115fbbb..9d3f2088ab4 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -440,7 +440,8 @@ struct uiBlock {
/** for doing delayed */
eBlockBoundsCalc bounds_type;
- int mx, my;
+ /** Offset to use when calculating bounds (in pixels). */
+ int bounds_offset[2];
/** for doing delayed */
int bounds, minbounds;
@@ -613,7 +614,7 @@ struct uiPopupBlockHandle {
rctf prev_block_rect;
rctf prev_butrct;
short prev_dir1, prev_dir2;
- int prev_mx, prev_my;
+ int prev_bounds_offset[2];
/* Maximum estimated size to avoid having to reposition on refresh. */
float max_size_x, max_size_y;
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 2631f38d73d..06ea9a7a927 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -85,8 +85,8 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl
block->minbounds = minwidth;
block->bounds = 1;
- block->mx = 0;
- block->my = 0;
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
block->bounds_type = UI_BLOCK_BOUNDS_PIE_CENTER;
block->pie_data.pie_center_spawned[0] = pie->mx;
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index 73847d6fc71..3ec2fd26d36 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -272,7 +272,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
block->minbounds = minwidth;
- UI_block_bounds_set_menu(block, 1, offset[0], offset[1]);
+ UI_block_bounds_set_menu(block, 1, offset);
}
else {
/* for a header menu we set the direction automatic */
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 4fd25c4c7e2..e6e7cb33ad5 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -48,6 +48,7 @@
#include "BLI_rect.h"
#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -161,12 +162,12 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
ui_block_to_window_fl(handle->ctx_region, pup->but->block, &center[0], &center[1]);
/* These variables aren't used for popovers,
* we could add new variables if there is a conflict. */
- handle->prev_mx = block->mx = (int)center[0];
- handle->prev_my = block->my = (int)center[1];
+ block->bounds_offset[0] = (int)center[0];
+ block->bounds_offset[1] = (int)center[1];
+ copy_v2_v2_int(handle->prev_bounds_offset, block->bounds_offset);
}
else {
- block->mx = handle->prev_mx;
- block->my = handle->prev_my;
+ copy_v2_v2_int(block->bounds_offset, handle->prev_bounds_offset);
}
if (!slideout) {
@@ -213,7 +214,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
}
}
- UI_block_bounds_set_popup(block, block_margin, offset[0], offset[1]);
+ UI_block_bounds_set_popup(block, block_margin, offset);
}
return block;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 7e43ac8c850..04a329b2607 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4498,7 +4498,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
if (block) {
- float mval_origin[2] = {block->mx, block->my};
+ float mval_origin[2] = {UNPACK2(block->bounds_offset)};
ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]);
ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
}