diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-06 07:19:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-06 07:19:15 +0300 |
commit | 26c17b0ab12d90ecbee8bc3a1188215ed3c30ddd (patch) | |
tree | c4f8aa9f61fefab9daee98fcd68ba30995eb513a /source/blender/windowmanager/intern/wm_tooltip.c | |
parent | 59572cbbc454e6439c7a1fdcb4982697d24371e2 (diff) |
UI: delay tool label tip display
Displaying the labels tip immediately feels too intrusive,
make this work more like regular tooltips, displaying more quickly.
Tooltips can now uses multiple passes, each pass with it's own delay
for the next pass to show.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_tooltip.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_tooltip.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index 58c657bf116..dcf51c1d015 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -52,9 +52,9 @@ void WM_tooltip_immediate_init( WM_tooltip_init(C, win); } -void WM_tooltip_timer_init( +void WM_tooltip_timer_init_ex( bContext *C, wmWindow *win, ARegion *ar, - wmTooltipInitFn init) + wmTooltipInitFn init, double delay) { WM_tooltip_timer_clear(C, win); @@ -64,11 +64,17 @@ void WM_tooltip_timer_init( screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); } screen->tool_tip->region_from = ar; - screen->tool_tip->timer = WM_event_add_timer( - wm, win, TIMER, UI_TOOLTIP_DELAY); + screen->tool_tip->timer = WM_event_add_timer(wm, win, TIMER, delay); screen->tool_tip->init = init; } +void WM_tooltip_timer_init( + bContext *C, wmWindow *win, ARegion *ar, + wmTooltipInitFn init) +{ + WM_tooltip_timer_init_ex(C, win, ar, init, UI_TOOLTIP_DELAY); +} + void WM_tooltip_timer_clear(bContext *C, wmWindow *win) { wmWindowManager *wm = CTX_wm_manager(C); @@ -103,8 +109,16 @@ void WM_tooltip_init(bContext *C, wmWindow *win) UI_tooltip_free(C, screen, screen->tool_tip->region); screen->tool_tip->region = NULL; } + const int pass_prev = screen->tool_tip->pass; + double pass_delay = 0.0; screen->tool_tip->region = screen->tool_tip->init( - C, screen->tool_tip->region_from, &screen->tool_tip->exit_on_event); + C, screen->tool_tip->region_from, + &screen->tool_tip->pass, &pass_delay, &screen->tool_tip->exit_on_event); + if (pass_prev != screen->tool_tip->pass) { + /* The pass changed, add timer for next pass. */ + wmWindowManager *wm = CTX_wm_manager(C); + screen->tool_tip->timer = WM_event_add_timer(wm, win, TIMER, pass_delay); + } if (screen->tool_tip->region == NULL) { WM_tooltip_clear(C, win); } |