From a8ce9a143abbb51eae28e5d0cae1fb310bd0c24c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Jan 2020 12:26:36 +1100 Subject: Tool System: store the fallback tool for re-use The fallback tool was run-time only data, now it's stored in the blend file. --- .../startup/bl_ui/space_toolsystem_common.py | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 7b0a769ae62..0a42e1232d3 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -354,6 +354,16 @@ class ToolSelectPanelHelper: i += 1 return None, -1 + @classmethod + def _tool_group_active_set_by_id(cls, context, idname_group, idname): + item_group = cls._tool_get_group_by_id(context, idname_group, coerce=True) + if item_group: + for i, item in enumerate(item_group): + if item and item.idname == idname: + cls._tool_group_active[item_group[0].idname] = i + return True + return False + @staticmethod def _tool_active_from_context(context, space_type, mode=None, create=False): if space_type in {'VIEW_3D', 'PROPERTIES'}: @@ -660,10 +670,10 @@ class ToolSelectPanelHelper: *, is_horizontal_layout=False, ): - tool_fallback = tool.tool_fallback + idname_fallback = tool.idname_fallback space_type = tool.space_type cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) - item_fallback, _index = cls._tool_get_by_id(context, tool_fallback) + item_fallback, _index = cls._tool_get_by_id(context, idname_fallback) if item_fallback is not None: draw_settings = item_fallback.draw_settings if draw_settings is not None: @@ -700,11 +710,11 @@ class ToolSelectPanelHelper: draw_settings(context, layout, tool) if context.preferences.experimental.use_tool_fallback: - tool_fallback = tool.tool_fallback + idname_fallback = tool.idname_fallback else: - tool_fallback = None + idname_fallback = None - if tool_fallback and tool_fallback != item.idname: + if idname_fallback and idname_fallback != item.idname: tool_settings = context.tool_settings # Show popover which looks like an enum but isn't one. @@ -862,6 +872,7 @@ class WM_MT_toolsystem_submenu(Menu): def _activate_by_item(context, space_type, item, index, *, as_fallback=False): cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) + tool = ToolSelectPanelHelper._tool_active_from_context(context, space_type, create=True) tool_fallback_id = cls.tool_fallback_id if as_fallback: @@ -889,6 +900,12 @@ def _activate_by_item(context, space_type, item, index, *, as_fallback=False): # Done, now get the current tool to replace the item & index. tool_active = ToolSelectPanelHelper._tool_active_from_context(context, space_type) item, index = cls._tool_get_by_id(context, getattr(tool_active, "idname", None)) + else: + # Ensure the active fallback tool is read from saved state (even if the fallback tool is not in use). + stored_idname_fallback = tool.idname_fallback + if stored_idname_fallback: + cls._tool_group_active_set_by_id(context, tool_fallback_id, stored_idname_fallback) + del stored_idname_fallback # Find fallback keymap. item_fallback = None @@ -897,7 +914,6 @@ 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. - tool = ToolSelectPanelHelper._tool_active_from_context(context, space_type, create=True) tool.setup( idname=item.idname, keymap=item.keymap[0] if item.keymap is not None else "", -- cgit v1.2.3 From b423b891274af6262565e28199c5e53b0cde4374 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Jan 2020 14:04:11 +1100 Subject: Tool System: enable fallback tool by default This defaults to selection when not using a gizmo. The previous behavior to drag anywhere can be set in the tool settings or by selecting the fallback tool (Alt-W). See: T66304 --- release/scripts/startup/bl_ui/space_toolsystem_common.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 0a42e1232d3..05785b85dfc 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -709,11 +709,7 @@ class ToolSelectPanelHelper: if draw_settings is not None: draw_settings(context, layout, tool) - if context.preferences.experimental.use_tool_fallback: - idname_fallback = tool.idname_fallback - else: - idname_fallback = None - + idname_fallback = tool.idname_fallback if idname_fallback and idname_fallback != item.idname: tool_settings = context.tool_settings -- cgit v1.2.3 From 6a49161c8c60cb63d9e3ed8dbe700163ff858436 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Wed, 22 Jan 2020 14:54:44 +0100 Subject: VSE: Tool system integration Add toolbar to sequencer regions. A bit of refactoring has to be done in RNA space. Currently there is only cut tool implemented to serve as template for anybody who would like to add more. --- release/scripts/startup/bl_ui/space_toolsystem_common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 05785b85dfc..4dc724299f0 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -390,6 +390,14 @@ class ToolSelectPanelHelper: if tool is not None: tool.refresh_from_context() return tool + elif space_type == 'SEQUENCE_EDITOR': + space_data = context.space_data + if mode is None: + mode = space_data.view_type + tool = context.workspace.tools.from_space_sequencer(mode, create=create) + if tool is not None: + tool.refresh_from_context() + return tool return None @staticmethod @@ -656,6 +664,8 @@ class ToolSelectPanelHelper: return space_type, space_data.mode elif space_type == 'NODE_EDITOR': return space_type, None + elif space_type == 'SEQUENCE_EDITOR': + return space_type, context.space_data.view_type else: return None, None -- cgit v1.2.3