forked from bartvdbraak/blender
Toggle to standard cursor when opening menus/popups
Cursor is now set to standard arrow-cursor when opening menu, and reset to previous one when closing it. Previously it just stayed as it was before, e.g. the edit mode cross-cursor stayed active even if a menu was opened. Fixes T48192.
This commit is contained in:
parent
9b48f2b27c
commit
37493fb9fe
@ -67,6 +67,7 @@ void ED_region_panels(
|
|||||||
const bool vertical);
|
const bool vertical);
|
||||||
void ED_region_header_init(struct ARegion *ar);
|
void ED_region_header_init(struct ARegion *ar);
|
||||||
void ED_region_header(const struct bContext *C, struct ARegion *ar);
|
void ED_region_header(const struct bContext *C, struct ARegion *ar);
|
||||||
|
void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
|
||||||
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
|
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
|
||||||
void ED_region_info_draw(struct ARegion *ar, const char *text, float fill_color[4], const bool full_redraw);
|
void ED_region_info_draw(struct ARegion *ar, const char *text, float fill_color[4], const bool full_redraw);
|
||||||
void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
|
void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
|
||||||
|
@ -1788,10 +1788,20 @@ void ui_popup_block_scrolltest(uiBlock *block)
|
|||||||
|
|
||||||
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
|
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
|
||||||
{
|
{
|
||||||
ui_region_temp_remove(C, CTX_wm_screen(C), handle->region);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
|
bScreen *sc = CTX_wm_screen(C);
|
||||||
|
|
||||||
|
ui_region_temp_remove(C, sc, handle->region);
|
||||||
|
|
||||||
|
/* reset to region cursor (only if there's not another menu open) */
|
||||||
|
if (BLI_listbase_is_empty(&sc->regionbase)) {
|
||||||
|
ED_region_cursor_set(win, CTX_wm_area(C), CTX_wm_region(C));
|
||||||
|
/* in case cursor needs to be changed again */
|
||||||
|
WM_event_add_mousemove(C);
|
||||||
|
}
|
||||||
|
|
||||||
if (handle->scrolltimer)
|
if (handle->scrolltimer)
|
||||||
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), handle->scrolltimer);
|
WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1975,6 +1985,8 @@ uiPopupBlockHandle *ui_popup_block_create(
|
|||||||
if (activebut) {
|
if (activebut) {
|
||||||
UI_but_tooltip_timer_remove(C, activebut);
|
UI_but_tooltip_timer_remove(C, activebut);
|
||||||
}
|
}
|
||||||
|
/* standard cursor by default */
|
||||||
|
WM_cursor_set(window, CURSOR_STD);
|
||||||
|
|
||||||
/* create handle */
|
/* create handle */
|
||||||
handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
|
handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
|
||||||
|
@ -1507,6 +1507,16 @@ void ED_region_init(bContext *C, ARegion *ar)
|
|||||||
region_update_rect(ar);
|
region_update_rect(ar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
|
||||||
|
{
|
||||||
|
if (ar->type && ar->type->cursor) {
|
||||||
|
ar->type->cursor(win, sa, ar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WM_cursor_set(win, CURSOR_STD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* for quick toggle, can skip fades */
|
/* for quick toggle, can skip fades */
|
||||||
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
|
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
|
||||||
{
|
{
|
||||||
|
@ -1064,17 +1064,11 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc)
|
|||||||
/* screen sets cursor based on swinid */
|
/* screen sets cursor based on swinid */
|
||||||
static void region_cursor_set(wmWindow *win, int swinid, int swin_changed)
|
static void region_cursor_set(wmWindow *win, int swinid, int swin_changed)
|
||||||
{
|
{
|
||||||
ScrArea *sa = win->screen->areabase.first;
|
for (ScrArea *sa = win->screen->areabase.first; sa; sa = sa->next) {
|
||||||
|
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||||
for (; sa; sa = sa->next) {
|
|
||||||
ARegion *ar = sa->regionbase.first;
|
|
||||||
for (; ar; ar = ar->next) {
|
|
||||||
if (ar->swinid == swinid) {
|
if (ar->swinid == swinid) {
|
||||||
if (swin_changed || (ar->type && ar->type->event_cursor)) {
|
if (swin_changed || (ar->type && ar->type->event_cursor)) {
|
||||||
if (ar->type && ar->type->cursor)
|
ED_region_cursor_set(win, sa, ar);
|
||||||
ar->type->cursor(win, sa, ar);
|
|
||||||
else
|
|
||||||
WM_cursor_set(win, CURSOR_STD);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user