[Bf-blender-cvs] [8947cfe] pie-menus: Add generic python operator that spawns a pie menu for a specific operator enum.

Antony Riakiotakis noreply at git.blender.org
Fri May 30 23:36:58 CEST 2014


Commit: 8947cfe30c02bb0c65fd16e96a3be2121e9cd639
Author: Antony Riakiotakis
Date:   Sat May 31 00:36:43 2014 +0300
https://developer.blender.org/rB8947cfe30c02bb0c65fd16e96a3be2121e9cd639

Add generic python operator that spawns a pie menu for a specific
operator enum.

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

M	release/scripts/startup/bl_operators/wm.py
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/sculpt_paint/paint_ops.c

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index f218920..ea556ee 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -529,6 +529,33 @@ class WM_OT_context_menu_enum(Operator):
         
         return {'PASS_THROUGH'}
 
+class WM_OT_context_operator_pie_enum(Operator):
+    bl_idname = "wm.context_operator_pie_enum"
+    bl_label = "Operator Enum Pie"
+    bl_options = {'UNDO', 'INTERNAL'}
+    data_path = rna_path_prop
+    title = StringProperty(
+            name="Title",
+            description="Pie Menu Title",
+            maxlen=1024,
+            )
+
+    def invoke(self, context, event):
+        data_path = self.data_path
+
+        value_path, prop_string = data_path.rsplit(".", 1)
+        op = eval("bpy.ops.%s" % value_path)
+
+        def draw_cb(self, context):
+            layout = self.layout
+            pie = layout.pie()
+            pie.operator_enum(op.idname_py(), prop_string)
+
+        context.window_manager.pie_menu(draw_func=draw_cb, title=self.title, event=event)
+
+        return {'PASS_THROUGH'}
+
+
 class WM_OT_context_pie_enum(Operator):
     bl_idname = "wm.context_pie_enum"
     bl_label = "Context Enum Pie"
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ad8ff2a..4e53015 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2215,10 +2215,10 @@ static RadialDirection ui_get_radialbut_vec(float *vec, short itemnum, short tot
 	return dir;
 }
 
-static bool ui_item_is_radial_displayable (uiButtonItem *UNUSED(bitem))
+static bool ui_item_is_radial_displayable (uiButtonItem *bitem)
 {
-//	if (bitem->but->type == LABEL)
-//		return false;
+	if (bitem->but->type == LABEL)
+		return false;
 
 	return true;
 }
@@ -2254,7 +2254,6 @@ static void ui_litem_layout_radial(uiLayout *litem)
 
 			/* not all button types are drawn in a radial menu, do filtering here */
 			if(ui_item_is_radial_displayable(bitem)) {
-
 				itemnum++;
 
 				bitem->but->pie_dir = ui_get_radialbut_vec(vec, itemnum, totitems);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 4d65388..a2a4773 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1191,11 +1191,13 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 	RNA_boolean_set(kmi->ptr, "create_missing", 1);
 
 	/* */
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_operator_pie_enum", TABKEY, KM_PRESS, 0, 0);
+	RNA_string_set(kmi->ptr, "data_path", "object.mode_set.mode");
+	RNA_string_set(kmi->ptr, "title", "Object Mode");
+
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_pie_enum", AKEY, KM_PRESS, 0, 0);
 	RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method");
 
-	WM_keymap_add_pie_menu(keymap, "VIEW3D_PIE_object_mode", TABKEY, KM_PRESS, 0, 0);
-
 	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");




More information about the Bf-blender-cvs mailing list