[Bf-extensions-cvs] [7a9d42b] dxf_import: make manipulator pie enable manipulator when one of the options is selected

Antony Riakiotakis noreply at git.blender.org
Fri Aug 15 12:38:30 CEST 2014


Commit: 7a9d42bda8b57341b2bba7108f9e292118fb38b8
Author: Antony Riakiotakis
Date:   Tue Aug 12 18:11:41 2014 +0200
Branches: dxf_import
https://developer.blender.org/rBA7a9d42bda8b57341b2bba7108f9e292118fb38b8

make manipulator pie enable manipulator when one of the options is selected

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

M	ui_pie_menus_official.py

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

diff --git a/ui_pie_menus_official.py b/ui_pie_menus_official.py
index 1283932..1fa1536 100644
--- a/ui_pie_menus_official.py
+++ b/ui_pie_menus_official.py
@@ -29,7 +29,8 @@ bl_info = {
 
 
 import bpy
-from bpy.types import Menu
+from bpy.types import Menu, Operator
+from bpy.props import EnumProperty
 
 
 class VIEW3D_PIE_object_mode(Menu):
@@ -71,6 +72,27 @@ class VIEW3D_PIE_shade(Menu):
                 pie.operator("OBJECT_OT_shade_flat")
 
 
+class VIEW3D_manipulator_set(Operator):
+    bl_label = "Set Manipulator"
+    bl_idname = "view3d.manipulator_set"
+
+    type = EnumProperty(
+            name="Type",
+            items=(('TRANSLATE', "Translate", "Use the manipulator for movement transformations"),
+                   ('ROTATE', "Rotate", "Use the manipulator for rotation transformations"),
+                   ('SCALE', "Scale", "Use the manipulator for scale transformations"),
+                  ),
+        )
+
+    def execute(self, context):
+        #show manipulator if user selects an option
+        context.space_data.show_manipulator = True
+
+        context.space_data.transform_manipulators = {self.type}
+
+        return {'FINISHED'}
+
+
 class VIEW3D_PIE_manipulator(Menu):
     bl_label = "Manipulator"
 
@@ -78,7 +100,9 @@ class VIEW3D_PIE_manipulator(Menu):
         layout = self.layout
 
         pie = layout.menu_pie()
-        pie.prop(context.space_data, "transform_manipulators", expand=True)
+        pie.operator("view3d.manipulator_set", icon='MAN_TRANS', text="Translate").type = 'TRANSLATE'
+        pie.operator("view3d.manipulator_set", icon='MAN_ROT', text="Rotate").type = 'ROTATE'
+        pie.operator("view3d.manipulator_set", icon='MAN_SCALE', text="Scale").type = 'SCALE'
         pie.prop(context.space_data, "show_manipulator")
 
 
@@ -110,7 +134,9 @@ addon_keymaps = []
 
 
 def register():
-    #register menus first
+    bpy.utils.register_class(VIEW3D_manipulator_set)
+
+    #register menus
     bpy.utils.register_class(VIEW3D_PIE_object_mode)
     bpy.utils.register_class(VIEW3D_PIE_view)
     bpy.utils.register_class(VIEW3D_PIE_shade)
@@ -138,6 +164,8 @@ def register():
 
 
 def unregister():
+    bpy.utils.unregister_class(VIEW3D_manipulator_set)
+
     bpy.utils.unregister_class(VIEW3D_PIE_object_mode)
     bpy.utils.unregister_class(VIEW3D_PIE_view)
     bpy.utils.unregister_class(VIEW3D_PIE_shade)



More information about the Bf-extensions-cvs mailing list