Sun position: remove unused prop in HDRI mode
[blender-addons.git] / space_view3d_pie_menus / pie_views_numpad_menu.py
blob8798409141181c2982d1a89573e2f4c263046592
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 bl_info = {
22 "name": "Hotkey: 'Alt Q'",
23 "description": "Viewport Numpad Menus",
24 "author": "pitiwazou, meta-androcto",
25 "version": (0, 1, 1),
26 "blender": (2, 80, 0),
27 "location": "Alt Q key",
28 "warning": "",
29 "doc_url": "",
30 "category": "View Numpad Pie"
33 import bpy
34 from bpy.types import (
35 Menu,
36 Operator,
40 # Lock Camera Transforms
41 class PIE_OT_LockTransforms(Operator):
42 bl_idname = "object.locktransforms"
43 bl_label = "Lock Object Transforms"
44 bl_description = ("Enable or disable the editing of objects transforms in the 3D View\n"
45 "Needs an existing Active Object")
46 bl_options = {'REGISTER', 'UNDO'}
48 @classmethod
49 def poll(cls, context):
50 return context.active_object is not None
52 def execute(self, context):
53 obj = context.active_object
54 if obj.lock_rotation[0] is False:
55 obj.lock_rotation[0] = True
56 obj.lock_rotation[1] = True
57 obj.lock_rotation[2] = True
58 obj.lock_scale[0] = True
59 obj.lock_scale[1] = True
60 obj.lock_scale[2] = True
62 elif context.object.lock_rotation[0] is True:
63 obj.lock_rotation[0] = False
64 obj.lock_rotation[1] = False
65 obj.lock_rotation[2] = False
66 obj.lock_scale[0] = False
67 obj.lock_scale[1] = False
68 obj.lock_scale[2] = False
70 return {'FINISHED'}
73 # Pie views numpad - Q
74 class PIE_MT_ViewNumpad(Menu):
75 bl_idname = "PIE_MT_viewnumpad"
76 bl_label = "Pie Views Menu"
78 def draw(self, context):
79 layout = self.layout
80 ob = context.active_object
81 pie = layout.menu_pie()
82 scene = context.scene
83 rd = scene.render
85 # 4 - LEFT
86 pie.operator("view3d.view_axis", text="Left", icon='TRIA_LEFT').type = 'LEFT'
87 # 6 - RIGHT
88 pie.operator("view3d.view_axis", text="Right", icon='TRIA_RIGHT').type = 'RIGHT'
89 # 2 - BOTTOM
90 pie.operator("view3d.view_axis", text="Bottom", icon='TRIA_DOWN').type = 'BOTTOM'
91 # 8 - TOP
92 pie.operator("view3d.view_axis", text="Top", icon='TRIA_UP').type = 'TOP'
93 # 7 - TOP - LEFT
94 pie.operator("view3d.view_axis", text="Back").type = 'BACK'
95 # 9 - TOP - RIGHT
96 pie.operator("view3d.view_axis", text="Front").type = 'FRONT'
97 # 1 - BOTTOM - LEFT
98 box = pie.split().column()
100 row = box.row(align=True)
101 row.operator("view3d.view_camera", text="View Cam", icon='HIDE_OFF')
102 row.operator("view3d.camera_to_view", text="Cam To View", icon='NONE')
104 row = box.row(align=True)
105 if context.space_data.lock_camera is False:
106 row.operator("wm.context_toggle", text="Lock Cam To View",
107 icon='UNLOCKED').data_path = "space_data.lock_camera"
108 elif context.space_data.lock_camera is True:
109 row.operator("wm.context_toggle", text="Lock Cam to View",
110 icon='LOCKED').data_path = "space_data.lock_camera"
112 icon_locked = 'LOCKED' if ob and ob.lock_rotation[0] is False else \
113 'UNLOCKED' if ob and ob.lock_rotation[0] is True else 'LOCKED'
115 row = box.row(align=True)
116 row.operator("object.locktransforms", text="Lock Transforms", icon=icon_locked)
118 row = box.row(align=True)
119 row.prop(rd, "use_border", text="Border")
120 # 3 - BOTTOM - RIGHT
121 box = pie.split().column()
123 row = box.row(align=True)
124 row.operator("view3d.view_all").center = True
125 row.operator("view3d.view_selected", text="Selected")
127 row = box.row(align=True)
128 row.operator("view3d.view_persportho", text="Persp/Ortho")
129 row.operator("view3d.localview", text="Local/Global")
131 row = box.row(align=True)
132 row.operator("screen.region_quadview", text="Toggle Quad")
133 row.operator("screen.screen_full_area", text="Toggle Full")
136 classes = (
137 PIE_MT_ViewNumpad,
138 PIE_OT_LockTransforms,
141 addon_keymaps = []
144 def register():
145 for cls in classes:
146 bpy.utils.register_class(cls)
148 wm = bpy.context.window_manager
149 if wm.keyconfigs.addon:
150 # Views numpad
151 km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
152 kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS', alt=True)
153 kmi.properties.name = "PIE_MT_viewnumpad"
154 addon_keymaps.append((km, kmi))
157 def unregister():
158 for cls in classes:
159 bpy.utils.unregister_class(cls)
161 wm = bpy.context.window_manager
162 kc = wm.keyconfigs.addon
163 if kc:
164 for km, kmi in addon_keymaps:
165 km.keymap_items.remove(kmi)
166 addon_keymaps.clear()
169 if __name__ == "__main__":
170 register()