diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-15 05:20:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-15 05:20:13 +0300 |
commit | d09289ff7a8e8fe6d4da6b46dd153033d7cfd426 (patch) | |
tree | 3c66fb599c3ffa9ee7449cc37b6fd190130c7bd6 /release/scripts/startup/bl_ui/space_toolsystem_common.py | |
parent | 6eacb626e043a584b0ec6cf97902ed40464ad5d3 (diff) |
Cleanup: de-duplicate active tool panel
Diffstat (limited to 'release/scripts/startup/bl_ui/space_toolsystem_common.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 71354f9875d..4e7b5ea22d8 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -147,6 +147,25 @@ ToolDef.from_fn = from_fn del from_dict, from_fn, with_args +class ToolActivePanelHelper: + # Sub-class must define. + # bl_space_type = 'VIEW_3D' + # bl_region_type = 'UI' + bl_label = "Active Tool" + # bl_category = "Tool" + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + ToolSelectPanelHelper.draw_active_tool_header( + context, + layout, + show_tool_name=True, + tool_key=ToolSelectPanelHelper._tool_key_from_context(context, space_type=self.bl_space_type), + ) + + class ToolSelectPanelHelper: """ Generic Class, can be used for any toolbar. @@ -544,12 +563,16 @@ class ToolSelectPanelHelper: self.draw_cls(self.layout, context) @staticmethod - def _tool_key_from_context(context): - space_data = context.space_data - space_type = space_data.type + def _tool_key_from_context(context, *, space_type=None): + if space_type is None: + space_data = context.space_data + space_type = space_data.type + if space_type == 'VIEW_3D': return space_type, context.mode elif space_type == 'IMAGE_EDITOR': + if space_type is None: + space_data = context.space_data return space_type, space_data.mode elif space_type == 'NODE_EDITOR': return space_type, None |