[Bf-blender-cvs] [9a6d8f809d0] blender2.8: Tool System: support custom cursor drawing

Campbell Barton noreply at git.blender.org
Thu Oct 25 12:06:06 CEST 2018


Commit: 9a6d8f809d0a02169dcaca24da24d29a0c47c772
Author: Campbell Barton
Date:   Thu Oct 25 21:03:41 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB9a6d8f809d0a02169dcaca24da24d29a0c47c772

Tool System: support custom cursor drawing

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

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 11601334913..7ff96952e84 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -99,6 +99,8 @@ ToolDef = namedtuple(
         "operator",
         # Optional draw settings (operator options, toolsettings).
         "draw_settings",
+        # Optional draw cursor.
+        "draw_cursor",
     )
 )
 del namedtuple
@@ -119,6 +121,7 @@ def from_dict(kw_args):
         "data_block": None,
         "operator": None,
         "draw_settings": None,
+        "draw_cursor": None,
     }
     kw.update(kw_args)
 
@@ -614,6 +617,20 @@ def _activate_by_item(context, space_type, item, index):
         index=index,
     )
 
+    WindowManager = bpy.types.WindowManager
+
+    handle_map = _activate_by_item._cursor_draw_handle
+    handle = handle_map.pop(space_type, None)
+    if (handle is not None):
+        WindowManager.draw_cursor_remove(handle)
+    if item.draw_cursor is not None:
+        def handle_fn(context, item, tool, xy):
+            item.draw_cursor(context, tool, xy)
+        handle = WindowManager.draw_cursor_add(handle_fn, (context, item, tool), space_type)
+        handle_map[space_type] = handle
+
+_activate_by_item._cursor_draw_handle = {}
+
 
 def activate_by_name(context, space_type, text):
     _cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)



More information about the Bf-blender-cvs mailing list