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:
Diffstat (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py50
1 files changed, 41 insertions, 9 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 4a598d0aa63..c4dabb5b5bc 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -64,7 +64,7 @@ from collections import namedtuple
ToolDef = namedtuple(
"ToolDef",
(
- # Unique tool name (withing space & mode context).
+ # Unique tool name (within space & mode context).
"idname",
# The name to display in the interface.
"label",
@@ -106,7 +106,7 @@ ToolDef = namedtuple(
# Keep this functionality since it's likely useful for add-on key-maps.
#
# Warning: currently 'from_dict' this is a list of one item,
- # so internally we can swap the key-map function for the key-map it's self.
+ # so internally we can swap the key-map function for the key-map itself.
# This isn't very nice and may change, tool definitions shouldn't care about this.
"keymap",
# Optional data-block associated with this tool.
@@ -190,7 +190,7 @@ class ToolActivePanelHelper:
ToolSelectPanelHelper.draw_active_tool_header(
context,
layout.column(),
- show_tool_icon=True,
+ show_tool_icon_always=True,
tool_key=ToolSelectPanelHelper._tool_key_from_context(context, space_type=self.bl_space_type),
)
@@ -202,13 +202,41 @@ class ToolSelectPanelHelper:
- keymap_prefix:
The text prefix for each key-map for this spaces tools.
- tools_all():
- Returns (context_mode, tools) tuple pair for all tools defined.
+ Generator (context_mode, tools) tuple pairs for all tools defined.
- tools_from_context(context, mode=None):
- Returns tools available in this context.
+ A generator for all tools available in the current context.
- Each tool is a 'ToolDef' or None for a separator in the toolbar, use ``None``.
+ Tool Sequence Structure
+ =======================
+
+ Sequences of tools as returned by tools_all() and tools_from_context() are comprised of:
+
+ - A `ToolDef` instance (representing a tool that can be activated).
+ - None (a visual separator in the tool list).
+ - A tuple of `ToolDef` or None values
+ (representing a group of tools that can be selected between using a click-drag action).
+ Note that only a single level of nesting is supported (groups cannot contain sub-groups).
+ - A callable which takes a single context argument and returns a tuple of values described above.
+ When the context is None, all potential tools must be returned.
"""
+ @classmethod
+ def tools_all(cls):
+ """
+ Return all tools for this toolbar, this must include all available tools ignoring the current context.
+ The value is must be a sequence of (mode, tool_list) pairs, where mode may be object-mode edit-mode etc.
+ The mode may be None for tool-bars that don't make use of sub-modes.
+ """
+ raise Exception("Sub-class %r must implement this method!" % cls)
+
+ @classmethod
+ def tools_from_context(cls, context, mode=None):
+ """
+ Return all tools for the current context,
+ this result is used at run-time and may filter out tools to display.
+ """
+ raise Exception("Sub-class %r must implement this method!" % cls)
+
@staticmethod
def _tool_class_from_space_type(space_type):
return next(
@@ -766,7 +794,7 @@ class ToolSelectPanelHelper:
def draw_active_tool_header(
context, layout,
*,
- show_tool_icon=False,
+ show_tool_icon_always=False,
tool_key=None,
):
if tool_key is None:
@@ -783,11 +811,15 @@ class ToolSelectPanelHelper:
return None
# Note: we could show 'item.text' here but it makes the layout jitter when switching tools.
# Add some spacing since the icon is currently assuming regular small icon size.
- if show_tool_icon:
+ if show_tool_icon_always:
layout.label(text=" " + item.label, icon_value=icon_value)
layout.separator()
else:
- layout.label(text=item.label)
+ if context.space_data.show_region_toolbar:
+ layout.template_icon(icon_value=0, scale=0.5)
+ else:
+ layout.template_icon(icon_value=icon_value, scale=0.5)
+ layout.separator()
draw_settings = item.draw_settings
if draw_settings is not None: