Use separate root objects to gather the sample visualization and the
[blender-addons-contrib.git] / space_view3d_manipulator_Menu.py
1 #re creating the functionality of the manipulator menu from 2.49
2
3 # ##### BEGIN GPL LICENSE BLOCK #####
4 #
5 #  This program is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU General Public License
7 #  as published by the Free Software Foundation; either version 2
8 #  of the License, or (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with this program; if not, write to the Free Software Foundation,
17 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # ##### END GPL LICENSE BLOCK #####
20
21
22 bl_info = {
23     "name": "3d View: Manipulator Menu",
24     "author": "MichaelW",
25     "version": (1, 2, 1),
26     "blender": (2, 61, 0),
27     "location": "View3D > Ctrl Space ",
28     "description": "Menu to change the manipulator type and/or disable it",
29     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
30                 "Scripts/3D_interaction/Manipulator_Menu",
31     "tracker_url": "https://developer.blender.org/T22092",
32     "category": "3D View"}
33
34
35 import bpy
36
37 def main(context):
38     bpy.context.space_data.manipulator = False
39
40 #class VIEW3D_OT_disable_manipulator(bpy.types.Operator):
41 #    """"""
42 #    bl_idname = "VIEW3D_OT_disable_manipulator"
43 #    bl_label = "disable manipulator"
44 #
45 #    def poll(self, context):
46 #        return context.active_object != None
47 #
48 #    def execute(self, context):
49 #        main(context)
50 #        return {'FINISHED'}
51 #
52
53
54 class VIEW3D_MT_ManipulatorMenu(bpy.types.Menu):
55     bl_label = "ManipulatorType"
56
57     def draw(self, context):
58         layout = self.layout
59         layout.operator_context = 'INVOKE_REGION_WIN'
60
61         props = layout.operator("view3d.enable_manipulator",text ='Translate', icon='MAN_TRANS')
62         props.translate = True
63
64         props = layout.operator("view3d.enable_manipulator",text ='Rotate', icon='MAN_ROT')
65         props.rotate = True
66
67         props = layout.operator("view3d.enable_manipulator",text ='Scale', icon='MAN_SCALE')
68         props.scale = True
69         layout.separator()
70
71         props = layout.operator("view3d.enable_manipulator",text ='Combo', icon='MAN_SCALE')
72         props.scale = True
73         props.rotate = True
74         props.translate = True
75
76         layout.separator()
77
78         props = layout.operator("view3d.enable_manipulator",text ='Hide', icon='MAN_SCALE')
79         props.scale = False
80         props.rotate = False
81         props.translate = False
82
83         layout.separator()
84
85
86
87 def register():
88     bpy.utils.register_module(__name__)
89
90     wm = bpy.context.window_manager
91     km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
92     kmi = km.keymap_items.new('wm.call_menu', 'SPACE', 'PRESS', ctrl=True)
93     kmi.properties.name = "VIEW3D_MT_ManipulatorMenu"
94
95
96 def unregister():
97     bpy.utils.unregister_module(__name__)
98
99     wm = bpy.context.window_manager
100     km = wm.keyconfigs.addon.keymaps['3D View Generic']
101     for kmi in km.keymap_items:
102         if kmi.idname == 'wm.call_menu':
103             if kmi.properties.name == "VIEW3D_MT_ManipulatorMenu":
104                 km.keymap_items.remove(kmi)
105                 break
106
107 if __name__ == "__main__":
108     register