[Bf-blender-cvs] [a613ef6] pie-menus: Proof of concept pie interaction:

Antony Riakiotakis noreply at git.blender.org
Tue Jun 24 22:56:29 CEST 2014


Commit: a613ef67df45b52a23d0a8a26c905278b93def45
Author: Antony Riakiotakis
Date:   Tue Jun 24 23:56:21 2014 +0300
https://developer.blender.org/rBa613ef67df45b52a23d0a8a26c905278b93def45

Proof of concept pie interaction:

Press for calling operator, hold to spawn pie menu.

Test on object mode operator, pressing TAB toggles to edit mode, keeping
TAB pressed more that the drag timeout spawns a pie menu.

Still needs a way to enforce the menu to not listen for further drag
timeouts but looks like the concept holds.

This is implemented using the previous operator,
WM_OT_call_pie_menu_timer, in a macro. When the calling button is
pressed too long, the operator is cancelled (thus cancelling the macro)
but spawning a pie menu before that. If the timeout is not reached and
a key release event is detected, the operator finishes and the macro
continues, calling the next operator instead (object mode set, in our
case).

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/object/object_ops.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 52e8c94..b0ba014 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1421,6 +1421,16 @@ class VIEW3D_PIE_view(Menu):
         pie.operator_enum("VIEW3D_OT_viewnumpad", "type")
         pie.operator("VIEW3D_OT_view_persportho", text="Persp/Ortho", icon='RESTRICT_VIEW_OFF')
 
+class VIEW3D_PIE_object(Menu):
+    bl_label = "Mode"
+
+    def draw(self, context):
+        layout = self.layout
+
+        pie = layout.menu_pie()
+        pie.operator_enum("OBJECT_OT_mode_set", "mode")
+
+
 class VIEW3D_PIE_shade(Menu):
     bl_label = "Shade"
 
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 2f95019..d1da57a 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -271,7 +271,19 @@ void ED_operatormacros_object(void)
 		otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
 		RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
 	}
-	
+
+	ot = WM_operatortype_append_macro("OBJECT_OT_pie_mode_set", "Set Mode",
+	                                  "Set the mode of interaction for the selected object", OPTYPE_UNDO | OPTYPE_REGISTER);
+
+	if (ot) {
+		otmacro = WM_operatortype_macro_define(ot, "WM_OT_call_pie_menu_timer");
+		RNA_string_set(otmacro->ptr, "name", "VIEW3D_PIE_object");
+		otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_mode_set");
+		RNA_enum_set(otmacro->ptr, "mode", OB_MODE_EDIT);
+		RNA_boolean_set(otmacro->ptr, "toggle", true);
+
+	}
+
 }
 
 static int object_mode_poll(bContext *C)
@@ -289,10 +301,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
 	/* Objects, Regardless of Mode -------------------------------------------------- */
 	keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
 
-	kmi = WM_keymap_add_item(keymap, "WM_OT_context_operator_pie_enum", TABKEY, KM_PRESS, 0, 0);
-	RNA_string_set(kmi->ptr, "name", "OBJECT_OT_mode_set");
-	RNA_string_set(kmi->ptr, "property", "mode");
-	RNA_string_set(kmi->ptr, "title", "Object Mode");
+	kmi = WM_keymap_add_item(keymap, "OBJECT_OT_pie_mode_set", TABKEY, KM_PRESS, 0, 0);
 
 #if 0
 	/* Note: this keymap works disregarding mode */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 84dc904..fb4490c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2108,7 +2108,7 @@ static int wm_call_pie_menu_timer_modal(bContext *C, wmOperator *op, const wmEve
 	}
 
 	if (event->type == TIMER) {
-		if (data->timer->duration > U.pie_drag_timeout) {
+		if (data->timer->duration > U.pie_drag_timeout / 10.0f) {
 			char idname[BKE_ST_MAXNAME];
 			RNA_string_get(op->ptr, "name", idname);




More information about the Bf-blender-cvs mailing list