Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-12-11 10:05:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-12-11 10:09:39 +0300
commit7f36db35cee4a0c5c6eebd5d7baeacd3dd529983 (patch)
tree4339fcbfdc80a3da99dac35cee2ba731fe072716 /release/scripts/startup/bl_ui/space_toolsystem_common.py
parent576d385ddb581190d21febfa724086797c47492a (diff)
UI: show tool cycling shortcuts in the toolbar
Diffstat (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 01bd6dc3068..4413dee4189 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -323,6 +323,25 @@ class ToolSelectPanelHelper:
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):
"""
Return the active Python tool definition and index (if in sub-group, else -1).
@@ -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: