[Bf-blender-cvs] [02c7aa4] pie-menus: Proper implementation of click style override:

Antony Riakiotakis noreply at git.blender.org
Tue Jul 8 18:33:18 CEST 2014


Commit: 02c7aa445508aa8d3410625faa6ab046aa4d61d0
Author: Antony Riakiotakis
Date:   Tue Jul 8 19:32:51 2014 +0300
https://developer.blender.org/rB02c7aa445508aa8d3410625faa6ab046aa4d61d0

Proper implementation of click style override:

Guide: This is added for double key combinations. In these situations,
holding the second key can be taxing and stretching for the hand.

Forcing a click style here is better. Ctrl-Tab for edit mode selection
uses this override currently.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/mesh/mesh_ops.c
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/space_view3d/view3d_ops.c
M	source/blender/windowmanager/WM_keymap.h
M	source/blender/windowmanager/intern/wm_keymap.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 0ed849c..7b40aa6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -358,9 +358,9 @@ bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *
 /* Pie menus */
 typedef struct uiPieMenu uiPieMenu;
 
-void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event, bool force_hold);
+void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event, bool force_click);
 void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
-                             const char *propname, const struct wmEvent *event, bool force_hold);
+                             const char *propname, const struct wmEvent *event, bool force_click);
 uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event, bool force_hold) ATTR_NONNULL();
 void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie);
 struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 120957c..c5ae85f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8422,6 +8422,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 	uiBlock *block;
 	int mx, my;
 	double duration;
+	bool is_click_style;
 
 	/* we block all events, this is modal interaction, except for drop events which is described below */
 	int retval = WM_UI_HANDLER_BREAK;
@@ -8435,6 +8436,8 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 	ar = menu->region;
 	block = ar->uiblocks.first;
 
+	is_click_style = (U.pie_interaction_type == USER_UI_PIE_CLICK) || (block->pie_data.flags & UI_PIE_CLICK_STYLE);
+
 	if (menu->scrolltimer == NULL) {
 		menu->scrolltimer =
 		    WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, PIE_MENU_INTERVAL);
@@ -8506,7 +8509,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 			ED_region_tag_redraw(ar);
 		}
 		else {
-			if (U.pie_interaction_type == USER_UI_PIE_DRAG) {
+			if (!is_click_style) {
 				retval = ui_pie_menu_apply(C, menu, event, true);
 			}
 		}
@@ -8521,7 +8524,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 
 			case LEFTMOUSE:
 				if (event->val == KM_PRESS) {
-					if ((U.pie_interaction_type == USER_UI_PIE_CLICK) || (block->pie_data.flags & UI_PIE_CLICK_STYLE)) {
+					if (is_click_style) {
 						retval = ui_pie_menu_apply(C, menu, event, false);
 					}
 					else {
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 3114026..52ba3e6 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -165,8 +165,7 @@ typedef enum RadialDirection {
 #define UI_PIE_INVALID_DIR         (1 << 3) /* mouse not far enough from center position  */
 #define UI_PIE_CANCELLED           (1 << 4) /* pie menu cancelled but we still wait for a release event  */
 #define UI_PIE_CLICK_STYLE         (1 << 5) /* pie menu changed to click style, click to confirm  */
-#define UI_PIE_FORCE_HOLD_STYLE    (1 << 6) /* pie menu forced to hold style. Usually for operators  */
-#define UI_PIE_ANIMATION_FINISHED  (1 << 7) /* pie animation finished, do not calculate any more motio  */
+#define UI_PIE_ANIMATION_FINISHED  (1 << 6) /* pie animation finished, do not calculate any more motio  */
 
 typedef struct uiLinkLine {  /* only for draw/edit */
 	struct uiLinkLine *next, *prev;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index e0eab09..1c9d9a4 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2675,7 +2675,7 @@ struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon
 	pie->block_radial->flag |= UI_BLOCK_RADIAL;
 	pie->block_radial->pie_data.event = event->type;
 	if (force_hold)
-		pie->block_radial->pie_data.flags |= UI_PIE_FORCE_HOLD_STYLE;
+		pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
 
 	pie->layout = uiBlockLayout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
 	pie->mx = event->x;
@@ -2720,7 +2720,7 @@ uiLayout *uiPieMenuLayout(uiPieMenu *pie)
 	return pie->layout;
 }
 
-void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event, bool force_hold)
+void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event, bool force_click)
 {
 	uiPieMenu *pie;
 	uiLayout *layout;
@@ -2735,7 +2735,7 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even
 	if (mt->poll && mt->poll(C, mt) == 0)
 		return;
 
-	pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event, force_hold);
+	pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event, force_click);
 	layout = uiPieMenuLayout(pie);
 
 	menu.layout = layout;
@@ -2752,12 +2752,12 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even
 
 
 void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
-                             const char *propname, const wmEvent *event, bool force_hold)
+                             const char *propname, const wmEvent *event, bool force_click)
 {
 	uiPieMenu *pie;
 	uiLayout *layout;
 
-	pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event, force_hold);
+	pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event, force_click);
 	layout = uiPieMenuLayout(pie);
 
 	layout = uiLayoutRadial(layout);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 1398bd9..cf1f338 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -343,7 +343,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
 	WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
 	
 	/* selection mode */
-	WM_keymap_add_pie_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0);
+	WM_keymap_add_pie_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0, true);
 	
 	/* hide */
 	kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index c433f75..b89acba 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1197,7 +1197,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SKEY, KM_PRESS, KM_SHIFT, 0);
 	RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_smooth_stroke");
 
-	WM_keymap_add_pie_menu(keymap, "VIEW3D_PIE_tests", QKEY, KM_PRESS, 0, 0);
+	WM_keymap_add_pie_menu(keymap, "VIEW3D_PIE_tests", QKEY, KM_PRESS, 0, 0, false);
 
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0);
 	RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.texture_angle_source_random");
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 50e4f65..c75adf6 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -294,7 +294,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
 	RNA_boolean_set(kmi->ptr, "center", true);
 
 	/* numpad view hotkeys*/
-	WM_keymap_add_pie_menu(keymap, "VIEW3D_PIE_view", QKEY, KM_PRESS, 0, 0);
+	WM_keymap_add_pie_menu(keymap, "VIEW3D_PIE_view", QKEY, KM_PRESS, 0, 0, false);
 
 	RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
 	RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index bf81972..c609549 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -65,7 +65,7 @@ wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, in
 wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, int type,
                                  int val, int modifier, int keymodifier);
 wmKeyMapItem *WM_keymap_add_pie_menu(struct wmKeyMap *keymap, const char *idname, int type,
-                                     int val, int modifier, int keymodifier);
+                                     int val, int modifier, int keymodifier, bool force_click);
 
 bool        WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
 int         WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len);
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 5a32c99..3c76acd 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -464,10 +464,11 @@ wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type,
 	return kmi;
 }
 
-wmKeyMapItem *WM_keymap_add_pie_menu(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_pie_menu(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier, bool force_click)
 {
 	wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_call_pie_menu", type, val, modifier, keymodifier);
 	RNA_string_set(kmi->ptr, "name", idname);
+	RNA_boolean_set(kmi->ptr, "force_click", force_click);
 	return kmi;
 }
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index e6ef524..8153e71 100644
--- a/source/blender/windowmana

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list