[Bf-blender-cvs] [c3f8a08] pie-menus: Add simple pie menu template

Antony Riakiotakis noreply at git.blender.org
Mon Jul 28 20:22:53 CEST 2014


Commit: c3f8a08fe40431f394cccf9307f3e7b6b5da1717
Author: Antony Riakiotakis
Date:   Mon Jul 28 20:22:41 2014 +0200
Branches: pie-menus
https://developer.blender.org/rBc3f8a08fe40431f394cccf9307f3e7b6b5da1717

Add simple pie menu template

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

A	release/scripts/templates_py/ui_pie_menu.py
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/templates_py/ui_pie_menu.py b/release/scripts/templates_py/ui_pie_menu.py
new file mode 100644
index 0000000..1aaf5ca
--- /dev/null
+++ b/release/scripts/templates_py/ui_pie_menu.py
@@ -0,0 +1,49 @@
+import bpy
+from bpy.props import *
+from bpy.types import Operator
+from bpy.types import Menu
+
+#expand an operator's macro in a pie menu
+
+myitems = (('0','Hey Lady!', ''),('1','Spaaaaaaaceeeee!',''),('2','Wanna be awesome in space?',''), ('3','The fact sphere is always useful',''))
+
+class TestPieOperator(bpy.types.Operator):
+    """Tooltip"""
+    bl_idname = "wm.test_pie_operator"
+    bl_label = "Simple Pie Sticky Operator"
+
+    test_type = EnumProperty(name='test_type', items = myitems, default='3')
+
+    @classmethod
+    def poll(cls, context):
+        return True
+
+    def execute(self, context):
+        print("The sphere core says: " + myitems[int(self.test_type)][1])
+        return {'FINISHED'}
+
+class VIEW3D_PIE_template(Menu):
+    bl_label = "Test Pie"
+
+    def draw(self, context):
+        layout = self.layout
+
+        pie = layout.menu_pie()
+        pie.operator_enum("WM_OT_test_pie_operator", "test_type")
+
+
+def register():
+    bpy.utils.register_class(TestPieOperator)
+    bpy.utils.register_class(VIEW3D_PIE_template)
+ 
+
+def unregister():
+    bpy.utils.unregister_class(TestPieOperator)
+    bpy.utils.unregister_class(VIEW3D_PIE_template)
+
+if __name__ == "__main__":
+    register()
+    
+    bpy.ops.wm.call_pie_menu(name="VIEW3D_PIE_template")
+
+
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index e7dea98..22b09ec 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2059,6 +2059,16 @@ static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *e
 	return OPERATOR_CANCELLED;
 }
 
+static int wm_call_pie_menu_exec(bContext *C, wmOperator *op)
+{
+	char idname[BKE_ST_MAXNAME];
+	RNA_string_get(op->ptr, "name", idname);
+
+	uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate, RNA_boolean_get(op->ptr, "force_click"));
+
+	return OPERATOR_CANCELLED;
+}
+
 static void WM_OT_call_pie_menu(wmOperatorType *ot)
 {
 	ot->name = "Call Pie Menu";
@@ -2066,6 +2076,7 @@ static void WM_OT_call_pie_menu(wmOperatorType *ot)
 	ot->description = "Call (draw) a pre-defined pie menu";
 
 	ot->invoke = wm_call_pie_menu_invoke;
+	ot->exec = wm_call_pie_menu_exec;
 	ot->poll = WM_operator_winactive;
 
 	ot->flag = OPTYPE_INTERNAL;




More information about the Bf-blender-cvs mailing list