[Bf-blender-cvs] [3041705c518] master: Fix T65294: Orbit navigate gizmo fails in paint modes

Campbell Barton noreply at git.blender.org
Mon Jun 3 09:57:05 CEST 2019


Commit: 3041705c5188493e66ca25b597f2b15a1b32c0ca
Author: Campbell Barton
Date:   Mon Jun 3 17:52:47 2019 +1000
Branches: master
https://developer.blender.org/rB3041705c5188493e66ca25b597f2b15a1b32c0ca

Fix T65294: Orbit navigate gizmo fails in paint modes

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

M	source/blender/editors/interface/view2d_gizmo_navigate.c
M	source/blender/editors/space_view3d/view3d_gizmo_navigate.c
M	source/blender/makesrna/intern/rna_wm_gizmo.c
M	source/blender/windowmanager/gizmo/WM_gizmo_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.c b/source/blender/editors/interface/view2d_gizmo_navigate.c
index a32179834b1..1ae8dddb75b 100644
--- a/source/blender/editors/interface/view2d_gizmo_navigate.c
+++ b/source/blender/editors/interface/view2d_gizmo_navigate.c
@@ -171,6 +171,9 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *
           gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE | ED_GIZMO_BUTTON_SHOW_BACKDROP);
     }
 
+    /* Not needed, just match 3D view where it is needed. */
+    WM_gizmo_set_flag(gz, WM_GIZMO_EVENT_HANDLE_ALL, true);
+
     wmOperatorType *ot = WM_operatortype_find(info->opname, true);
     WM_gizmo_operator_set(gz, 0, ot, NULL);
   }
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index 6d8d8ba93f5..2a7120e29b1 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -183,6 +183,10 @@ static void WIDGETGROUP_navigate_setup(const bContext *C, wmGizmoGroup *gzgroup)
 
     wmOperatorType *ot = WM_operatortype_find(info->opname, true);
     WM_gizmo_operator_set(gz, 0, ot, NULL);
+
+    /* We only need this for rotation so click/drag events aren't stolen
+     * by paint mode press events, however it's strange if only rotation has this behavior. */
+    WM_gizmo_set_flag(gz, WM_GIZMO_EVENT_HANDLE_ALL, true);
   }
 
   {
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
index b13c5da7002..e942d74bdd9 100644
--- a/source/blender/makesrna/intern/rna_wm_gizmo.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -398,6 +398,7 @@ RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_
 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
                               flag,
                               WM_GIZMO_OPERATOR_TOOL_INIT);
+RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_event_handle_all, flag, WM_GIZMO_EVENT_HANDLE_ALL);
 
 /* wmGizmo.state */
 RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT);
@@ -1241,6 +1242,16 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
       "Merge active tool properties on activation (does not overwrite existing)");
   RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
 
+  /* WM_GIZMO_EVENT_HANDLE_ALL */
+  prop = RNA_def_property(srna, "use_event_handle_all", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_funcs(
+      prop, "rna_Gizmo_flag_use_event_handle_all_get", "rna_Gizmo_flag_use_event_handle_all_set");
+  RNA_def_property_ui_text(prop,
+                           "Handle All Events",
+                           "When highlighted, "
+                           "do not pass events through to be handled by other keymaps");
+  RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
   /* wmGizmo.state (readonly) */
   /* WM_GIZMO_STATE_HIGHLIGHT */
   prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
index cd8bcc6696b..7afd2908b8e 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
@@ -85,6 +85,10 @@ typedef enum eWM_GizmoFlag {
 
   /** Use the active tools operator properties when running as an operator. */
   WM_GIZMO_OPERATOR_TOOL_INIT = (1 << 9),
+
+  /** Don't pass through events to other handlers
+   * (allows click/drag not to have it's events stolen by press events in other keymaps). */
+  WM_GIZMO_EVENT_HANDLE_ALL = (1 << 10),
 } eWM_GizmoFlag;
 
 /**
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 881359677f1..55a106b50c4 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2766,6 +2766,9 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
           }
         }
 
+        /* Don't use from now on. */
+        const bool is_event_handle_all = gz && (gz->flag & WM_GIZMO_EVENT_HANDLE_ALL);
+
         if (handle_keymap) {
           /* Handle highlight gizmo. */
           if (gz != NULL) {
@@ -2797,6 +2800,12 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
           }
         }
 
+        if (is_event_handle_all) {
+          if (action == WM_HANDLER_CONTINUE) {
+            action |= WM_HANDLER_BREAK | WM_HANDLER_MODAL;
+          }
+        }
+
         /* restore the area */
         CTX_wm_area_set(C, area);
         CTX_wm_region_set(C, region);



More information about the Bf-blender-cvs mailing list