[Bf-extensions-cvs] [1b9a94b] master: pie menus official, add individual activation system. re: T48709

meta-androcto noreply at git.blender.org
Wed Aug 3 03:31:47 CEST 2016


Commit: 1b9a94b5f9380a12123f1def08db5a4110b54c9c
Author: meta-androcto
Date:   Wed Aug 3 11:31:25 2016 +1000
Branches: master
https://developer.blender.org/rBA1b9a94b5f9380a12123f1def08db5a4110b54c9c

pie menus official, add individual activation system. re: T48709

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

A	pie_menus_official/__init__.py
R062	ui_pie_menus_official.py	pie_menus_official/pie_clip_marker_of/__init__.py
A	pie_menus_official/pie_manipulator_of/__init__.py
A	pie_menus_official/pie_object_modes_of/__init__.py
A	pie_menus_official/pie_pivot_of/__init__.py
A	pie_menus_official/pie_shade_of/__init__.py
A	pie_menus_official/pie_snap_of/__init__.py
A	pie_menus_official/pie_view_of/__init__.py
A	pie_menus_official/utils.py

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

diff --git a/pie_menus_official/__init__.py b/pie_menus_official/__init__.py
new file mode 100644
index 0000000..44e7e53
--- /dev/null
+++ b/pie_menus_official/__init__.py
@@ -0,0 +1,246 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+from bpy.props import (
+        BoolProperty,
+        PointerProperty,
+        )
+from bpy.types import (
+        PropertyGroup,
+        AddonPreferences,
+        )
+
+
+bl_info = {
+    'name': 'UI Pie Menu Official',
+    'author': 'Antony Riakiotakis, Sebastian Koenig',
+    'version': (1, 1, 2),
+    'blender': (2, 7, 7),
+    'location': 'See preferences for Activation list',
+    'description': 'Pie Menu Activate',
+    'warning': '',
+    'wiki_url': '',
+    'category': 'Pie Menu'
+    }
+
+
+sub_modules_names = (
+    "pie_object_modes_of",
+    "pie_view_of",
+    "pie_shade_of",
+    "pie_manipulator_of",
+    "pie_pivot_of",
+    "pie_snap_of",
+    "pie_clip_marker_of",
+    )
+
+
+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']))
+
+
+def _get_pref_class(mod):
+    import inspect
+
+    for obj in vars(mod).values():
+        if inspect.isclass(obj) and issubclass(obj, PropertyGroup):
+            if hasattr(obj, 'bl_idname') and obj.bl_idname == mod.__name__:
+                return obj
+
+
+def get_addon_preferences(name=''):
+    """Acquisition and registration"""
+    addons = bpy.context.user_preferences.addons
+    if __name__ not in addons:  # wm.read_factory_settings()
+        return None
+    addon_prefs = addons[__name__].preferences
+    if name:
+        if not hasattr(addon_prefs, name):
+            for mod in sub_modules:
+                if mod.__name__.split('.')[-1] == name:
+                    cls = _get_pref_class(mod)
+                    if cls:
+                        prop = PointerProperty(type=cls)
+                        setattr(UIToolsPreferences, name, prop)
+                        bpy.utils.unregister_class(UIToolsPreferences)
+                        bpy.utils.register_class(UIToolsPreferences)
+        return getattr(addon_prefs, name, None)
+    else:
+        return addon_prefs
+
+
+def register_submodule(mod):
+    if not hasattr(mod, '__addon_enabled__'):
+        mod.__addon_enabled__ = False
+    if not mod.__addon_enabled__:
+        mod.register()
+        mod.__addon_enabled__ = True
+
+
+def unregister_submodule(mod):
+    if mod.__addon_enabled__:
+        mod.unregister()
+        mod.__addon_enabled__ = False
+
+        prefs = get_addon_preferences()
+        name = mod.__name__.split('.')[-1]
+        if hasattr(UIToolsPreferences, name):
+            delattr(UIToolsPreferences, name)
+            if prefs:
+                bpy.utils.unregister_class(UIToolsPreferences)
+                bpy.utils.register_class(UIToolsPreferences)
+                if name in prefs:
+                    del prefs[name]
+
+class UIToolsPreferences(AddonPreferences):
+    bl_idname = __name__
+
+    def draw(self, context):
+        layout = self.layout
+
+        for mod in sub_modules:
+            mod_name = mod.__name__.split('.')[-1]
+            info = mod.bl_info
+            column = layout.column()
+            box = column.box()
+
+            # first stage
+            expand = getattr(self, 'show_expanded_' + mod_name)
+            icon = 'TRIA_DOWN' if expand else 'TRIA_RIGHT'
+            col = box.column()
+            row = col.row()
+            sub = row.row()
+            sub.context_pointer_set('addon_prefs', self)
+            sub.alignment = 'LEFT'
+            op = sub.operator('wm.context_toggle', text='', icon=icon,
+                              emboss=False)
+            op.data_path = 'addon_prefs.show_expanded_' + mod_name
+            sub.label('{}: {}'.format(info['category'], info['name']))
+            sub = row.row()
+            sub.alignment = 'RIGHT'
+            if info.get('warning'):
+                sub.label('', icon='ERROR')
+            sub.prop(self, 'use_' + mod_name, text='')
+
+            # The second stage
+            if expand:
+                if info.get('description'):
+                    split = col.row().split(percentage=0.15)
+                    split.label('Description:')
+                    split.label(info['description'])
+                if info.get('location'):
+                    split = col.row().split(percentage=0.15)
+                    split.label('Location:')
+                    split.label(info['location'])
+                if info.get('author') and info.get('author') != 'chromoly':
+                    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:')
+                    split.label('.'.join(str(x) for x in info['version']),
+                                translate=False)
+                if info.get('warning'):
+                    split = col.row().split(percentage=0.15)
+                    split.label('Warning:')
+                    split.label('  ' + info['warning'], icon='ERROR')
+
+                tot_row = int(bool(info.get('wiki_url')))
+                if tot_row:
+                    split = col.row().split(percentage=0.15)
+                    split.label(text='Internet:')
+                    if info.get('wiki_url'):
+                        op = split.operator('wm.url_open',
+                                            text='Documentation', icon='HELP')
+                        op.url = info.get('wiki_url')
+                    for i in range(4 - tot_row):
+                        split.separator()
+
+                # Details and settings
+                if getattr(self, 'use_' + mod_name):
+                    prefs = get_addon_preferences(mod_name)
+
+                    if prefs and hasattr(prefs, 'draw'):
+                        box = box.column()
+                        prefs.layout = box
+                        try:
+                            prefs.draw(context)
+                        except:
+                            traceback.print_exc()
+                            box.label(text='Error (see console)', icon='ERROR')
+                        del prefs.layout
+
+        row = layout.row()
+        row.label("End of Pie Menu Activations")
+
+
+for mod in sub_modules:
+    info = mod.bl_info
+    mod_name = mod.__name__.split('.')[-1]
+
+    def gen_update(mod):
+        def update(self, context):
+            if getattr(self, 'use_' + mod.__name__.split('.')[-1]):
+                if not mod.__addon_enabled__:
+                    register_submodule(mod)
+            else:
+                if mod.__addon_enabled__:
+                    unregister_submodule(mod)
+        return update
+
+    prop = BoolProperty(
+        name=info['name'],
+        description=info.get('description', ''),
+        update=gen_update(mod),
+    )
+    setattr(UIToolsPreferences, 'use_' + mod_name, prop)
+    prop = BoolProperty()
+    setattr(UIToolsPreferences, 'show_expanded_' + mod_name, prop)
+
+classes = (
+    UIToolsPreferences,
+    )
+
+
+def register():
+    for cls in classes:
+        bpy.utils.register_class(cls)
+
+    prefs = get_addon_preferences()
+    for mod in sub_modules:
+        if not hasattr(mod, '__addon_enabled__'):
+            mod.__addon_enabled__ = False
+        name = mod.__name__.split('.')[-1]
+        if getattr(prefs, 'use_' + name):
+            register_submodule(mod)
+
+
+def unregister():
+    for mod in sub_modules:
+        if mod.__addon_enabled__:
+            unregister_submodule(mod)
+
+    for cls in reversed(classes):
+        bpy.utils.unregister_class(cls)
+
+if __name__ == "__main__":
+    register()
+
+
diff --git a/ui_pie_menus_official.py b/pie_menus_official/pie_clip_marker_of/__init__.py
similarity index 62%
rename from ui_pie_menus_official.py
rename to pie_menus_official/pie_clip_marker_of/__init__.py
index 2473949..1c303f2 100644
--- a/ui_pie_menus_official.py
+++ b/pie_menus_official/pie_clip_marker_of/__init__.py
@@ -19,132 +19,22 @@
 # <pep8 compliant>
 
 bl_info = {
-    "name": "Pie Menus Official",
-    "author": "Antony Riakiotakis, Sebastian Koenig",
-    "version": (1, 0, 3),
+    "name": "Clip Editor Pies: Key: 'hotkey list Below'",
+    "description": "Clip Editor Pies",
+#    "author": "Antony Riakiotakis, Sebastian Koenig",
+    "version": (0, 1, 0),
     "blender": (2, 77, 0),
-    "description": "Enable official Pie Menus in Blender",
-    "wiki_url": "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/UI/Pie_Menus",
-    "tracker_url": "https://developer.blender.org/maniphest/task/create/?project=3&type=Bug",
-    "category": "User Interface",
-}
+    "location": "Q, W, Shift W, E. Shift S, Shift A",
+    "warning": "",
+    "wiki_url": "",
+    "category": "Pie Menu"
+    }
 
 import bpy
-from bpy.types import Menu, Operator
-from bpy.props import EnumProperty
-
-
-class VIEW3D_PIE_object_mode(Menu):
-    bl_label = "Mode"
-
-    def draw(self, context):
-        layout = self.layout
-
-        pie = layout.menu_pie()
-        pie.operator_enum("OBJECT_OT_mode_set", "mode")
-
-
-class VIEW3D_PIE_view_more(Menu):
-    bl_label = "More"
-
-    def draw(self, conte

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list