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>2018-08-31 07:37:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-31 07:37:10 +0300
commitb1ccb6ad25b82acf424e9c6130a6e83568a5d37e (patch)
tree12fe6321f7ad0a928963c1d99414a58f96bb7986 /release
parent39ee0f01e3b340e9c39c9d95df6acdba27694337 (diff)
Tool System: support tool description for tips
When the description isn't set, the operators is used instead.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py48
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py6
2 files changed, 53 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index b8e3d81c1d4..1be86ea7c1c 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -23,8 +23,13 @@ from bpy.types import (
)
__all__ = (
- "ToolSelectPanelHelper",
"ToolDef",
+ "ToolSelectPanelHelper",
+ "activate_by_name",
+ "activate_by_name_or_cycle",
+ "description_from_name",
+ "keymap_from_name",
+ "keymap_from_context",
)
# Support reloading icons.
@@ -70,6 +75,8 @@ ToolDef = namedtuple(
(
# The name to display in the interface.
"text",
+ # Description (for tooltip), when not set, use the description of 'operator'.
+ "description",
# The name of the icon to use (found in ``release/datafiles/icons``) or None for no icon.
"icon",
# An optional cursor to use when this tool is active.
@@ -104,6 +111,7 @@ def from_dict(kw_args):
(since keymap is a callback).
"""
kw = {
+ "description": None,
"icon": None,
"cursor": None,
"widget": None,
@@ -631,6 +639,44 @@ def activate_by_name_or_cycle(context, space_type, text, offset=1):
return True
+def description_from_name(context, space_type, text, *, use_operator=True):
+ # Used directly for tooltips.
+ cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
+ if item is None:
+ return False
+
+ # Custom description.
+ description = item.description
+ if description is not None:
+ return description
+
+ # Extract from the operator.
+ if use_operator:
+ operator = item.operator
+
+ if operator is None:
+ if item.keymap is not None:
+ operator = item.keymap[0].keymap_items[0].idname
+
+ if operator is not None:
+ import _bpy
+ return _bpy.ops.get_rna(operator).bl_rna.description
+ return ""
+
+
+def keymap_from_name(context, space_type, text):
+ # Used directly for tooltips.
+ cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
+ if item is None:
+ return False
+
+ keymap = item.keymap
+ # List container of one.
+ if keymap:
+ return keymap[0]
+ return ""
+
+
def keymap_from_context(context, space_type):
"""
Keymap for popup toolbar, currently generated each time.
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index ae8c7d82f9a..003f1fa4a7a 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -163,6 +163,9 @@ class _defs_view3d_generic:
return dict(
text="Cursor",
+ description=(
+ "Set the 3D cursor location, drag to transform"
+ ),
icon="ops.generic.cursor",
keymap=(
("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='PRESS')),
@@ -369,6 +372,9 @@ class _defs_transform:
return dict(
text="Transform",
+ description=(
+ "Supports any combination of grab, rotate & scale at once"
+ ),
icon="ops.transform.transform",
widget="TRANSFORM_GGT_gizmo",
# No keymap default action, only for gizmo!