[Bf-blender-cvs] [83d713c] pie-menus: Pies:

Antony Riakiotakis noreply at git.blender.org
Fri Jun 27 02:43:30 CEST 2014


Commit: 83d713c6060ed44eb92077ed7b9498f2af875ba6
Author: Antony Riakiotakis
Date:   Fri Jun 27 02:50:22 2014 +0300
https://developer.blender.org/rB83d713c6060ed44eb92077ed7b9498f2af875ba6

Pies:

* Modify timed pie macro with own timeout property.
* Times are now counted in 100ths of second, gives more needed
precision.
* Add whole event argument to pie creation so we can spawn at custom
initial position
* Escape key also exits pie menus now.

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

M	release/scripts/modules/bpy_types.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/resources.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/makesrna/intern/rna_wm_api.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 3114291..cf1e000 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -142,7 +142,7 @@ class WindowManager(bpy_types.ID):
 
     def menu_pie(self, event, draw_func, title="", icon='NONE'):
         import bpy
-        pie = self.piemenu_begin__internal(title, icon, event.type)
+        pie = self.piemenu_begin__internal(title, icon, event)
 
         try:
             draw_func(pie, bpy.context)
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 274a981..5ba3c6b 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -220,6 +220,7 @@ class USERPREF_PT_interface(Panel):
         col.label(text="Pie Menus:")
         sub = col.column(align=True)
         sub.prop(view, "pie_drag_timeout")
+        sub.prop(view, "pie_operator_timeout")
         sub.prop(view, "pie_initial_timeout")
         sub.prop(view, "pie_menu_radius")
         sub.prop(view, "pie_menu_threshold")
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2097b0b..92b8147 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -358,8 +358,8 @@ bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *
 /* Pie menus */
 typedef struct uiPieMenu uiPieMenu;
 
-void uiPieMenuInvoke(struct bContext *C, const char *idname, short event);
-uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, short event) ATTR_NONNULL();
+void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event);
+uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) ATTR_NONNULL();
 void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie);
 struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie);
 /* Popup Blocks
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e60ddf8..0f32686 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -322,11 +322,15 @@ static void ui_centered_bounds_block(wmWindow *window, uiBlock *block)
 	
 }
 
-static void ui_centered_pie_bounds_block(uiBlock *block, const int xy[2])
+static void ui_centered_pie_bounds_block(uiBlock *block)
 {
 	int startx;
 	int width, height;
 
+	const int xy[2] = {
+	    block->pie_data.pie_center_spawned[0],
+	    block->pie_data.pie_center_spawned[1]
+	};
 	/* note: this is used for the splash where window bounds event has not been
 	 * updated by ghost, get the window bounds from ghost directly */
 
@@ -1205,7 +1209,7 @@ void uiEndBlock_ex(const bContext *C, uiBlock *block, const int xy[2])
 			ui_centered_bounds_block(window, block);
 			break;
 		case UI_BLOCK_BOUNDS_PIE_CENTER:
-			ui_centered_pie_bounds_block(block, xy);
+			ui_centered_pie_bounds_block(block);
 			break;
 
 			/* fallback */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1ea581a..dfbf84e 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8400,7 +8400,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 	time_diff = PIL_check_seconds_timer() - menu->towardstime;
 
 	/* deactivate initial direction after a while */
-	if (time_diff > 0.1 * U.pie_initial_timeout) {
+	if (time_diff > 0.01 * U.pie_initial_timeout) {
 		block->pie_data.flags &= ~UI_PIE_INITIAL_DIRECTION;
 		/* force redraw */
 		ED_region_tag_redraw(ar);
@@ -8414,7 +8414,10 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 	ui_block_calculate_pie_segment(block, mx, my);
 
 	if (block->pie_data.flags & UI_PIE_CANCELLED) {
-		if (event->type == block->pie_data.event && event->val == KM_RELEASE) {
+		if ((event->type == block->pie_data.event && event->val == KM_RELEASE) ||
+		    event->type == RIGHTMOUSE ||
+		    event->type == ESCKEY)
+		{
 			menu->menuretval = UI_RETURN_OK;
 		}
 
@@ -8430,7 +8433,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 			ED_region_tag_redraw(ar);
 		}
 		else {
-			if (time_diff > U.pie_drag_timeout * 0.1) {
+			if (time_diff > U.pie_drag_timeout * 0.01) {
 				retval = ui_pie_menu_apply(C, menu, event, true);
 			}
 			else {
@@ -8457,6 +8460,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 				}
 				break;
 
+			case ESCKEY:
 			case RIGHTMOUSE:
 				menu->menuretval = UI_RETURN_CANCEL;
 				break;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 7b283be..4d31a35 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2651,7 +2651,7 @@ static float uiPieTitleWidth(const char *name, int icon)
 		        (UI_UNIT_X * (1.50f + (icon ? 0.25f : 0.0f)));
 }
 
-struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, short event)
+struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const wmEvent *event)
 {
 	uiStyle *style = UI_GetStyleDraw();
 	uiPieMenu *pie = MEM_callocN(sizeof(uiPopupMenu), "pie menu");
@@ -2662,10 +2662,11 @@ struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon
 	/* pie->block_radial->flag |= UI_BLOCK_POPUP_MEMORY; */
 	pie->block_radial->puphash = ui_popup_menu_hash(title);
 	pie->block_radial->flag |= UI_BLOCK_RADIAL;
-	pie->block_radial->pie_data.event = event;
+	pie->block_radial->pie_data.event = event->type;
 
 	pie->layout = uiBlockLayout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
-
+	pie->mx = event->x;
+	pie->my = event->y;
 
 	/* create title button */
 	if (title[0]) {
@@ -2689,8 +2690,6 @@ void uiPieMenuEnd(bContext *C, uiPieMenu *pie)
 {
 	wmWindow *window = CTX_wm_window(C);
 	uiPopupBlockHandle *menu;
-	pie->mx = window->eventstate->x;
-	pie->my = window->eventstate->y;
 
 	menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PIE, pie);
 	menu->popup = true;
@@ -2708,7 +2707,7 @@ uiLayout *uiPieMenuLayout(uiPieMenu *pie)
 	return pie->layout;
 }
 
-void uiPieMenuInvoke(struct bContext *C, const char *idname, short event)
+void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event)
 {
 	uiPieMenu *pie;
 	uiLayout *layout;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 64301d3..6f7a471 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -2459,6 +2459,9 @@ void init_userdef_do_versions(void)
 		if (U.pie_menu_threshold == 0)
 			U.pie_menu_threshold = 12;
 
+		if (U.pie_operator_timeout == 0)
+			U.pie_operator_timeout = 20;
+
 		for (btheme = U.themes.first; btheme; btheme = btheme->next) {
 			btheme->tui.wcol_pie_menu = wcol_pie_menu;
 		}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index f48e034..9061544 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -533,7 +533,8 @@ typedef struct UserDef {
 	                             * a drag/release pie menu */
 	short pie_initial_timeout;  /* direction in the pie menu will always be calculated from the initial position
 	                             * within this time limit */
-
+	int pie_operator_timeout;     /* if button released before this time it calls an operator instead */
+	int pad2;
 	short pie_menu_radius;        /* pie menu radius */
 	short pie_menu_threshold;     /* pie menu distance from center before a direction is set */
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index fef5859..949aeb7 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -3203,12 +3203,16 @@ static void rna_def_userdef_view(BlenderRNA *brna)
 
 	/* pie menus */
 	prop = RNA_def_property(srna, "pie_drag_timeout", PROP_INT, PROP_NONE);
-	RNA_def_property_range(prop, 0, 100);
-	RNA_def_property_ui_text(prop, "Drag Timeout", "Pie menus turn to drag style after this amount of time (in  1/10ths of sec)");
+	RNA_def_property_range(prop, 0, 1000);
+	RNA_def_property_ui_text(prop, "Drag Timeout", "Pie menus turn to drag style after this amount of time (in 1/100ths of sec)");
 
 	prop = RNA_def_property(srna, "pie_initial_timeout", PROP_INT, PROP_NONE);
-	RNA_def_property_range(prop, 0, 100);
-	RNA_def_property_ui_text(prop, "Recenter Timeout", "Pie menus will use the initial mouse position as center for this amount of time (in  1/10ths of sec)");
+	RNA_def_property_range(prop, 0, 1000);
+	RNA_def_property_ui_text(prop, "Recenter Timeout", "Pie menus will use the initial mouse position as center for this amount of time (in 1/100ths of sec)");
+
+	prop = RNA_def_property(srna, "pie_operator_timeout", PROP_INT, PROP_NONE);
+	RNA_def_property_range(prop, 0, 1000);
+	RNA_def_property_ui_text(prop, "Operator Timeout", "Pie menus will spawn a pie menu if button is released before this amount of time (in 1/100ths of sec)");
 
 	prop = RNA_def_property(srna, "pie_menu_radius", PROP_INT, PROP_PIXEL);
 	RNA_def_property_range(prop, 0, 1000);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 344d8b5..7d49952 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -311,12 +311,12 @@ static void rna_PupMenuEnd(bContext *C, PointerRNA *handle)
 }
 
 /* pie menu wrapper */
-static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, int type)
+static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event)
 {
 	PointerRNA r_ptr;
 	void *d

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list