[Bf-blender-cvs] [68682028998] master: Fix T62875: Tooltips behave erratically with view gizmos

Campbell Barton noreply at git.blender.org
Tue Jun 11 04:05:41 CEST 2019


Commit: 6868202899824a46ee28eb02df74efd76f6e3503
Author: Campbell Barton
Date:   Tue Jun 11 11:43:48 2019 +1000
Branches: master
https://developer.blender.org/rB6868202899824a46ee28eb02df74efd76f6e3503

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.

===================================================================

M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_tooltip.c

===================================================================

diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index c725b9f51c9..51c75430271 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -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;
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 73fae5fd46a..6915ea91c8e 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -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);
     }
   }
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 632b0131191..ea76fba46b1 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2784,11 +2784,25 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
         }
 
         if (handle_highlight) {
-          int part;
+          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 (U.flag & USER_TOOLTIPS) {
-              WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init);
+
+          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);
+              }
             }
           }
         }
@@ -3278,8 +3292,10 @@ 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)) {
-          WM_tooltip_clear(C, win);
+        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);
+          }
         }
       }
 
diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c
index fb56b2ef23f..3a219d7a573 100644
--- a/source/blender/windowmanager/intern/wm_tooltip.c
+++ b/source/blender/windowmanager/intern/wm_tooltip.c
@@ -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);



More information about the Bf-blender-cvs mailing list