Fix T62875: Tooltips behave erratically with view gizmos
Improvements to behavior for gizmo tool-tips. - 2D gizmos no longer cancel tool-tips on cursor motion (matching the behavior of UI widgets). - 3D gizmos still close on motion since 3D gizmos may have a large on-screen area which would cause them to stay visible even after the cursor has been moved a large distance. The motion threshold is used so they don't close on unintended cursor motion. - Changing highlighted gizmo now cancels the tool-tip & resets the timer.
This commit is contained in:
@@ -787,6 +787,8 @@ typedef struct wmTooltipState {
|
||||
bool *r_exit_on_event);
|
||||
/** Exit on any event, not needed for buttons since their highlight state is used. */
|
||||
bool exit_on_event;
|
||||
/** Cursor location at the point of tooltip creation. */
|
||||
int event_xy[2];
|
||||
/** Pass, use when we want multiple tips, count down to zero. */
|
||||
int pass;
|
||||
} wmTooltipState;
|
||||
|
||||
@@ -1144,10 +1144,15 @@ struct ARegion *WM_gizmomap_tooltip_init(struct bContext *C,
|
||||
bool *r_exit_on_event)
|
||||
{
|
||||
wmGizmoMap *gzmap = ar->gizmo_map;
|
||||
*r_exit_on_event = true;
|
||||
*r_exit_on_event = false;
|
||||
if (gzmap) {
|
||||
wmGizmo *gz = gzmap->gzmap_context.highlight;
|
||||
if (gz) {
|
||||
wmGizmoGroup *gzgroup = gz->parent_gzgroup;
|
||||
if ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0) {
|
||||
/* On screen area of 3D gizmos may be large, exit on cursor motion. */
|
||||
*r_exit_on_event = true;
|
||||
}
|
||||
return UI_tooltip_create_from_gizmo(C, gz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2784,14 +2784,28 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
|
||||
}
|
||||
|
||||
if (handle_highlight) {
|
||||
struct {
|
||||
wmGizmo *gz;
|
||||
int part;
|
||||
} prev = {
|
||||
.gz = gz,
|
||||
.part = gz ? gz->highlight_part : 0,
|
||||
};
|
||||
int part = -1;
|
||||
gz = wm_gizmomap_highlight_find(gzmap, C, event, &part);
|
||||
if (wm_gizmomap_highlight_set(gzmap, C, gz, part) && gz != NULL) {
|
||||
|
||||
if ((gz == NULL) || (prev.gz != gz) || (prev.part != part)) {
|
||||
WM_tooltip_clear(C, CTX_wm_window(C));
|
||||
}
|
||||
|
||||
if (wm_gizmomap_highlight_set(gzmap, C, gz, part)) {
|
||||
if (gz != NULL) {
|
||||
if (U.flag & USER_TOOLTIPS) {
|
||||
WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't use from now on. */
|
||||
bool is_event_handle_all = gz && (gz->flag & WM_GIZMO_EVENT_HANDLE_ALL);
|
||||
@@ -3278,10 +3292,12 @@ void wm_event_do_handlers(bContext *C)
|
||||
|
||||
/* Clear tool-tip on mouse move. */
|
||||
if (screen->tool_tip && screen->tool_tip->exit_on_event) {
|
||||
if (ISMOUSE(event->type)) {
|
||||
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
|
||||
if (len_manhattan_v2v2_int(screen->tool_tip->event_xy, &event->x) > U.move_threshold) {
|
||||
WM_tooltip_clear(C, win);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we let modal handlers get active area/region, also wm_paintcursor_test needs it */
|
||||
CTX_wm_area_set(C, area_event_inside(C, &event->x));
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@@ -116,6 +117,7 @@ void WM_tooltip_init(bContext *C, wmWindow *win)
|
||||
&screen->tool_tip->pass,
|
||||
&pass_delay,
|
||||
&screen->tool_tip->exit_on_event);
|
||||
copy_v2_v2_int(screen->tool_tip->event_xy, &win->eventstate->x);
|
||||
if (pass_prev != screen->tool_tip->pass) {
|
||||
/* The pass changed, add timer for next pass. */
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
Reference in New Issue
Block a user