[Bf-extensions-cvs] [99ed6107] master: 3D Viewport Pie Menus: Cleanup, refactor, fix key register

lijenstina noreply at git.blender.org
Wed Jul 5 01:23:08 CEST 2017


Commit: 99ed610784b804c175d9e189d9a1b3036973ed61
Author: lijenstina
Date:   Wed Jul 5 01:22:14 2017 +0200
Branches: master
https://developer.blender.org/rBA99ed610784b804c175d9e189d9a1b3036973ed61

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

===================================================================

M	space_view3d_pie_menus/__init__.py
M	space_view3d_pie_menus/pie_align_menu.py
M	space_view3d_pie_menus/pie_animation_menu.py
M	space_view3d_pie_menus/pie_apply_transform_menu.py
M	space_view3d_pie_menus/pie_cursor.py
M	space_view3d_pie_menus/pie_delete_menu.py
M	space_view3d_pie_menus/pie_editor_switch_menu.py
M	space_view3d_pie_menus/pie_manipulator_menu.py
M	space_view3d_pie_menus/pie_modes_menu.py
M	space_view3d_pie_menus/pie_orientation_menu.py
M	space_view3d_pie_menus/pie_origin.py
D	space_view3d_pie_menus/pie_origin_cursor.py
M	space_view3d_pie_menus/pie_pivot_point_menu.py
M	space_view3d_pie_menus/pie_proportional_menu.py
M	space_view3d_pie_menus/pie_save_open_menu.py
M	space_view3d_pie_menus/pie_sculpt_menu.py
M	space_view3d_pie_menus/pie_select_menu.py
M	space_view3d_pie_menus/pie_shading_menu.py
M	space_view3d_pie_menus/pie_snap_menu.py
M	space_view3d_pie_menus/pie_views_numpad_menu.py

===================================================================

diff --git a/space_view3d_pie_menus/__init__.py b/space_view3d_pie_menus/__init__.py
index 5a08426f..01afb97b 100644
--- a/space_view3d_pie_menus/__init__.py
+++ b/space_view3d_pie_menus/__init__.py
@@ -18,19 +18,6 @@
 
 # <pep8 compliant>
 
