Remove win2k check
[blender-addons.git] / ui_pie_menus_official.py
blob7e627cc6685ce1cb767e2300cfbedb1316d4ba81
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": "Pie Menus Official",
23 "author": "Antony Riakiotakis, Sebastian Koenig",
24 "version": (1, 0, 2),
25 "blender": (2, 71, 4),
26 "description": "Enable official Pie Menus in Blender",
27 "category": "User Interface",
28 "wiki_url": "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/UI/Pie_Menus"
32 import bpy
33 from bpy.types import Menu, Operator
34 from bpy.props import EnumProperty
37 class VIEW3D_PIE_object_mode(Menu):
38 bl_label = "Mode"
40 def draw(self, context):
41 layout = self.layout
43 pie = layout.menu_pie()
44 pie.operator_enum("OBJECT_OT_mode_set", "mode")
47 class VIEW3D_PIE_view_more(Menu):
48 bl_label = "More"
50 def draw(self, context):
51 layout = self.layout
53 pie = layout.menu_pie()
54 pie.operator("VIEW3D_OT_view_persportho", text="Persp/Ortho", icon='RESTRICT_VIEW_OFF')
55 pie.operator("VIEW3D_OT_camera_to_view")
56 pie.operator("VIEW3D_OT_view_selected")
57 pie.operator("VIEW3D_OT_view_all")
58 pie.operator("VIEW3D_OT_localview")
59 pie.operator("SCREEN_OT_region_quadview")
62 class VIEW3D_PIE_view(Menu):
63 bl_label = "View"
65 def draw(self, context):
66 layout = self.layout
68 pie = layout.menu_pie()
69 pie.operator_enum("VIEW3D_OT_viewnumpad", "type")
70 pie.operator("wm.call_menu_pie", text="More", icon='PLUS').name = "VIEW3D_PIE_view_more"
73 class VIEW3D_PIE_shade(Menu):
74 bl_label = "Shade"
76 def draw(self, context):
77 layout = self.layout
79 pie = layout.menu_pie()
80 pie.prop(context.space_data, "viewport_shade", expand=True)
82 if context.active_object:
83 if(context.mode == 'EDIT_MESH'):
84 pie.operator("MESH_OT_faces_shade_smooth")
85 pie.operator("MESH_OT_faces_shade_flat")
86 else:
87 pie.operator("OBJECT_OT_shade_smooth")
88 pie.operator("OBJECT_OT_shade_flat")
91 class VIEW3D_manipulator_set(Operator):
92 bl_label = "Set Manipulator"
93 bl_idname = "view3d.manipulator_set"
95 type = EnumProperty(
96 name="Type",
97 items=(('TRANSLATE', "Translate", "Use the manipulator for movement transformations"),
98 ('ROTATE', "Rotate", "Use the manipulator for rotation transformations"),
99 ('SCALE', "Scale", "Use the manipulator for scale transformations"),
103 def execute(self, context):
104 # show manipulator if user selects an option
105 context.space_data.show_manipulator = True
107 context.space_data.transform_manipulators = {self.type}
109 return {'FINISHED'}
112 class VIEW3D_PIE_manipulator(Menu):
113 bl_label = "Manipulator"
115 def draw(self, context):
116 layout = self.layout
118 pie = layout.menu_pie()
119 pie.operator("view3d.manipulator_set", icon='MAN_TRANS', text="Translate").type = 'TRANSLATE'
120 pie.operator("view3d.manipulator_set", icon='MAN_ROT', text="Rotate").type = 'ROTATE'
121 pie.operator("view3d.manipulator_set", icon='MAN_SCALE', text="Scale").type = 'SCALE'
122 pie.prop(context.space_data, "show_manipulator")
125 class VIEW3D_PIE_pivot(Menu):
126 bl_label = "Pivot"
128 def draw(self, context):
129 layout = self.layout
131 pie = layout.menu_pie()
132 pie.prop(context.space_data, "pivot_point", expand=True)
133 if context.active_object.mode == 'OBJECT':
134 pie.prop(context.space_data, "use_pivot_point_align", text="Center Points")
137 class VIEW3D_PIE_snap(Menu):
138 bl_label = "Snapping"
140 def draw(self, context):
141 layout = self.layout
143 toolsettings = context.tool_settings
144 pie = layout.menu_pie()
145 pie.prop(toolsettings, "snap_element", expand=True)
146 pie.prop(toolsettings, "use_snap")
149 class CLIP_PIE_refine_pie(Menu):
150 # Refinement Options
151 bl_label = "Refine Intrinsics"
153 def draw(self, context):
154 clip = context.space_data.clip
155 settings = clip.tracking.settings
157 layout = self.layout
158 pie = layout.menu_pie()
160 pie.prop(settings, "refine_intrinsics", expand=True)
163 class CLIP_PIE_geometry_reconstruction(Menu):
164 # Geometry Reconstruction
165 bl_label = "Reconstruction"
167 def draw(self, context):
168 layout = self.layout
169 pie = layout.menu_pie()
171 pie.operator("clip.bundles_to_mesh", icon='MESH_DATA')
172 pie.operator("clip.track_to_empty", icon='EMPTY_DATA')
175 class CLIP_PIE_proxy_pie(Menu):
176 # Proxy Controls
177 bl_label = "Proxy Size"
179 def draw(self, context):
180 space = context.space_data
182 layout = self.layout
183 pie = layout.menu_pie()
185 pie.prop(space.clip, "use_proxy", text="Use Proxy")
186 pie.prop(space.clip_user, "proxy_render_size", expand=True)
189 class CLIP_PIE_display_pie(Menu):
190 # Display Options
191 bl_label = "Marker Display"
193 def draw(self, context):
194 space = context.space_data
196 layout = self.layout
197 pie = layout.menu_pie()
199 pie.prop(space, "show_names", text="Show Track Info", icon='WORDWRAP_ON')
200 pie.prop(space, "show_disabled", text="Show Disabled Tracks", icon='VISIBLE_IPO_ON')
201 pie.prop(space, "show_marker_search", text="Display Search Area", icon='VIEWZOOM')
202 pie.prop(space, "show_marker_pattern", text="Display Pattern Area", icon='BORDERMOVE')
205 class CLIP_PIE_marker_pie(Menu):
206 # Settings for the individual markers
207 bl_label = "Marker Settings"
209 def draw(self, context):
210 clip = context.space_data.clip
211 track_active = clip.tracking.tracks.active
213 layout = self.layout
214 pie = layout.menu_pie()
216 prop = pie.operator("wm.context_set_enum", text="Loc", icon='OUTLINER_DATA_EMPTY')
217 prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
218 prop.value = "Loc"
219 prop = pie.operator("wm.context_set_enum", text="Affine", icon='OUTLINER_DATA_LATTICE')
220 prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
221 prop.value = "Affine"
223 pie.operator("clip.track_settings_to_track", icon='COPYDOWN')
224 pie.operator("clip.track_settings_as_default", icon='SETTINGS')
226 if track_active:
227 pie.prop(track_active, "use_normalization", text="Normalization")
228 pie.prop(track_active, "use_brute", text="Use Brute Force")
229 pie.prop(track_active, "use_blue_channel", text="Blue Channel")
231 if track_active.pattern_match == "PREV_FRAME":
232 prop = pie.operator("wm.context_set_enum", text="Match Previous", icon='KEYINGSET')
233 prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
234 prop.value = 'KEYFRAME'
235 else:
236 prop = pie.operator("wm.context_set_enum", text="Match Keyframe", icon='KEY_HLT')
237 prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
238 prop.value = 'PREV_FRAME'
241 class CLIP_PIE_tracking_pie(Menu):
242 # Tracking Operators
243 bl_label = "Tracking"
245 def draw(self, context):
246 layout = self.layout
247 pie = layout.menu_pie()
249 prop = pie.operator("clip.track_markers", icon='PLAY_REVERSE')
250 prop.backwards = True
251 prop.sequence = True
252 prop = pie.operator("clip.track_markers", icon='PLAY')
253 prop.backwards = False
254 prop.sequence = True
256 pie.operator("clip.disable_markers", icon='RESTRICT_VIEW_ON')
257 pie.operator("clip.detect_features", icon='ZOOM_SELECTED')
259 pie.operator("clip.clear_track_path", icon='BACK').action = 'UPTO'
260 pie.operator("clip.clear_track_path", icon='FORWARD').action = 'REMAINED'
262 pie.operator("clip.refine_markers", icon='LOOP_BACK').backwards = True
263 pie.operator("clip.refine_markers", icon='LOOP_FORWARDS').backwards = False
266 class CLIP_PIE_clipsetup_pie(Menu):
267 # Setup the clip display options
268 bl_label = "Clip and Display Setup"
270 def draw(self, context):
271 space = context.space_data
273 layout = self.layout
274 pie = layout.menu_pie()
276 pie.operator("clip.reload", text="Reload Footage", icon='FILE_REFRESH')
277 pie.operator("clip.prefetch", text="Prefetch Footage", icon='LOOP_FORWARDS')
279 pie.prop(space, "use_mute_footage", text="Mute Footage", icon='MUTE_IPO_ON')
280 pie.prop(space.clip_user, "use_render_undistorted", text="Render Undistorted")
281 pie.operator("clip.set_scene_frames", text="Set Scene Frames", icon='SCENE_DATA')
282 pie.operator("wm.call_menu_pie", text="Marker Display", icon='PLUS').name = "CLIP_PIE_display_pie"
283 pie.operator("clip.set_active_clip", icon='CLIP')
284 pie.operator("wm.call_menu_pie", text="Proxy", icon='PLUS').name = "CLIP_PIE_proxy_pie"
287 class CLIP_PIE_solver_pie(Menu):
288 # Operators to solve the scene
289 bl_label = "Solving"
291 def draw(self, context):
292 clip = context.space_data.clip
293 settings = clip.tracking.settings
295 layout = self.layout
296 pie = layout.menu_pie()
298 pie.operator("clip.create_plane_track", icon='MESH_PLANE')
299 pie.operator("clip.solve_camera", text="Solve Camera", icon='OUTLINER_OB_CAMERA')
301 pie.operator("wm.call_menu_pie", text="Refinement", icon='CAMERA_DATA').name = "CLIP_PIE_refine_pie"
302 pie.prop(settings, "use_tripod_solver", text="Tripod Solver")
304 pie.operator("clip.set_solver_keyframe", text="Set Keyframe A", icon='KEY_HLT').keyframe = 'KEYFRAME_A'
305 pie.operator("clip.set_solver_keyframe", text="Set Keyframe B", icon='KEY_HLT').keyframe = 'KEYFRAME_B'
307 prop = pie.operator("clip.clean_tracks", icon='STICKY_UVS_DISABLE')
308 pie.operator("clip.filter_tracks", icon='FILTER')
309 prop.frames = 15
310 prop.error = 2
313 class CLIP_PIE_reconstruction_pie(Menu):
314 # Scene Reconstruction
315 bl_label = "Reconstruction"
317 def draw(self, context):
318 layout = self.layout
319 pie = layout.menu_pie()
321 pie.operator("clip.set_viewport_background", text="Set Viewport Background", icon='SCENE_DATA')
322 pie.operator("clip.setup_tracking_scene", text="Setup Tracking Scene", icon='SCENE_DATA')
324 pie.operator("clip.set_plane", text="Setup Floor", icon='MESH_PLANE')
325 pie.operator("clip.set_origin", text="Set Origin", icon='MANIPUL')
327 pie.operator("clip.set_axis", text="Set X Axis", icon='AXIS_FRONT').axis = 'X'
328 pie.operator("clip.set_axis", text="Set Y Axis", icon='AXIS_SIDE').axis = 'Y'
330 pie.operator("clip.set_scale", text="Set Scale", icon='ARROW_LEFTRIGHT')
331 pie.operator("wm.call_menu_pie", text="Reconstruction", icon='MESH_DATA').name = "CLIP_PIE_geometry_reconstruction"
334 class CLIP_PIE_timecontrol_pie(Menu):
335 # Time Controls
336 bl_label = "Time Control"
338 def draw(self, context):
339 layout = self.layout
340 pie = layout.menu_pie()
342 pie.operator("screen.frame_jump", text="Jump to Startframe", icon='TRIA_LEFT').end = False
343 pie.operator("screen.frame_jump", text="Jump to Endframe", icon='TRIA_RIGHT').end = True
345 pie.operator("clip.frame_jump", text="Start of Track", icon='REW').position = 'PATHSTART'
346 pie.operator("clip.frame_jump", text="End of Track", icon='FF').position = 'PATHEND'
348 pie.operator("screen.animation_play", text="Playback Backwards", icon='PLAY_REVERSE').reverse = True
349 pie.operator("screen.animation_play", text="Playback Forwards", icon='PLAY').reverse = False
351 pie.operator("screen.frame_offset", text="Previous Frame", icon='TRIA_LEFT').delta = -1
352 pie.operator("screen.frame_offset", text="Next Frame", icon='TRIA_RIGHT').delta = 1
355 addon_keymaps = []
357 classes = (
358 VIEW3D_manipulator_set,
360 VIEW3D_PIE_object_mode,
361 VIEW3D_PIE_view,
362 VIEW3D_PIE_view_more,
363 VIEW3D_PIE_shade,
364 VIEW3D_PIE_manipulator,
365 VIEW3D_PIE_pivot,
366 VIEW3D_PIE_snap,
368 CLIP_PIE_geometry_reconstruction,
369 CLIP_PIE_tracking_pie,
370 CLIP_PIE_display_pie,
371 CLIP_PIE_proxy_pie,
372 CLIP_PIE_marker_pie,
373 CLIP_PIE_solver_pie,
374 CLIP_PIE_refine_pie,
375 CLIP_PIE_reconstruction_pie,
376 CLIP_PIE_clipsetup_pie,
377 CLIP_PIE_timecontrol_pie,
381 def register():
382 for cls in classes:
383 bpy.utils.register_class(cls)
385 wm = bpy.context.window_manager
387 if wm.keyconfigs.addon:
388 km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
389 kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS')
390 kmi.properties.name = 'VIEW3D_PIE_object_mode'
391 kmi = km.keymap_items.new('wm.call_menu_pie', 'Z', 'PRESS')
392 kmi.properties.name = 'VIEW3D_PIE_shade'
393 kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS')
394 kmi.properties.name = 'VIEW3D_PIE_view'
395 kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', ctrl=True)
396 kmi.properties.name = 'VIEW3D_PIE_manipulator'
397 kmi = km.keymap_items.new('wm.call_menu_pie', 'PERIOD', 'PRESS')
398 kmi.properties.name = 'VIEW3D_PIE_pivot'
399 kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS', ctrl=True, shift=True)
400 kmi.properties.name = 'VIEW3D_PIE_snap'
401 addon_keymaps.append(km)
403 km = wm.keyconfigs.addon.keymaps.new(name="Clip", space_type='CLIP_EDITOR')
404 kmi = km.keymap_items.new("wm.call_menu_pie", 'Q', 'PRESS')
405 kmi.properties.name = "CLIP_PIE_marker_pie"
406 kmi = km.keymap_items.new("wm.call_menu_pie", 'W', 'PRESS')
407 kmi.properties.name = "CLIP_PIE_clipsetup_pie"
408 kmi = km.keymap_items.new("wm.call_menu_pie", 'E', 'PRESS')
409 kmi.properties.name = "CLIP_PIE_tracking_pie"
410 kmi = km.keymap_items.new("wm.call_menu_pie", 'S', 'PRESS', shift=True)
411 kmi.properties.name = "CLIP_PIE_solver_pie"
412 kmi = km.keymap_items.new("wm.call_menu_pie", 'W', 'PRESS', shift=True)
413 kmi.properties.name = "CLIP_PIE_reconstruction_pie"
414 addon_keymaps.append(km)
416 km = wm.keyconfigs.addon.keymaps.new(name="Frames")
417 kmi = km.keymap_items.new("wm.call_menu_pie", 'A', 'PRESS', oskey=True)
418 kmi.properties.name = "CLIP_PIE_timecontrol_pie"
420 addon_keymaps.append(km)
423 def unregister():
424 for cls in classes:
425 bpy.utils.unregister_class(cls)
427 wm = bpy.context.window_manager
429 if wm.keyconfigs.addon:
430 for km in addon_keymaps:
431 for kmi in km.keymap_items:
432 km.keymap_items.remove(kmi)
434 wm.keyconfigs.addon.keymaps.remove(km)
436 addon_keymaps.clear()