diff options
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 14 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 20 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 31 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_subwindow.h | 4 |
7 files changed, 56 insertions, 29 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d4b723b807f..617b0d12684 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -705,6 +705,7 @@ void UI_but_func_drawextra_set( void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func); void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN); +void UI_but_tooltip_refresh(struct bContext *C, uiBut *but); void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but); bool UI_textbutton_activate_rna(const struct bContext *C, struct ARegion *ar, diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index cb2b99dbfb9..ffebd39b693 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1207,6 +1207,11 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block) for (but = block->buttons.first; but; but = but->next) { if (ui_but_update_from_old_block(C, block, &but, &but_old)) { ui_but_update(but); + + /* redraw dynamic tooltip if we have one open */ + if (but->tip_func) { + UI_but_tooltip_refresh((bContext *)C, but); + } } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 829fa6be44f..8e58ed5e98d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -7526,6 +7526,20 @@ static bool button_modal_state(uiHandleButtonState state) BUTTON_STATE_MENU_OPEN); } +/** + * Recreate tooltip (use to update dynamic tips) + */ +void UI_but_tooltip_refresh(bContext *C, uiBut *but) +{ + uiHandleButtonData *data; + + data = but->active; + if (data && data->tooltip) { + ui_tooltip_free(C, data->tooltip); + data->tooltip = ui_tooltip_create(C, data->region, but); + } +} + /* removes tooltip timer from active but (meaning tooltip is disabled until it's reenabled again) */ void UI_but_tooltip_timer_remove(bContext *C, uiBut *but) { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 0e4dd701a58..d39b70802fe 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1339,7 +1339,7 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) /* used for area initialize below */ -static void region_subwindow(wmWindow *win, ARegion *ar) +static void region_subwindow(wmWindow *win, ARegion *ar, bool activate) { bool hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) != 0; @@ -1351,10 +1351,12 @@ static void region_subwindow(wmWindow *win, ARegion *ar) wm_subwindow_close(win, ar->swinid); ar->swinid = 0; } - else if (ar->swinid == 0) - ar->swinid = wm_subwindow_open(win, &ar->winrct); - else - wm_subwindow_position(win, ar->swinid, &ar->winrct); + else if (ar->swinid == 0) { + ar->swinid = wm_subwindow_open(win, &ar->winrct, activate); + } + else { + wm_subwindow_position(win, ar->swinid, &ar->winrct, activate); + } } static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *handlers, int flag) @@ -1457,7 +1459,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) /* region windows, default and own handlers */ for (ar = sa->regionbase.first; ar; ar = ar->next) { - region_subwindow(win, ar); + region_subwindow(win, ar, false); if (ar->swinid) { /* default region handlers */ @@ -1498,10 +1500,10 @@ void ED_region_update_rect(bContext *C, ARegion *ar) void ED_region_init(bContext *C, ARegion *ar) { // ARegionType *at = ar->type; - + /* refresh can be called before window opened */ - region_subwindow(CTX_wm_window(C), ar); - + region_subwindow(CTX_wm_window(C), ar, false); + region_update_rect(ar); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a5b25645f2a..fce2ef3eb2d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1233,10 +1233,12 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) screen_test_scale(win->screen, winsize_x, winsize_y); - if (win->screen->mainwin == 0) - win->screen->mainwin = wm_subwindow_open(win, &winrct); - else - wm_subwindow_position(win, win->screen->mainwin, &winrct); + if (win->screen->mainwin == 0) { + win->screen->mainwin = wm_subwindow_open(win, &winrct, false); + } + else { + wm_subwindow_position(win, win->screen->mainwin, &winrct, false); + } for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* set spacetype and region callbacks, calls init() */ diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 7dade62347c..a0279e56ba1 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -192,7 +192,7 @@ void wm_subwindow_rect_set(wmWindow *win, int swinid, const rcti *rect) /* always sets pixel-precise 2D window/view matrices */ /* coords is in whole pixels. xmin = 15, xmax = 16: means window is 2 pix big */ -int wm_subwindow_open(wmWindow *win, const rcti *winrct) +int wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate) { wmSubWindow *swin; int width, height; @@ -208,18 +208,19 @@ int wm_subwindow_open(wmWindow *win, const rcti *winrct) swin->swinid = freewinid; swin->winrct = *winrct; - /* and we appy it all right away */ - wmSubWindowSet(win, swin->swinid); - - /* extra service */ - wm_swin_size_get(swin, &width, &height); - wmOrtho2_pixelspace(width, height); - glLoadIdentity(); + if (activate) { + /* and we appy it all right away */ + wmSubWindowSet(win, swin->swinid); + + /* extra service */ + wm_swin_size_get(swin, &width, &height); + wmOrtho2_pixelspace(width, height); + glLoadIdentity(); + } return swin->swinid; } - void wm_subwindow_close(wmWindow *win, int swinid) { wmSubWindow *swin = swin_from_swinid(win, swinid); @@ -237,7 +238,7 @@ void wm_subwindow_close(wmWindow *win, int swinid) } /* pixels go from 0-99 for a 100 pixel window */ -void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct) +void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool activate) { wmSubWindow *swin = swin_from_swinid(win, swinid); @@ -267,10 +268,12 @@ void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct) if (swin->winrct.ymax > winsize_y) swin->winrct.ymax = winsize_y; - /* extra service */ - wmSubWindowSet(win, swinid); - wm_swin_size_get(swin, &width, &height); - wmOrtho2_pixelspace(width, height); + if (activate) { + /* extra service */ + wmSubWindowSet(win, swinid); + wm_swin_size_get(swin, &width, &height); + wmOrtho2_pixelspace(width, height); + } } else { printf("%s: Internal error, bad winid: %d\n", __func__, swinid); diff --git a/source/blender/windowmanager/wm_subwindow.h b/source/blender/windowmanager/wm_subwindow.h index bf7b99433c6..2a8118a726b 100644 --- a/source/blender/windowmanager/wm_subwindow.h +++ b/source/blender/windowmanager/wm_subwindow.h @@ -36,11 +36,11 @@ /* *************** internal api ************** */ void wm_subwindows_free(wmWindow *win); -int wm_subwindow_open(wmWindow *win, const rcti *winrct); +int wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate); void wm_subwindow_close(wmWindow *win, int swinid); int wm_subwindow_get_id(wmWindow *win); /* returns id */ -void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct); +void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool activate); void wm_subwindow_size_get(wmWindow *win, int swinid, int *x, int *y); void wm_subwindow_origin_get(wmWindow *win, int swinid, int *x, int *y); |