-bl_info = {
-    "name": "3D Viewport Pie Menus",
-    "author": "meta-androcto, pitiwazou, chromoly, italic",
-    "version": (1, 1, 4),
-    "blender": (2, 7, 7),
-    "description": "Individual Pie Menu Activation List",
-    "location": "Addons Preferences",
-    "warning": "",
-    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
-    "Scripts/3D_interaction/viewport_pies",
-    "category": "Pie Menu"
-    }
-
 
 import bpy
 from bpy.props import (
@@ -42,6 +29,20 @@ from bpy.types import (
         AddonPreferences,
         )
 
+
+bl_info = {
+    "name": "3D Viewport Pie Menus",
+    "author": "meta-androcto, pitiwazou, chromoly, italic",
+    "version": (1, 1, 5),
+    "blender": (2, 7, 7),
+    "description": "Individual Pie Menu Activation List",
+    "location": "Addons Preferences",
+    "warning": "",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/3D_interaction/viewport_pies",
+    "category": "Pie Menu"
+    }
+
 sub_modules_names = (
     "pie_modes_menu",
     "pie_views_numpad_menu",
@@ -64,7 +65,8 @@ sub_modules_names = (
     )
 
 
-sub_modules = [__import__(__package__ + "." + submod, {}, {}, submod) for submod in sub_modules_names]
+sub_modules = [__import__(__package__ + "." + submod, {}, {}, submod) for
+              submod in sub_modules_names]
 sub_modules.sort(key=lambda mod: (mod.bl_info['category'], mod.bl_info['name']))
 
 
@@ -122,11 +124,60 @@ def unregister_submodule(mod):
                     del prefs[name]
 
 
+def enable_all_modules(self, context):
+    for mod in sub_modules:
+        mod_name = mod.__name__.split('.')[-1]
+        setattr(self, 'use_' + mod_name, False)
+        if not mod.__addon_enabled__:
+            setattr(self, 'use_' + mod_name, True)
+            mod.__addon_enabled__ = True
+
+    return None
+
+
+def disable_all_modules(self, context):
+    for mod in sub_modules:
+        mod_name = mod.__name__.split('.')[-1]
+
+        if mod.__addon_enabled__:
+            setattr(self, 'use_' + mod_name, False)
+            mod.__addon_enabled__ = False
+
+    return None
+
+
 class PieToolsPreferences(AddonPreferences):
     bl_idname = __name__
 
+    enable_all = BoolProperty(
+            name="Enable all",
+            description="Enable all Pie Modules",
+            default=False,
+            update=enable_all_modules
+            )
+    disable_all = BoolProperty(
+            name="Disable all",
+            description="Disable all Pie Modules",
+            default=False,
+            update=disable_all_modules
+            )
+
     def draw(self, context):
         layout = self.layout
+        split = layout.split(percentage=0.5, align=True)
+        row = split.row()
+        row.alignment = "LEFT"
+        sub_box = row.box()
+        sub_box.prop(self, "enable_all", emboss=False,
+                    icon="VISIBLE_IPO_ON", icon_only=True)
+        row.label("Enable All")
+
+        row = split.row()
+        row.alignment = "RIGHT"
+        row.label("Disable All")
+        sub_box = row.box()
+        sub_box.prop(self, "disable_all", emboss=False,
+                    icon="VISIBLE_IPO_OFF", icon_only=True)
 
         for mod in sub_modules:
             mod_name = mod.__name__.split('.')[-1]
@@ -161,10 +212,12 @@ class PieToolsPreferences(AddonPreferences):
                     split = col.row().split(percentage=0.15)
                     split.label('Location:')
                     split.label(info['location'])
-                if info.get('author') and info.get('author') != 'chromoly':
+                """
+                if info.get('author'):
                     split = col.row().split(percentage=0.15)
                     split.label('Author:')
                     split.label(info['author'])
+                """
                 if info.get('version'):
                     split = col.row().split(percentage=0.15)
                     split.label('Version:')
@@ -196,12 +249,14 @@ class PieToolsPreferences(AddonPreferences):
                         try:
                             prefs.draw(context)
                         except:
+                            import traceback
                             traceback.print_exc()
                             box.label(text='Error (see console)', icon='ERROR')
                         del prefs.layout
 
         row = layout.row()
-        row.label("End of Pie Menu Activations")
+        row.label(text="End of Advanced Object Panels Activations",
+                  icon="FILE_PARENT")
 
 
 for mod in sub_modules:
@@ -219,10 +274,10 @@ for mod in sub_modules:
         return update
 
     prop = BoolProperty(
-        name=info['name'],
-        description=info.get('description', ''),
-        update=gen_update(mod),
-    )
+            name=info['name'],
+            description=info.get('description', ''),
+            update=gen_update(mod),
+            )
     setattr(PieToolsPreferences, 'use_' + mod_name, prop)
     prop = BoolProperty()
     setattr(PieToolsPreferences, 'show_expanded_' + mod_name, prop)
@@ -253,5 +308,6 @@ def unregister():
     for cls in reversed(classes):
         bpy.utils.unregister_class(cls)
 
+
 if __name__ == "__main__":
     register()
diff --git a/space_view3d_pie_menus/pie_align_menu.py b/space_view3d_pie_menus/pie_align_menu.py
index 94b0e1cf..c77b9253 100644
--- a/space_view3d_pie_menus/pie_align_menu.py
+++ b/space_view3d_pie_menus/pie_align_menu.py
@@ -21,8 +21,8 @@
 bl_info = {
     "name": "Hotkey: 'Alt X'",
     "description": "V/E/F Align tools",
-    #    "author": "pitiwazou, meta-androcto",
-    #    "version": (0, 1, 0),
+    "author": "pitiwazou, meta-androcto",
+    "version": (0, 1, 1),
     "blender": (2, 77, 0),
     "location": "Mesh Edit Mode",
     "warning": "",
@@ -35,11 +35,10 @@ from bpy.types import (
         Menu,
         Operator,
         )
+from bpy.props import EnumProperty
 
 
 # Pie Align - Alt + X
-
-
 class PieAlign(Menu):
     bl_idname = "pie.align"
     bl_label = "Pie Align"
@@ -54,32 +53,46 @@ class PieAlign(Menu):
         # 2 - BOTTOM
         pie.operator("align.y", text="Align Y", icon='PLUS')
         # 8 - TOP
-        pie.operator("align.2y0", text="Align To Y-0")
+        pie.operator("align.2xyz", text="Align To Y-0").axis = '1'
         # 7 - TOP - LEFT
-        pie.operator("align.2x0", text="Align To X-0")
+        pie.operator("align.2xyz", text="Align To X-0").axis = '0'
         # 9 - TOP - RIGHT
-        pie.operator("align.2z0", text="Align To Z-0")
+        pie.operator("align.2xyz", text="Align To Z-0").axis = '2'
         # 1 - BOTTOM - LEFT
         pie.separator()
         # 3 - BOTTOM - RIGHT
         # pie.menu("align.xyz")
         box = pie.split().box().column()
+
         row = box.row(align=True)
         row.label("X")
-        row.operator("alignx.left", text="Neg")
-        row.operator("alignx.right", text="Pos")
+        align_1 = row.operator("alignxyz.all", text="Neg")
+        align_1.axis = '0'
+        align_1.side = 'NEGATIVE'
+        align_2 = row.operator("alignxyz.all", text="Pos")
+        align_2.axis = '0'
+        align_2.side = 'POSITIVE'
+
         row = box.row(align=True)
         row.label("Y")
-        row.operator("aligny.front", text="Neg")
-        row.operator("aligny.back", text="Pos")
+        align_3 = row.operator("alignxyz.all", text="Neg")
+        align_3.axis = '1'
+        align_3.side = 'NEGATIVE'
+        align_4 = row.operator("alignxyz.all", text="Pos")
+        align_4.axis = '1'
+        align_4.side = 'POSITIVE'
+
         row = box.row(align=True)
         row.label("Z")
-        row.operator("alignz.bottom", text="Neg")
-        row.operator("alignz.top", text="Pos")
-
-# Align X
+        align_5 = row.operator("alignxyz.all", text="Neg")
+        align_5.axis = '2'
+        align_5.side = 'NEGATIVE'
+        align_6 = row.operator("alignxyz.all", text="Pos")
+        align_6.axis = '2'
+        align_6.side = 'POSITIVE'
 
 
+# Align X
 class AlignX(Operator):
     bl_idname = "align.x"
     bl_label = "Align  X"
@@ -89,13 +102,17 @@ class AlignX(Operator):
     def execute(self, context):
 
         for vert in bpy.context.object.data.vertices:
-            bpy.ops.transform.resize(value=(0, 1, 1), constraint_axis=(True, False, False), constraint_orientation='GLOBAL',
-                                     mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
+            bpy.ops.transform.resize(
+                    value=(0, 1, 1), constraint_axis=(True, False, False),
+                    constraint_orientation='GLOBAL',
+                    mirror=False, proportional='DISABLED',
+                    proportional_edit_falloff='SMOOTH',
+                    proportional_size=1
+                    )
         return {'FINISHED'}
 
-# Align Y
-
 
+# Align Y
 class AlignY(Operator):
     bl_idname = "align.y"
     bl_label = "Align  Y"
@@ -105,13 +122,17 @@ class AlignY(Operator):
     def execute(self, context):
 
         for vert in bpy.context.object.data.vertices:
-            bpy.ops.transform.resize(value=(1, 0, 1), constraint_axis=(False, True, False), constraint_orientation='GLOBAL',
-                                     mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
+            bpy.ops.transform.resize(
+                    value=(1, 0, 1), constraint_axis=(False, True, False),
+                    constraint_orientation='GLOBAL',
+                    mirror=False, proportional='DISABLED',
+                    proportional_edit_falloff='SMOOTH',
+                    proportional_size=1
+                    )
         return {'FINISHED'}
 
-# Align Z
-
 
+# Align Z
 class AlignZ(Operator):
     bl_idname = "align.z"
     bl_label = "Align  Z"
@@ -121,267 +142,122 @@ class AlignZ(Operator):
     def execute(self, context):
 
         for vert in bpy.cont

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list