Pie Menu manipulators - use tools
[blender-addons.git] / pie_menus_official / pie_manipulator_of.py
blobef25d369b5a54dfb32d37948e5b4df1a37ef8e45
2 bl_info = {
3 "name": "Manipulator Menu: Key: 'Ctrl Space'",
4 "description": "Manipulator Modes",
5 "author": "Antony Riakiotakis, Sebastian Koenig",
6 "version": (0, 1, 1),
7 "blender": (2, 77, 0),
8 "location": "Ctrl Space",
9 "warning": "",
10 "wiki_url": "",
11 "category": "3d View"
14 import bpy
15 from bpy.types import (
16 Menu,
17 Operator,
19 from bpy.props import (
20 EnumProperty,
24 # Pie Manipulator Mode - Ctrl Space
25 class VIEW3D_manipulator_set_of(Operator):
26 bl_label = "Set Manipulator"
27 bl_idname = "view3d.manipulator_set"
29 type = EnumProperty(
30 name="Type",
31 items=(('TRANSLATE', "Translate", "Use the manipulator for movement transformations"),
32 ('ROTATE', "Rotate", "Use the manipulator for rotation transformations"),
33 ('SCALE', "Scale", "Use the manipulator for scale transformations"),
37 def execute(self, context):
38 # show manipulator if user selects an option
39 context.space_data.show_manipulator = True
40 context.space_data.transform_manipulators = {self.type}
42 return {'FINISHED'}
45 class VIEW3D_PIE_manipulator_of(Menu):
46 bl_label = "Manipulator"
47 bl_idname = "view3d.manipulator_of"
49 def draw(self, context):
50 layout = self.layout
52 pie = layout.menu_pie()
53 pie.operator("wm.tool_set_by_name", icon='MAN_TRANS', text="Translate").name = "Move"
54 pie.operator("wm.tool_set_by_name", icon='MAN_ROT', text="Rotate").name = "Rotate"
55 pie.operator("wm.tool_set_by_name", icon='MAN_SCALE', text="Scale").name = "Scale"
56 pie.prop(context.space_data, "show_manipulator")
59 classes = (
60 VIEW3D_manipulator_set_of,
61 VIEW3D_PIE_manipulator_of,
64 addon_keymaps = []
67 def register():
68 for cls in classes:
69 bpy.utils.register_class(cls)
70 wm = bpy.context.window_manager
72 if wm.keyconfigs.addon:
73 # Align
74 km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
75 kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', ctrl=True)
76 kmi.properties.name = "view3d.manipulator_of"
77 addon_keymaps.append((km, kmi))
80 def unregister():
81 for cls in classes:
82 bpy.utils.unregister_class(cls)
84 wm = bpy.context.window_manager
85 kc = wm.keyconfigs.addon
86 if kc:
87 for km, kmi in addon_keymaps:
88 km.keymap_items.remove(kmi)
89 addon_keymaps.clear()
92 if __name__ == "__main__":
93 register()