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>2021-11-08 16:25:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-11-08 16:25:46 +0300
commitc55d0ebea541ff8c265306af052b0cd738d6a16a (patch)
tree077fb7bd95bfd51c8f023f080f4799627067708f /release
parentd6e22109353cf9920284f3f84dee9b8cfd125669 (diff)
parentcd8350764b881fbf75b1a0d0ee0f46cd798d17ae (diff)
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py34
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py22
2 files changed, 51 insertions, 5 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 55e124912a1..c66690030d2 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -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(
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 1a448046f7a..c07487079de 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2583,7 +2583,8 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
def tools_all(cls):
yield from cls._tools.items()
- # for reuse
+ # Private tool lists for convenient reuse in `_tools`.
+
_tools_transform = (
_defs_image_uv_transform.translate,
_defs_image_uv_transform.rotate,
@@ -2609,6 +2610,9 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
),
)
+ # Private tools dictionary, store data to implement `tools_all` & `tools_from_context`.
+ # The keys match image spaces modes: 'context.space_data.mode'.
+ # The values represent the tools, see `ToolSelectPanelHelper` for details.
_tools = {
None: [
# for all modes
@@ -2674,6 +2678,8 @@ class NODE_PT_tools_active(ToolSelectPanelHelper, Panel):
def tools_all(cls):
yield from cls._tools.items()
+ # Private tool lists for convenient reuse in `_tools`.
+
_tools_select = (
(
_defs_node_select.select,
@@ -2692,6 +2698,9 @@ class NODE_PT_tools_active(ToolSelectPanelHelper, Panel):
),
)
+ # Private tools dictionary, store data to implement `tools_all` & `tools_from_context`.
+ # The keys is always `None` since nodes don't use use modes to access different tools.
+ # The values represent the tools, see `ToolSelectPanelHelper` for details.
_tools = {
None: [
*_tools_select,
@@ -2730,7 +2739,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
def tools_all(cls):
yield from cls._tools.items()
- # for reuse
+ # Private tool lists for convenient reuse in `_tools`.
+
_tools_transform = (
_defs_transform.translate,
_defs_transform.rotate,
@@ -2786,6 +2796,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_view3d_generic.ruler,
)
+ # Private tools dictionary, store data to implement `tools_all` & `tools_from_context`.
+ # The keys match object-modes from: 'context.mode'.
+ # The values represent the tools, see `ToolSelectPanelHelper` for details.
_tools = {
None: [
# Don't use this! because of paint modes.
@@ -3095,6 +3108,8 @@ class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
def tools_all(cls):
yield from cls._tools.items()
+ # Private tool lists for convenient reuse in `_tools`.
+
_tools_select = (
(
_defs_sequencer_select.select,
@@ -3110,6 +3125,9 @@ class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
),
)
+ # Private tools dictionary, store data to implement `tools_all` & `tools_from_context`.
+ # The keys match sequence editors view type: 'context.space_data.view_type'.
+ # The values represent the tools, see `ToolSelectPanelHelper` for details.
_tools = {
None: [
],