diff options
author | lijenstina <lijenstina@gmail.com> | 2017-07-05 02:22:14 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2017-07-05 02:22:14 +0300 |
commit | 99ed610784b804c175d9e189d9a1b3036973ed61 (patch) | |
tree | 9865ee8d7e95d9747a349409139e0849db6d1d60 /space_view3d_pie_menus/pie_editor_switch_menu.py | |
parent | 759595b17b3a4b04f800d2c12e2af80aa63e4c29 (diff) |
3D Viewport Pie Menus: Cleanup, refactor, fix key register
Bumped version to 1.1.5
Pep8 cleanup
Remove the pie_origin_cursor.py since it is not needed anymore
Part of the T51547:
refactor the key unregister code so it matches the official pies
Note: using this code was crashing blender because of Bool Tool
key registration that left out some lingering keys on unregister
reload
Also there were some wrong calls with the unregister within the
pies themselves
Merge some operators where possible (around 7 less in total)
and use passing arguments instead
Add Enable All / Disable all buttons in the preferences
Comment out the code for authors in the init instead of in
individual scripts
Remove unused imports and cameratoto scene prop
Add an icon at end of registrations line
Fix several crashes with operators being called out of context
Diffstat (limited to 'space_view3d_pie_menus/pie_editor_switch_menu.py')
-rw-r--r-- | space_view3d_pie_menus/pie_editor_switch_menu.py | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/space_view3d_pie_menus/pie_editor_switch_menu.py b/space_view3d_pie_menus/pie_editor_switch_menu.py index 788b053d..67f40ff8 100644 --- a/space_view3d_pie_menus/pie_editor_switch_menu.py +++ b/space_view3d_pie_menus/pie_editor_switch_menu.py @@ -21,8 +21,8 @@ bl_info = { "name": "Hotkey: 'Ctrl Alt S ", "description": "Switch Editor Type Menu", - # "author": "saidenka", - # "version": (0, 1, 0), + "author": "saidenka", + "version": (0, 1, 0), "blender": (2, 77, 0), "location": "All Editors", "warning": "", @@ -69,19 +69,19 @@ class AreaPieEditor(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator(SetAreaType.bl_idname, text="Text Editor", icon="TEXT").type = "TEXT_EDITOR" + pie.operator(SetAreaType.bl_idname, text="Text Editor", icon="TEXT").types = "TEXT_EDITOR" # 6 - RIGHT pie.menu(AreaTypePieAnim.bl_idname, text="Animation Editors", icon="ACTION") # 2 - BOTTOM - pie.operator(SetAreaType.bl_idname, text="Property", icon="BUTS").type = "PROPERTIES" + pie.operator(SetAreaType.bl_idname, text="Property", icon="BUTS").types = "PROPERTIES" # 8 - TOP - pie.operator(SetAreaType.bl_idname, text="3D View", icon="MESH_CUBE").type = "VIEW_3D" + pie.operator(SetAreaType.bl_idname, text="3D View", icon="MESH_CUBE").types = "VIEW_3D" # 7 - TOP - LEFT - pie.operator(SetAreaType.bl_idname, text="UV/Image Editor", icon="IMAGE_COL").type = "IMAGE_EDITOR" + pie.operator(SetAreaType.bl_idname, text="UV/Image Editor", icon="IMAGE_COL").types = "IMAGE_EDITOR" # 9 - TOP - RIGHT - pie.operator(SetAreaType.bl_idname, text="Node Editor", icon="NODETREE").type = "NODE_EDITOR" + pie.operator(SetAreaType.bl_idname, text="Node Editor", icon="NODETREE").types = "NODE_EDITOR" # 1 - BOTTOM - LEFT - pie.operator(SetAreaType.bl_idname, text="Outliner", icon="OOPS").type = "OUTLINER" + pie.operator(SetAreaType.bl_idname, text="Outliner", icon="OOPS").types = "OUTLINER" # 3 - BOTTOM - RIGHT pie.menu(AreaTypePieOther.bl_idname, text="More Editors", icon="QUESTION") @@ -93,17 +93,17 @@ class AreaTypePieOther(Menu): def draw(self, context): # 4 - LEFT - self.layout.operator(SetAreaType.bl_idname, text="Logic Editor", icon="LOGIC").type = "LOGIC_EDITOR" + self.layout.operator(SetAreaType.bl_idname, text="Logic Editor", icon="LOGIC").types = "LOGIC_EDITOR" # 6 - RIGHT - self.layout.operator(SetAreaType.bl_idname, text="File Browser", icon="FILESEL").type = "FILE_BROWSER" + self.layout.operator(SetAreaType.bl_idname, text="File Browser", icon="FILESEL").types = "FILE_BROWSER" # 2 - BOTTOM - self.layout.operator(SetAreaType.bl_idname, text="Python Console", icon="CONSOLE").type = "CONSOLE" + self.layout.operator(SetAreaType.bl_idname, text="Python Console", icon="CONSOLE").types = "CONSOLE" # 8 - TOP # 7 - TOP - LEFT - self.layout.operator(SetAreaType.bl_idname, text="User Setting", - icon="PREFERENCES").type = "USER_PREFERENCES" + self.layout.operator(SetAreaType.bl_idname, text="User Preferences", + icon="PREFERENCES").types = "USER_PREFERENCES" # 9 - TOP - RIGHT - self.layout.operator(SetAreaType.bl_idname, text="Info", icon="INFO").type = "INFO" + self.layout.operator(SetAreaType.bl_idname, text="Info", icon="INFO").types = "INFO" # 1 - BOTTOM - LEFT # 3 - BOTTOM - RIGHT @@ -114,33 +114,33 @@ class SetAreaType(Operator): bl_description = "Change Editor Type" bl_options = {'REGISTER'} - type = StringProperty(name="Area Type") + types = StringProperty(name="Area Type") def execute(self, context): - context.area.type = self.type + context.area.type = self.types return {'FINISHED'} class AreaTypePieAnim(Menu): bl_idname = "INFO_MT_window_pie_area_type_anim" bl_label = "Editor Type (Animation)" - bl_description = "Is pie menu change editor type (animation related)" + bl_description = "Menu for changing editor type (animation related)" def draw(self, context): # 4 - LEFT - self.layout.operator(SetAreaType.bl_idname, text="NLA Editor", icon="NLA").type = "NLA_EDITOR" + self.layout.operator(SetAreaType.bl_idname, text="NLA Editor", icon="NLA").types = "NLA_EDITOR" # 6 - RIGHT - self.layout.operator(SetAreaType.bl_idname, text="DopeSheet", icon="ACTION").type = "DOPESHEET_EDITOR" + self.layout.operator(SetAreaType.bl_idname, text="DopeSheet", icon="ACTION").types = "DOPESHEET_EDITOR" # 2 - BOTTOM - self.layout.operator(SetAreaType.bl_idname, text="Graph Editor", icon="IPO").type = "GRAPH_EDITOR" + self.layout.operator(SetAreaType.bl_idname, text="Graph Editor", icon="IPO").types = "GRAPH_EDITOR" # 8 - TOP - self.layout.operator(SetAreaType.bl_idname, text="Timeline", icon="TIME").type = "TIMELINE" + self.layout.operator(SetAreaType.bl_idname, text="Timeline", icon="TIME").types = "TIMELINE" # 7 - TOP - LEFT self.layout.operator(SetAreaType.bl_idname, - text="Video Sequence Editor", icon="SEQUENCE").type = "SEQUENCE_EDITOR" + text="Video Sequence Editor", icon="SEQUENCE").types = "SEQUENCE_EDITOR" # 9 - TOP - RIGHT self.layout.operator(SetAreaType.bl_idname, - text="Video Clip Editor", icon="RENDER_ANIMATION").type = "CLIP_EDITOR" + text="Video Clip Editor", icon="RENDER_ANIMATION").types = "CLIP_EDITOR" # 1 - BOTTOM - LEFT self.layout.operator("wm.call_menu_pie", text="Back", icon="BACK").name = AreaPieEditor.bl_idname # 3 - BOTTOM - RIGHT @@ -161,29 +161,26 @@ addon_keymaps = [] def register(): for cls in classes: bpy.utils.register_class(cls) - wm = bpy.context.window_manager + wm = bpy.context.window_manager if wm.keyconfigs.addon: # Snapping km = wm.keyconfigs.addon.keymaps.new(name='Window') kmi = km.keymap_items.new('wm.call_menu_pie', 'S', 'PRESS', ctrl=True, alt=True) kmi.properties.name = "pie.editor" -# kmi.active = True addon_keymaps.append((km, kmi)) def unregister(): for cls in classes: bpy.utils.unregister_class(cls) - wm = bpy.context.window_manager + wm = bpy.context.window_manager kc = wm.keyconfigs.addon if kc: - km = kc.keymaps['Window'] - for kmi in km.keymap_items: - if kmi.idname == 'wm.call_menu_pie': - if kmi.properties.name == "wm.area_type_pie_operator": - km.keymap_items.remove(kmi) + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) + addon_keymaps.clear() if __name__ == "__main__": |