[Bf-blender-cvs] [1abd120e70f] master: Cleanup: rename uiBlock.mx, my to bounds_offset

Campbell Barton noreply at git.blender.org
Wed Mar 13 06:42:54 CET 2019


Commit: 1abd120e70faddadad1b20e2b24dd5e03229806e
Author: Campbell Barton
Date:   Wed Mar 13 16:35:24 2019 +1100
Branches: master
https://developer.blender.org/rB1abd120e70faddadad1b20e2b24dd5e03229806e

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).

===================================================================

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/interface/interface_region_popover.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_node/node_select.c
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d9b2b09a117..ec8c2e0d299 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -594,8 +594,8 @@ typedef enum {
 
 void UI_block_bounds_set_normal(struct uiBlock *block, int addval);
 void UI_block_bounds_set_text(uiBlock *block, int addval);
-void UI_block_bounds_set_popup(uiBlock *block, int addval, int mx, int my);
-void UI_block_bounds_set_menu(uiBlock *block, int addvall, int mx, int my);
+void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2]);
+void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2]);
 void UI_block_bounds_set_centered(uiBlock *block, int addval);
 void UI_block_bounds_set_explicit(uiBlock *block, int minx, int miny, int maxx, int maxy);
 
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);
 	}
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index ae5413f13f4..fae5f7b3f20 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -1086,7 +1086,8 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
 	/* fake button, it holds space for search items */
 	uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
 
-	UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
+	/* Move it downwards, mouse over button. */
+	UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
 
 	//	UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate
 	wm_event_init_from_window(win, &event);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a6e0c86b5fd..ff3d1601dde 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -789,7 +789,9 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg)
 	/* fake button, it holds space for search items */
 	uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), width, height, NULL, 0, 0, 0, 0, NULL);
 
-	UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
+	/* Move it downwards, mouse over button. */
+	UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
+
 	UI_but_focus_on_enter_event(win, but);
 
 	return block;
@@ -1062,7 +1064,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
 		        UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
 	}
 
-	UI_block_bounds_set_popup(block, 4, 0, 0);
+	UI_block_bounds_set_popup(block, 4, NULL);
 
 	return block;
 }
@@ -1150,7 +1152,7 @@ static uiBl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list