Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-07-05 02:22:14 +0300
committerlijenstina <lijenstina@gmail.com>2017-07-05 02:22:14 +0300
commit99ed610784b804c175d9e189d9a1b3036973ed61 (patch)
tree9865ee8d7e95d9747a349409139e0849db6d1d60 /space_view3d_pie_menus/pie_views_numpad_menu.py
parent759595b17b3a4b04f800d2c12e2af80aa63e4c29 (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_views_numpad_menu.py')
-rw-r--r--space_view3d_pie_menus/pie_views_numpad_menu.py69
1 files changed, 28 insertions, 41 deletions
diff --git a/space_view3d_pie_menus/pie_views_numpad_menu.py b/space_view3d_pie_menus/pie_views_numpad_menu.py
index a176258a..02cf5464 100644
--- a/space_view3d_pie_menus/pie_views_numpad_menu.py
+++ b/space_view3d_pie_menus/pie_views_numpad_menu.py
@@ -21,8 +21,8 @@
bl_info = {
"name": "Hotkey: 'Q'",
"description": "Viewport Numpad Menus",
- # "author": "pitiwazou, meta-androcto",
- # "version": (0, 1, 0),
+ "author": "pitiwazou, meta-androcto",
+ "version": (0, 1, 1),
"blender": (2, 77, 0),
"location": "Q key",
"warning": "",
@@ -35,47 +35,42 @@ from bpy.types import (
Menu,
Operator,
)
-from bpy.props import (
- StringProperty,
- )
-
-# Lock Camera Transforms
+# Lock Camera Transforms
class LockTransforms(Operator):
bl_idname = "object.locktransforms"
bl_label = "Lock Object Transforms"
+ bl_description = ("Enable or disable the editing of objects transforms in the 3D View\n"
+ "Needs an existing Active Object")
bl_options = {'REGISTER', 'UNDO'}
+ @classmethod
+ def poll(cls, context):
+ return context.active_object is not None
+
def execute(self, context):
- obj = context.object
- if obj.lock_rotation[0] == False:
+ obj = context.active_object
+ if obj.lock_rotation[0] is False:
obj.lock_rotation[0] = True
obj.lock_rotation[1] = True
obj.lock_rotation[2] = True
- obj.lock_location[0] = True
- obj.lock_location[1] = True
- obj.lock_location[2] = True
obj.lock_scale[0] = True
obj.lock_scale[1] = True
obj.lock_scale[2] = True
- elif context.object.lock_rotation[0] == True:
+ elif context.object.lock_rotation[0] is True:
obj.lock_rotation[0] = False
obj.lock_rotation[1] = False
obj.lock_rotation[2] = False
- obj.lock_location[0] = False
- obj.lock_location[1] = False
- obj.lock_location[2] = False
obj.lock_scale[0] = False
obj.lock_scale[1] = False
obj.lock_scale[2] = False
+
return {'FINISHED'}
# Pie View All Sel Glob Etc - Q
-
-
class PieViewallSelGlobEtc(Menu):
bl_idname = "pie.vieallselglobetc"
bl_label = "Pie View All Sel Glob..."
@@ -99,16 +94,15 @@ class PieViewallSelGlobEtc(Menu):
layout.operator("screen.screen_full_area", text="Full Screen", icon='FULLSCREEN_ENTER')
# 3 - BOTTOM - RIGHT
-# Pie views numpad - Q
-
+# Pie views numpad - Q
class PieViewNumpad(Menu):
bl_idname = "pie.viewnumpad"
bl_label = "Pie Views Ortho"
def draw(self, context):
layout = self.layout
- ob = context.object
+ ob = context.active_object
pie = layout.menu_pie()
scene = context.scene
rd = scene.render
@@ -128,10 +122,11 @@ class PieViewNumpad(Menu):
# 1 - BOTTOM - LEFT
box = pie.split().column()
row = box.row(align=True)
- if context.space_data.lock_camera == False:
+
+ if context.space_data.lock_camera is False:
row.operator("wm.context_toggle", text="Lock Cam to View",
icon='UNLOCKED').data_path = "space_data.lock_camera"
- elif context.space_data.lock_camera == True:
+ elif context.space_data.lock_camera is True:
row.operator("wm.context_toggle", text="Lock Cam to View",
icon='LOCKED').data_path = "space_data.lock_camera"
@@ -139,18 +134,18 @@ class PieViewNumpad(Menu):
row.operator("view3d.viewnumpad", text="View Cam", icon='VISIBLE_IPO_ON').type = 'CAMERA'
row.operator("view3d.camera_to_view", text="Cam to view", icon='MAN_TRANS')
- if ob.lock_rotation[0] == False:
- row = box.row(align=True)
- row.operator("object.locktransforms", text="Lock Transforms", icon='LOCKED')
+ icon_locked = 'LOCKED' if ob and ob.lock_rotation[0] is False else \
+ 'UNLOCKED' if ob and ob.lock_rotation[0] is True else 'LOCKED'
+
+ row = box.row(align=True)
+ row.operator("object.locktransforms", text="Lock Transforms", icon=icon_locked)
- elif ob.lock_rotation[0] == True:
- row = box.row(align=True)
- row.operator("object.locktransforms", text="UnLock Transforms", icon='UNLOCKED')
row = box.row(align=True)
row.prop(rd, "use_border", text="Border")
# 3 - BOTTOM - RIGHT
pie.menu(PieViewallSelGlobEtc.bl_idname, text="View Menu", icon='BBOX')
+
classes = (
PieViewNumpad,
LockTransforms,
@@ -164,34 +159,26 @@ def register():
for cls in classes:
bpy.utils.register_class(cls)
-# Active Camera
- bpy.types.Scene.cameratoto = bpy.props.StringProperty(default="")
-
wm = bpy.context.window_manager
-
if wm.keyconfigs.addon:
# Views numpad
km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS')
kmi.properties.name = "pie.viewnumpad"
-# 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['3D View Generic']
- for kmi in km.keymap_items:
- if kmi.idname == 'wm.call_menu_pie':
- if kmi.properties.name == "pie.viewnumpad":
- km.keymap_items.remove(kmi)
+ for km, kmi in addon_keymaps:
+ km.keymap_items.remove(kmi)
+ addon_keymaps.clear()
- del bpy.types.Scene.cameratoto
if __name__ == "__main__":
register()