Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-03-12 17:19:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-03-12 17:29:06 +0300
commit5929dd7129f6e8d41a79a5e01dd8b18f5369d1a8 (patch)
treed8787b4e4ef02d48a585fa96241f069bd034da1b
parent85ea7dfc546932dcd804417231824d2e8b842b27 (diff)
Fix T73212: Gizmo's are still interactive when behind nodes
-rw-r--r--source/blender/blenkernel/BKE_screen.h2
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface_handlers.c7
-rw-r--r--source/blender/editors/interface/interface_intern.h8
-rw-r--r--source/blender/editors/interface/interface_query.c34
-rw-r--r--source/blender/editors/space_node/space_node.c1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c12
7 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index a6ed1274f19..2231cc36861 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -190,6 +190,8 @@ typedef struct ARegionType {
/* return without drawing.
* lock is set by region definition, and copied to do_lock by render. can become flag. */
short do_lock, lock;
+ /** Don't handle gizmos events behind #uiBlock's with #UI_BLOCK_CLIP_EVENTS flag set. */
+ bool clip_gizmo_events_by_ui;
/* call cursor function on each move event */
short event_cursor;
} ARegionType;
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 277f330ad50..dba95c5106e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2382,6 +2382,9 @@ struct ID *UI_context_active_but_get_tab_ID(struct bContext *C);
uiBut *UI_region_active_but_get(struct ARegion *region);
uiBut *UI_region_but_find_rect_over(const struct ARegion *region, const struct rcti *isect);
+uiBlock *UI_region_block_find_mouse_over(const struct ARegion *region,
+ const int xy[2],
+ bool only_clip);
/* uiFontStyle.align */
typedef enum eFontStyle_Align {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6da9bacd865..833631f871d 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8268,6 +8268,13 @@ uiBut *UI_region_but_find_rect_over(const ARegion *region, const rcti *rect_px)
return ui_but_find_rect_over(region, rect_px);
}
+uiBlock *UI_region_block_find_mouse_over(const struct ARegion *region,
+ const int xy[2],
+ bool only_clip)
+{
+ return ui_block_find_mouse_over_ex(region, xy[0], xy[1], only_clip);
+}
+
/**
* Version of #UI_context_active_but_get that also returns RNA property info.
* Helper function for insert keyframe, reset to default, etc operators.
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 24977848ae4..a2e239884a3 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -951,6 +951,14 @@ bool ui_block_is_popover(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+uiBlock *ui_block_find_mouse_over_ex(const struct ARegion *region,
+ const int x,
+ const int y,
+ bool only_clip);
+uiBlock *ui_block_find_mouse_over(const struct ARegion *region,
+ const struct wmEvent *event,
+ bool only_clip);
+
uiBut *ui_region_find_first_but_test_flag(struct ARegion *region,
int flag_include,
int flag_exclude);
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 03434b12ddb..52488027662 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -505,6 +505,40 @@ bool UI_block_can_add_separator(const uiBlock *block)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Block (#uiBlock) Spatial
+ * \{ */
+
+uiBlock *ui_block_find_mouse_over_ex(const ARegion *region,
+ const int x,
+ const int y,
+ bool only_clip)
+{
+ if (!ui_region_contains_point_px(region, x, y)) {
+ return NULL;
+ }
+ for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ if (only_clip) {
+ if ((block->flag & UI_BLOCK_CLIP_EVENTS) == 0) {
+ continue;
+ }
+ }
+ float mx = x, my = y;
+ ui_window_to_block_fl(region, block, &mx, &my);
+ if (BLI_rctf_isect_pt(&block->rect, mx, my)) {
+ return block;
+ }
+ }
+ return NULL;
+}
+
+uiBlock *ui_block_find_mouse_over(const ARegion *region, const wmEvent *event, bool only_clip)
+{
+ return ui_block_find_mouse_over_ex(region, event->x, event->y, only_clip);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Region (#ARegion) State
* \{ */
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index d3c7374e782..951c26b69e0 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -981,6 +981,7 @@ void ED_spacetype_node(void)
art->listener = node_region_listener;
art->cursor = node_cursor;
art->event_cursor = true;
+ art->clip_gizmo_events_by_ui = true;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index a2d254bba94..c7556ec7516 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2512,6 +2512,18 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
BLI_assert(gzmap != NULL);
wmGizmo *gz = wm_gizmomap_highlight_get(gzmap);
+ /* Needed so UI blocks over gizmos don't let events fall through to the gizmos,
+ * noticeable for the node editor - where dragging on a node should move it, see: T73212. */
+ if (region->type->clip_gizmo_events_by_ui) {
+ if (UI_region_block_find_mouse_over(region, &event->x, true)) {
+ if (gz != NULL) {
+ WM_tooltip_clear(C, CTX_wm_window(C));
+ wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
+ }
+ return action;
+ }
+ }
+
if (region->gizmo_map != handler->gizmo_map) {
WM_gizmomap_tag_refresh(handler->gizmo_map);
}