diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 34 |
3 files changed, 49 insertions, 0 deletions
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 * \{ */ |