From 0e690d3abb4bb9e8ecf18ce09d3f74bbd01f9887 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 6 Sep 2024 20:22:24 +0200 Subject: [PATCH] UI: Dialog Drag Cursors Mouse cursor changes when hovering at the top of popup blocks to indicate that these can be dragged. On Mac this looks like a hand, while for other platforms it is a drag cursor. Pull Request: https://projects.blender.org/blender/blender/pulls/118358 --- .../editors/interface/interface_handlers.cc | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 80fc36f7731..d43442c5d7b 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -10594,13 +10594,37 @@ static int ui_handle_menu_event(bContext *C, but = ui_region_find_active_but(region); #ifdef USE_DRAG_POPUP + +# if defined(__APPLE__) + constexpr int PopupTitleHoverCursor = WM_CURSOR_HAND; + constexpr int PopupTitleDragCursor = WM_CURSOR_HAND_CLOSED; +# else + constexpr int PopupTitleHoverCursor = WM_CURSOR_MOVE; + constexpr int PopupTitleDragCursor = WM_CURSOR_MOVE; +# endif + + wmWindow *win = CTX_wm_window(C); + + if (!menu->is_grab && is_floating) { + if (event->type == LEFTMOUSE && event->val == KM_PRESS && inside_title) { + /* Initial press before starting to drag. */ + WM_cursor_set(win, PopupTitleDragCursor); + } + else if (event->type == MOUSEMOVE && !win->modalcursor) { + /* Hover over draggable area. */ + WM_cursor_set(win, inside_title ? PopupTitleHoverCursor : WM_CURSOR_DEFAULT); + } + } + if (menu->is_grab) { if (event->type == LEFTMOUSE) { menu->is_grab = false; + WM_cursor_set(win, WM_CURSOR_DEFAULT); retval = WM_UI_HANDLER_BREAK; } else { if (event->type == MOUSEMOVE) { + WM_cursor_set(win, PopupTitleDragCursor); int mdiff[2]; sub_v2_v2v2_int(mdiff, event->xy, menu->grab_xy_prev); @@ -11136,7 +11160,9 @@ static int ui_handle_menu_event(bContext *C, else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) && (inside && is_floating && inside_title)) { - if (!but || !ui_but_contains_point_px(but, region, event->xy)) { + if (!but || but->type == UI_BTYPE_IMAGE || + !ui_but_contains_point_px(but, region, event->xy)) + { if (but) { UI_but_tooltip_timer_remove(C, but); }