Changeset View
Changeset View
Standalone View
Standalone View
space_view3d_pie_menus/__init__.py
| Show All 15 Lines | |||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| import bpy | import bpy | ||||
| from bpy.props import ( | from bpy.props import ( | ||||
| BoolProperty, | BoolProperty, | ||||
| PointerProperty, | PointerProperty, | ||||
| ) | ) | ||||
| from bpy.types import ( | from bpy.types import ( | ||||
| PropertyGroup, | PropertyGroup, | ||||
| AddonPreferences, | AddonPreferences, | ||||
| ) | ) | ||||
| bl_info = { | bl_info = { | ||||
| "name": "3D Viewport Pie Menus", | "name": "3D Viewport Pie Menus", | ||||
| "author": "meta-androcto, pitiwazou, chromoly, italic", | "author": "meta-androcto, pitiwazou, chromoly, italic", | ||||
| "version": (1, 1, 8), | "version": (1, 1, 8), | ||||
| "blender": (2, 7, 7), | "blender": (2, 80, 0), | ||||
| "description": "Individual Pie Menu Activation List", | "description": "Individual Pie Menu Activation List", | ||||
| "location": "Addons Preferences", | "location": "Addons Preferences", | ||||
| "warning": "", | "warning": "", | ||||
| "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" | "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" | ||||
| "Scripts/3D_interaction/viewport_pies", | "Scripts/3D_interaction/viewport_pies", | ||||
| "category": "Pie Menu" | "category": "Pie Menu" | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | for mod in sub_modules: | ||||
| mod.__addon_enabled__ = False | mod.__addon_enabled__ = False | ||||
| return None | return None | ||||
| class PieToolsPreferences(AddonPreferences): | class PieToolsPreferences(AddonPreferences): | ||||
| bl_idname = __name__ | bl_idname = __name__ | ||||
| enable_all = BoolProperty( | enable_all: BoolProperty( | ||||
| name="Enable all", | name="Enable all", | ||||
| description="Enable all Pie Modules", | description="Enable all Pie Modules", | ||||
| default=False, | default=False, | ||||
| update=enable_all_modules | update=enable_all_modules | ||||
| ) | ) | ||||
| disable_all = BoolProperty( | disable_all: BoolProperty( | ||||
| name="Disable all", | name="Disable all", | ||||
| description="Disable all Pie Modules", | description="Disable all Pie Modules", | ||||
| default=False, | default=False, | ||||
| update=disable_all_modules | update=disable_all_modules | ||||
| ) | ) | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| split = layout.split(percentage=0.5, align=True) | split = layout.split(factor=0.5, align=True) | ||||
| row = split.row() | row = split.row() | ||||
| row.alignment = "LEFT" | row.alignment = "LEFT" | ||||
| sub_box = row.box() | sub_box = row.box() | ||||
| sub_box.prop(self, "enable_all", emboss=False, | sub_box.prop(self, "enable_all", emboss=False, | ||||
| icon="VISIBLE_IPO_ON", icon_only=True) | icon="VISIBLE_IPO_ON", icon_only=True) | ||||
| row.label("Enable All") | row.label(text="Enable All") | ||||
| row = split.row() | row = split.row() | ||||
| row.alignment = "RIGHT" | row.alignment = "RIGHT" | ||||
| row.label("Disable All") | row.label(text="Disable All") | ||||
| sub_box = row.box() | sub_box = row.box() | ||||
| sub_box.prop(self, "disable_all", emboss=False, | sub_box.prop(self, "disable_all", emboss=False, | ||||
| icon="VISIBLE_IPO_OFF", icon_only=True) | icon="VISIBLE_IPO_OFF", icon_only=True) | ||||
| for mod in sub_modules: | for mod in sub_modules: | ||||
| mod_name = mod.__name__.split('.')[-1] | mod_name = mod.__name__.split('.')[-1] | ||||
| info = mod.bl_info | info = mod.bl_info | ||||
| column = layout.column() | column = layout.column() | ||||
| box = column.box() | box = column.box() | ||||
| # first stage | # first stage | ||||
| expand = getattr(self, 'show_expanded_' + mod_name) | expand = getattr(self, 'show_expanded_' + mod_name) | ||||
| icon = 'TRIA_DOWN' if expand else 'TRIA_RIGHT' | icon = 'TRIA_DOWN' if expand else 'TRIA_RIGHT' | ||||
| col = box.column() | col = box.column() | ||||
| row = col.row() | row = col.row() | ||||
| sub = row.row() | sub = row.row() | ||||
| sub.context_pointer_set('addon_prefs', self) | sub.context_pointer_set('addon_prefs', self) | ||||
| op = sub.operator('wm.context_toggle', text='', icon=icon, | op = sub.operator('wm.context_toggle', text='', icon=icon, | ||||
| emboss=False) | emboss=False) | ||||
| op.data_path = 'addon_prefs.show_expanded_' + mod_name | op.data_path = 'addon_prefs.show_expanded_' + mod_name | ||||
| sub.label('{}: {}'.format(info['category'], info['name'])) | sub.label(text='{}: {}'.format(info['category'], info['name'])) | ||||
| sub = row.row() | sub = row.row() | ||||
| sub.alignment = 'RIGHT' | sub.alignment = 'RIGHT' | ||||
| if info.get('warning'): | if info.get('warning'): | ||||
| sub.label('', icon='ERROR') | sub.label(text='', icon='ERROR') | ||||
| sub.prop(self, 'use_' + mod_name, text='') | sub.prop(self, 'use_' + mod_name, text='') | ||||
| # The second stage | # The second stage | ||||
| if expand: | if expand: | ||||
| if info.get('description'): | if info.get('description'): | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label('Description:') | split.label(text='Description:') | ||||
| split.label(info['description']) | split.label(text=info['description']) | ||||
| if info.get('location'): | if info.get('location'): | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label('Location:') | split.label(text='Location:') | ||||
| split.label(info['location']) | split.label(text=info['location']) | ||||
| """ | """ | ||||
| if info.get('author'): | if info.get('author'): | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label('Author:') | split.label(text='Author:') | ||||
| split.label(info['author']) | split.label(info['author']) | ||||
| """ | """ | ||||
| if info.get('version'): | if info.get('version'): | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label('Version:') | split.label(text='Version:') | ||||
| split.label('.'.join(str(x) for x in info['version']), | split.label(text='.'.join(str(x) for x in info['version']), | ||||
| translate=False) | translate=False) | ||||
| if info.get('warning'): | if info.get('warning'): | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label('Warning:') | split.label(text='Warning:') | ||||
| split.label(' ' + info['warning'], icon='ERROR') | split.label(text=' ' + info['warning'], icon='ERROR') | ||||
| tot_row = int(bool(info.get('wiki_url'))) | tot_row = int(bool(info.get('wiki_url'))) | ||||
| if tot_row: | if tot_row: | ||||
| split = col.row().split(percentage=0.15) | split = col.row().split(factor=0.15) | ||||
| split.label(text='Internet:') | split.label(text='Internet:') | ||||
| if info.get('wiki_url'): | if info.get('wiki_url'): | ||||
| op = split.operator('wm.url_open', | op = split.operator('wm.url_open', | ||||
| text='Documentation', icon='HELP') | text='Documentation', icon='HELP') | ||||
| op.url = info.get('wiki_url') | op.url = info.get('wiki_url') | ||||
| for i in range(4 - tot_row): | for i in range(4 - tot_row): | ||||
| split.separator() | split.separator() | ||||
| Show All 27 Lines | def gen_update(mod): | ||||
| if not mod.__addon_enabled__: | if not mod.__addon_enabled__: | ||||
| register_submodule(mod) | register_submodule(mod) | ||||
| else: | else: | ||||
| if mod.__addon_enabled__: | if mod.__addon_enabled__: | ||||
| unregister_submodule(mod) | unregister_submodule(mod) | ||||
| return update | return update | ||||
| prop = BoolProperty( | prop = BoolProperty( | ||||
| name=info['name'], | name=info['name'], | ||||
| description=info.get('description', ''), | description=info.get('description', ''), | ||||
| update=gen_update(mod), | update=gen_update(mod), | ||||
| ) | ) | ||||
| setattr(PieToolsPreferences, 'use_' + mod_name, prop) | setattr(PieToolsPreferences, 'use_' + mod_name, prop) | ||||
| prop = BoolProperty() | prop = BoolProperty() | ||||
| setattr(PieToolsPreferences, 'show_expanded_' + mod_name, prop) | setattr(PieToolsPreferences, 'show_expanded_' + mod_name, prop) | ||||
| classes = ( | classes = ( | ||||
| PieToolsPreferences, | PieToolsPreferences, | ||||
| ) | ) | ||||
| def register(): | def register(): | ||||
| for cls in classes: | for cls in classes: | ||||
| bpy.utils.register_class(cls) | bpy.utils.register_class(cls) | ||||
| prefs = get_addon_preferences() | prefs = get_addon_preferences() | ||||
| for mod in sub_modules: | for mod in sub_modules: | ||||
| Show All 18 Lines | |||||