[Bf-blender-cvs] [a0b03d3fb2d] blender2.8: Tool System: use classmethod for drawing

Campbell Barton noreply at git.blender.org
Fri May 18 21:18:52 CEST 2018


Commit: a0b03d3fb2d565a78780fea7c3c801dc50a4425d
Author: Campbell Barton
Date:   Fri May 18 21:16:57 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa0b03d3fb2d565a78780fea7c3c801dc50a4425d

Tool System: use classmethod for drawing

Allows the toolbar to be included in a popup.

===================================================================

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 d752cad8dfa..a8d1ef02003 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -430,7 +430,11 @@ class ToolSelectPanelHelper:
 
         return ui_gen, show_text
 
-    def draw(self, context):
+
+    @classmethod
+    def draw_cls(cls, layout, context):
+        # Use a classmethod so it can be called outside of a panel context.
+
         # XXX, this UI isn't very nice.
         # We might need to create new button types for this.
         # Since we probably want:
@@ -443,12 +447,12 @@ class ToolSelectPanelHelper:
             "name", None,
         )
 
-        ui_gen, show_text = self._layout_generator_detect_from_region(self.layout, context.region)
+        ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region)
 
         # Start iteration
         ui_gen.send(None)
 
-        for item in self.tools_from_context(context):
+        for item in cls.tools_from_context(context):
             if item is None:
                 ui_gen.send(True)
                 continue
@@ -467,9 +471,9 @@ class ToolSelectPanelHelper:
 
                 if is_active:
                     # not ideal, write this every time :S
-                    self._tool_group_active[item[0].text] = index
+                    cls._tool_group_active[item[0].text] = index
                 else:
-                    index = self._tool_group_active.get(item[0].text, 0)
+                    index = cls._tool_group_active.get(item[0].text, 0)
 
                 item = item[index]
                 use_menu = True
@@ -500,6 +504,9 @@ class ToolSelectPanelHelper:
         # Signal to finish any remaining layout edits.
         ui_gen.send(None)
 
+    def draw(self, context):
+        self.draw_cls(self.layout, context)
+
     @staticmethod
     def draw_active_tool_header(context, layout):
         # BAD DESIGN WARNING: last used tool



More information about the Bf-blender-cvs mailing list