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-05-13 09:13:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-13 09:13:13 +0300
commit0414b0a0be9f38aa87173428b895cf75b1a27c1a (patch)
tree06d3c0d05be2e058f67262c3b3608a4b7b21bea5 /release
parentece36344970eadacb95394dd027024f7d481b007 (diff)
Cleanup: add function to get class from space type
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py22
1 files changed, 10 insertions, 12 deletions
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
@@ -144,6 +144,14 @@ class ToolSelectPanelHelper:
"""
@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
if icon_name is not None:
@@ -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):