UI: show tool cycling shortcuts in the toolbar

This commit is contained in:
Campbell Barton
2019-12-11 18:05:02 +11:00
parent 576d385ddb
commit 7f36db35ce
2 changed files with 104 additions and 1 deletions

View File

@@ -322,6 +322,25 @@ class ToolSelectPanelHelper:
return (item, -1, None)
return None, -1, None
@classmethod
def _tool_get_group_by_id(cls, context, idname, *, coerce=False):
"""
Return the group which contains idname, or None.
"""
for item in cls.tools_from_context(context):
if item is not None:
if type(item) is tuple:
for subitem in item:
if subitem.idname == idname:
return item
else:
if item.idname == idname:
if coerce:
return (item,)
else:
return None
return None
@classmethod
def _tool_get_by_flat_index(cls, context, tool_index):
"""
@@ -1038,6 +1057,13 @@ def item_from_id_active_with_group(context, space_type, idname):
return item
def item_group_from_id(context, space_type, idname, *, coerce=False):
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
if cls is None:
return None
return cls._tool_get_group_by_id(context, idname, coerce=coerce)
def item_from_flat_index(context, space_type, index):
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
if cls is None: