[Bf-blender-cvs] [0414b0a0be9] blender2.8: Cleanup: add function to get class from space type
Campbell Barton
noreply at git.blender.org
Sun May 13 08:15:04 CEST 2018
Commit: 0414b0a0be9f38aa87173428b895cf75b1a27c1a
Author: Campbell Barton
Date: Sun May 13 08:13:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0414b0a0be9f38aa87173428b895cf75b1a27c1a
Cleanup: add function to get class from space type
===================================================================
M 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 a68ac803d3a..dad0ad348e4 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -143,6 +143,14 @@ class ToolSelectPanelHelper:
Each tool is a 'ToolDef' or None for a separator in the toolbar, use ``None``.
"""
+ @staticmethod
+ def _tool_class_from_space_type(space_type):
+ return next(
+ (cls for cls in ToolSelectPanelHelper.__subclasses__()
+ if cls.bl_space_type == space_type),
+ None
+ )
+
@staticmethod
def _icon_value_from_icon_handle(icon_name):
import os
@@ -454,12 +462,7 @@ class ToolSelectPanelHelper:
"""
workspace = context.workspace
- space_type = workspace.tool_space_type
- cls = next(
- (cls for cls in ToolSelectPanelHelper.__subclasses__()
- if cls.bl_space_type == space_type),
- None
- )
+ cls = ToolSelectPanelHelper._tool_class_from_space_type(workspace.tool_space_type)
if cls is not None:
tool_def_active, index_active = ToolSelectPanelHelper._tool_vars_from_active_with_index(context)
@@ -495,12 +498,7 @@ class WM_MT_toolsystem_submenu(Menu):
def _tool_group_from_button(context):
context_mode = context.mode
# Lookup the tool definitions based on the space-type.
- space_type = context.space_data.type
- cls = next(
- (cls for cls in ToolSelectPanelHelper.__subclasses__()
- if cls.bl_space_type == space_type),
- None
- )
+ cls = ToolSelectPanelHelper._tool_class_from_space_type(context.space_data.type)
if cls is not None:
tool_def_button, index_button = ToolSelectPanelHelper._tool_vars_from_button_with_index(context)
for item_group in cls.tools_from_context(context):
More information about the Bf-blender-cvs
mailing list