diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-02 06:13:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-02 06:16:53 +0300 |
commit | 3b92a9472c4cee8df98eb79e6be6b2f8b14c8b59 (patch) | |
tree | 1655af101632dfb858371345e2f4d8040c4c7f33 /source/blender/editors | |
parent | 3822a9c01aaa70d119b67f7a86a0a17d25eabc93 (diff) |
UI: update dynamic tips
Useful for progress ETA to continuously update.
This adds API option not to activate new regions GL state which isn't needed in many cases.
Diffstat (limited to 'source/blender/editors')
-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 |
5 files changed, 37 insertions, 13 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() */ |