UI: support tool generators (no visible change)

This allows toolbar definitions to dynamically generate tools,
needed for generating a tool list from brushes for eg.
This commit is contained in:
Campbell Barton
2018-04-29 12:26:00 +02:00
parent e017876f78
commit f4ba7667dc
2 changed files with 79 additions and 65 deletions

View File

@@ -414,7 +414,13 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
@classmethod
def tools_from_context(cls, context):
return (cls._tools[None], cls._tools.get(context.mode, ()))
for tools in (cls._tools[None], cls._tools.get(context.mode, ())):
for item in tools:
if not (type(item) is type and issubclass(item, ToolDef)) and callable(item):
yield from item(context)
else:
yield item
@classmethod
def tools_all(cls):