diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_tooltip.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_tooltip.c | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index 30332f57d8b..fb56b2ef23f 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -38,106 +38,103 @@ static double g_tooltip_time_closed; double WM_tooltip_time_closed(void) { - return g_tooltip_time_closed; + return g_tooltip_time_closed; } -void WM_tooltip_immediate_init( - bContext *C, wmWindow *win, ARegion *ar, - wmTooltipInitFn init) +void WM_tooltip_immediate_init(bContext *C, wmWindow *win, ARegion *ar, wmTooltipInitFn init) { - WM_tooltip_timer_clear(C, win); - - bScreen *screen = WM_window_get_active_screen(win); - if (screen->tool_tip == NULL) { - screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); - } - screen->tool_tip->region_from = ar; - screen->tool_tip->init = init; - WM_tooltip_init(C, win); + WM_tooltip_timer_clear(C, win); + + bScreen *screen = WM_window_get_active_screen(win); + if (screen->tool_tip == NULL) { + screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); + } + screen->tool_tip->region_from = ar; + screen->tool_tip->init = init; + WM_tooltip_init(C, win); } void WM_tooltip_timer_init_ex( - bContext *C, wmWindow *win, ARegion *ar, - wmTooltipInitFn init, double delay) + bContext *C, wmWindow *win, ARegion *ar, wmTooltipInitFn init, double delay) { - WM_tooltip_timer_clear(C, win); - - bScreen *screen = WM_window_get_active_screen(win); - wmWindowManager *wm = CTX_wm_manager(C); - if (screen->tool_tip == NULL) { - 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, delay); - screen->tool_tip->init = init; + WM_tooltip_timer_clear(C, win); + + bScreen *screen = WM_window_get_active_screen(win); + wmWindowManager *wm = CTX_wm_manager(C); + if (screen->tool_tip == NULL) { + 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, delay); + screen->tool_tip->init = init; } -void WM_tooltip_timer_init( - bContext *C, wmWindow *win, ARegion *ar, - wmTooltipInitFn 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); + 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); - bScreen *screen = WM_window_get_active_screen(win); - if (screen->tool_tip != NULL) { - if (screen->tool_tip->timer != NULL) { - WM_event_remove_timer(wm, win, screen->tool_tip->timer); - screen->tool_tip->timer = NULL; - } - } + wmWindowManager *wm = CTX_wm_manager(C); + bScreen *screen = WM_window_get_active_screen(win); + if (screen->tool_tip != NULL) { + if (screen->tool_tip->timer != NULL) { + WM_event_remove_timer(wm, win, screen->tool_tip->timer); + screen->tool_tip->timer = NULL; + } + } } void WM_tooltip_clear(bContext *C, wmWindow *win) { - WM_tooltip_timer_clear(C, win); - bScreen *screen = WM_window_get_active_screen(win); - if (screen->tool_tip != NULL) { - if (screen->tool_tip->region) { - UI_tooltip_free(C, screen, screen->tool_tip->region); - screen->tool_tip->region = NULL; - g_tooltip_time_closed = PIL_check_seconds_timer(); - } - MEM_freeN(screen->tool_tip); - screen->tool_tip = NULL; - } + WM_tooltip_timer_clear(C, win); + bScreen *screen = WM_window_get_active_screen(win); + if (screen->tool_tip != NULL) { + if (screen->tool_tip->region) { + UI_tooltip_free(C, screen, screen->tool_tip->region); + screen->tool_tip->region = NULL; + g_tooltip_time_closed = PIL_check_seconds_timer(); + } + MEM_freeN(screen->tool_tip); + screen->tool_tip = NULL; + } } void WM_tooltip_init(bContext *C, wmWindow *win) { - WM_tooltip_timer_clear(C, win); - bScreen *screen = WM_window_get_active_screen(win); - if (screen->tool_tip->region) { - 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->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); - } + WM_tooltip_timer_clear(C, win); + bScreen *screen = WM_window_get_active_screen(win); + if (screen->tool_tip->region) { + 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->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); + } } void WM_tooltip_refresh(bContext *C, wmWindow *win) { - WM_tooltip_timer_clear(C, win); - bScreen *screen = WM_window_get_active_screen(win); - if (screen->tool_tip != NULL) { - if (screen->tool_tip->region) { - UI_tooltip_free(C, screen, screen->tool_tip->region); - screen->tool_tip->region = NULL; - } - WM_tooltip_init(C, win); - } + WM_tooltip_timer_clear(C, win); + bScreen *screen = WM_window_get_active_screen(win); + if (screen->tool_tip != NULL) { + if (screen->tool_tip->region) { + UI_tooltip_free(C, screen, screen->tool_tip->region); + screen->tool_tip->region = NULL; + } + WM_tooltip_init(C, win); + } } |