diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 13:03:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 13:05:47 +0300 |
commit | 9a6d8f809d0a02169dcaca24da24d29a0c47c772 (patch) | |
tree | c79fe3b4d14df50f3e7f1123911bbd77efe55b88 /release | |
parent | f606ee7637eb26e749bc5c9f4bc914bcfba64ee6 (diff) |
Tool System: support custom cursor drawing
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 17 |
1 files changed, 17 insertions, 0 deletions
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) |