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
This commit is contained in:
committed by
Harley Acheson
parent
458c60269b
commit
0e690d3abb
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user