forked from bartvdbraak/blender
use a dynamic enum for addons, annoyingly the enum was being generated from python for each of the addon buttons (~14 times per draw) which was noticeably slow, so disabling 'expand' for now.
Eventually it would be good to have the expanded buttons all using the same result from itemf().
This commit is contained in:
parent
57c3c9e70f
commit
c6705e464f
@ -85,26 +85,26 @@ def register():
|
|||||||
from bpy.props import StringProperty, EnumProperty
|
from bpy.props import StringProperty, EnumProperty
|
||||||
WindowManager = bpy.types.WindowManager
|
WindowManager = bpy.types.WindowManager
|
||||||
|
|
||||||
|
def addon_filter_items(self, context):
|
||||||
|
import addon_utils
|
||||||
|
|
||||||
|
items = [('All', "All", ""),
|
||||||
|
('Enabled', "Enabled", ""),
|
||||||
|
('Disabled', "Disabled", ""),
|
||||||
|
]
|
||||||
|
|
||||||
|
items_unique = set()
|
||||||
|
|
||||||
|
for mod in addon_utils.modules(space_userpref.USERPREF_PT_addons._addons_fake_modules):
|
||||||
|
info = addon_utils.module_bl_info(mod)
|
||||||
|
items_unique.add(info["category"])
|
||||||
|
|
||||||
|
items.extend([(cat, cat, "") for cat in sorted(items_unique)])
|
||||||
|
return items
|
||||||
|
|
||||||
WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter")
|
WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter")
|
||||||
WindowManager.addon_filter = EnumProperty(
|
WindowManager.addon_filter = EnumProperty(
|
||||||
items=[('All', "All", ""),
|
items=addon_filter_items,
|
||||||
('Enabled', "Enabled", ""),
|
|
||||||
('Disabled', "Disabled", ""),
|
|
||||||
('3D View', "3D View", ""),
|
|
||||||
('Add Curve', "Add Curve", ""),
|
|
||||||
('Add Mesh', "Add Mesh", ""),
|
|
||||||
('Animation', "Animation", ""),
|
|
||||||
('Development', "Development", ""),
|
|
||||||
('Game Engine', "Game Engine", ""),
|
|
||||||
('Import-Export', "Import-Export", ""),
|
|
||||||
('Mesh', "Mesh", ""),
|
|
||||||
('Object', "Object", ""),
|
|
||||||
('Render', "Render", ""),
|
|
||||||
('Rigging', "Rigging", ""),
|
|
||||||
('Text Editor', "Text Editor", ""),
|
|
||||||
('System', "System", ""),
|
|
||||||
('Other', "Other", ""),
|
|
||||||
],
|
|
||||||
name="Category",
|
name="Category",
|
||||||
description="Filter add-ons by category",
|
description="Filter add-ons by category",
|
||||||
)
|
)
|
||||||
|
@ -889,7 +889,8 @@ class USERPREF_PT_addons(bpy.types.Panel):
|
|||||||
split = layout.split(percentage=0.2)
|
split = layout.split(percentage=0.2)
|
||||||
col = split.column()
|
col = split.column()
|
||||||
col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
|
col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
|
||||||
col.prop(context.window_manager, "addon_filter", expand=True)
|
col.label(text="Categories")
|
||||||
|
col.prop(context.window_manager, "addon_filter", text="") # , expand=True, too slow with dynamic enum.
|
||||||
|
|
||||||
col.label(text="Supported Level")
|
col.label(text="Supported Level")
|
||||||
col.prop(context.window_manager, "addon_support", expand=True)
|
col.prop(context.window_manager, "addon_support", expand=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user