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.py25
1 files changed, 24 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 cde430c1e6f..28549098e51 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -75,6 +75,8 @@ ToolDef = namedtuple(
"icon",
# An optional cursor to use when this tool is active.
"cursor",
+ # The properties to use for the widget.
+ "widget_properties",
# An optional gizmo group to activate when the tool is set or None for no gizmo.
"widget",
# Optional key-map for tool, possible values are:
@@ -132,6 +134,7 @@ def from_dict(kw_args):
"icon": None,
"cursor": None,
"widget": None,
+ "widget_properties": None,
"keymap": None,
"data_block": None,
"operator": None,
@@ -983,11 +986,13 @@ def _activate_by_item(context, space_type, item, index, *, as_fallback=False):
item_fallback, _index = cls._tool_get_active_by_index(context, select_index)
# End calculating fallback.
+ gizmo_group = item.widget or ""
+
tool.setup(
idname=item.idname,
keymap=item.keymap[0] if item.keymap is not None else "",
cursor=item.cursor or 'DEFAULT',
- gizmo_group=item.widget or "",
+ gizmo_group=gizmo_group,
data_block=item.data_block or "",
operator=item.operator or "",
index=index,
@@ -995,6 +1000,24 @@ def _activate_by_item(context, space_type, item, index, *, as_fallback=False):
keymap_fallback=(item_fallback and item_fallback.keymap and item_fallback.keymap[0]) or "",
)
+ if (
+ (gizmo_group != "") and
+ (props := tool.gizmo_group_properties(gizmo_group))
+ ):
+ if props is None:
+ print("Error:", gizmo_group, "could not access properties!")
+ else:
+ for key in props.bl_rna.properties.keys():
+ props.property_unset(key)
+
+ gizmo_properties = item.widget_properties
+ if gizmo_properties is not None:
+ if not isinstance(gizmo_properties, list):
+ raise Exception("expected a list, not a %r" % type(gizmo_properties))
+
+ from bl_keymap_utils.io import _init_properties_from_data
+ _init_properties_from_data(props, gizmo_properties)
+
WindowManager = bpy.types.WindowManager
handle_map = _activate_by_item._cursor_draw_handle