UI: ignore events in empty region overlap areas
- Resizable areas use 2D view bounds. - Header uses the button bounds. - A margin is added to avoid clicking between buttons. - Region resize edges clamp to the 2D view bounds. Resovles T61554
This commit is contained in:
@@ -403,6 +403,18 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *C,
|
||||
struct wmMsgBus *mbus);
|
||||
int ED_region_generic_tools_region_snap_size(const struct ARegion *ar, int size, int axis);
|
||||
|
||||
/* area_query.c */
|
||||
bool ED_region_overlap_isect_x(const ARegion *ar, const int event_x);
|
||||
bool ED_region_overlap_isect_y(const ARegion *ar, const int event_y);
|
||||
bool ED_region_overlap_isect_xy(const ARegion *ar, const int event_xy[2]);
|
||||
bool ED_region_overlap_isect_x_with_margin(const ARegion *ar, const int event_x, const int margin);
|
||||
bool ED_region_overlap_isect_y_with_margin(const ARegion *ar, const int event_y, const int margin);
|
||||
bool ED_region_overlap_isect_xy_with_margin(const ARegion *ar,
|
||||
const int event_xy[2],
|
||||
const int margin);
|
||||
|
||||
bool ED_region_contains_xy(const struct ARegion *ar, const int event_xy[2]);
|
||||
|
||||
/* interface_region_hud.c */
|
||||
struct ARegionType *ED_area_type_hud(int space_type);
|
||||
void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *sa_keep);
|
||||
|
||||
@@ -86,6 +86,14 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
|
||||
#define UI_MAX_NAME_STR 128
|
||||
#define UI_MAX_SHORTCUT_STR 64
|
||||
|
||||
/**
|
||||
* For #ARegion.overlap regions, pass events though if they don't overlap
|
||||
* the regions contents (the usable part of the #View2D and buttons).
|
||||
*
|
||||
* The margin is needed so it's not possible to accidentally click inbetween buttons.
|
||||
*/
|
||||
#define UI_REGION_OVERLAP_MARGIN (U.widget_unit / 3)
|
||||
|
||||
/* use for clamping popups within the screen */
|
||||
#define UI_SCREEN_MARGIN 10
|
||||
|
||||
@@ -2302,6 +2310,7 @@ void UI_context_active_but_prop_get_templateID(struct bContext *C,
|
||||
struct ID *UI_context_active_but_get_tab_ID(struct bContext *C);
|
||||
|
||||
uiBut *UI_region_active_but_get(struct ARegion *ar);
|
||||
uiBut *UI_region_but_find_rect_over(const struct ARegion *ar, const struct rcti *isect);
|
||||
|
||||
/* uiFontStyle.align */
|
||||
typedef enum eFontStyle_Align {
|
||||
|
||||
@@ -117,6 +117,9 @@ enum eView2D_Gridlines {
|
||||
#define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co))
|
||||
#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->hor, co))
|
||||
|
||||
#define IN_2D_VERT_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->vert, rct, NULL))
|
||||
#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->hor, rct, NULL))
|
||||
|
||||
/* ------------------------------------------ */
|
||||
/* Type definitions: */
|
||||
|
||||
@@ -275,6 +278,13 @@ char UI_view2d_mouse_in_scrollers(const struct ARegion *ar,
|
||||
const struct View2D *v2d,
|
||||
int x,
|
||||
int y);
|
||||
char UI_view2d_rect_in_scrollers_ex(const struct ARegion *ar,
|
||||
const struct View2D *v2d,
|
||||
const struct rcti *rect,
|
||||
int *r_scroll);
|
||||
char UI_view2d_rect_in_scrollers(const struct ARegion *ar,
|
||||
const struct View2D *v2d,
|
||||
const struct rcti *rect);
|
||||
|
||||
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
|
||||
void UI_view2d_text_cache_add(
|
||||
|
||||
@@ -7692,6 +7692,11 @@ uiBut *UI_region_active_but_get(ARegion *ar)
|
||||
return ui_context_button_active(ar, NULL);
|
||||
}
|
||||
|
||||
uiBut *UI_region_but_find_rect_over(const ARegion *ar, const rcti *rect_px)
|
||||
{
|
||||
return ui_but_find_rect_over(ar, rect_px);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of #UI_context_active_but_get that also returns RNA property info.
|
||||
* Helper function for insert keyframe, reset to default, etc operators.
|
||||
|
||||
@@ -903,6 +903,7 @@ void ui_but_pie_dir(RadialDirection dir, float vec[2]);
|
||||
bool ui_but_is_cursor_warp(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
bool ui_but_contains_pt(const uiBut *but, float mx, float my) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_but_contains_rect(const uiBut *but, const rctf *rect);
|
||||
bool ui_but_contains_point_px_icon(const uiBut *but,
|
||||
struct ARegion *ar,
|
||||
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
|
||||
@@ -918,6 +919,8 @@ uiBut *ui_but_find_mouse_over_ex(struct ARegion *ar,
|
||||
const bool labeledit) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_but_find_mouse_over(struct ARegion *ar,
|
||||
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_but_find_rect_over(const struct ARegion *ar,
|
||||
const rcti *rect_px) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
uiBut *ui_list_find_mouse_over_ex(struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
@@ -936,6 +939,7 @@ bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_region_find_first_but_test_flag(struct ARegion *ar, int flag_include, int flag_exclude);
|
||||
uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px);
|
||||
|
||||
/* interface_context_menu.c */
|
||||
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
|
||||
|
||||
@@ -201,6 +201,11 @@ bool ui_but_contains_pt(const uiBut *but, float mx, float my)
|
||||
return BLI_rctf_isect_pt(&but->rect, mx, my);
|
||||
}
|
||||
|
||||
bool ui_but_contains_rect(const uiBut *but, const rctf *rect)
|
||||
{
|
||||
return BLI_rctf_isect(&but->rect, rect, NULL);
|
||||
}
|
||||
|
||||
bool ui_but_contains_point_px(const uiBut *but, const ARegion *ar, int x, int y)
|
||||
{
|
||||
uiBlock *block = but->block;
|
||||
@@ -301,6 +306,44 @@ uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event)
|
||||
return ui_but_find_mouse_over_ex(ar, event->x, event->y, event->ctrl != 0);
|
||||
}
|
||||
|
||||
uiBut *ui_but_find_rect_over(const struct ARegion *ar, const rcti *rect_px)
|
||||
{
|
||||
if (!ui_region_contains_rect_px(ar, rect_px)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Currently no need to expose this at the moment. */
|
||||
bool labeledit = true;
|
||||
rctf rect_px_fl;
|
||||
BLI_rctf_rcti_copy(&rect_px_fl, rect_px);
|
||||
uiBut *butover = NULL;
|
||||
|
||||
for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
|
||||
rctf rect_block;
|
||||
ui_window_to_block_rctf(ar, block, &rect_block, &rect_px_fl);
|
||||
|
||||
for (uiBut *but = block->buttons.last; but; but = but->prev) {
|
||||
if (ui_but_is_interactive(but, labeledit)) {
|
||||
/* No pie menu support. */
|
||||
BLI_assert(but->pie_dir == UI_RADIAL_NONE);
|
||||
if (ui_but_contains_rect(but, &rect_block)) {
|
||||
butover = but;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* CLIP_EVENTS prevents the event from reaching other blocks */
|
||||
if (block->flag & UI_BLOCK_CLIP_EVENTS) {
|
||||
/* check if mouse is inside block */
|
||||
if (BLI_rctf_isect(&block->rect, &rect_block, NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return butover;
|
||||
}
|
||||
|
||||
uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
|
||||
{
|
||||
uiBlock *block;
|
||||
@@ -485,17 +528,13 @@ uiBut *ui_region_find_first_but_test_flag(ARegion *ar, int flag_include, int fla
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Region (#ARegion) State
|
||||
/** \name Region (#ARegion) Spatial
|
||||
* \{ */
|
||||
|
||||
bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
|
||||
{
|
||||
rcti winrct;
|
||||
|
||||
/* scale down area rect to exclude shadow */
|
||||
ui_region_winrct_get_no_margin(ar, &winrct);
|
||||
|
||||
/* check if the mouse is in the region */
|
||||
if (!BLI_rcti_isect_pt(&winrct, x, y)) {
|
||||
return false;
|
||||
}
|
||||
@@ -507,14 +546,9 @@ bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
|
||||
*/
|
||||
if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
|
||||
const View2D *v2d = &ar->v2d;
|
||||
int mx, my;
|
||||
int mx = x, my = y;
|
||||
|
||||
/* convert window coordinates to region coordinates */
|
||||
mx = x;
|
||||
my = y;
|
||||
ui_window_to_region(ar, &mx, &my);
|
||||
|
||||
/* check if in the rect */
|
||||
if (!BLI_rcti_isect_pt(&v2d->mask, mx, my) ||
|
||||
UI_view2d_mouse_in_scrollers(ar, &ar->v2d, x, y)) {
|
||||
return false;
|
||||
@@ -524,4 +558,26 @@ bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px)
|
||||
{
|
||||
rcti winrct;
|
||||
ui_region_winrct_get_no_margin(ar, &winrct);
|
||||
if (!BLI_rcti_isect(&winrct, rect_px, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* See comment in 'ui_region_contains_point_px' */
|
||||
if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
|
||||
const View2D *v2d = &ar->v2d;
|
||||
rcti rect_region;
|
||||
ui_window_to_region_rcti(ar, &rect_region, rect_px);
|
||||
if (!BLI_rcti_isect(&v2d->mask, &rect_region, NULL) ||
|
||||
UI_view2d_rect_in_scrollers(ar, &ar->v2d, rect_px)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -2626,13 +2626,14 @@ void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac)
|
||||
char UI_view2d_mouse_in_scrollers_ex(
|
||||
const ARegion *ar, const View2D *v2d, int x, int y, int *r_scroll)
|
||||
{
|
||||
int co[2];
|
||||
int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
const int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
*r_scroll = scroll;
|
||||
|
||||
/* clamp x,y to region-coordinates first */
|
||||
co[0] = x - ar->winrct.xmin;
|
||||
co[1] = y - ar->winrct.ymin;
|
||||
const int co[2] = {
|
||||
x - ar->winrct.xmin,
|
||||
y - ar->winrct.ymin,
|
||||
};
|
||||
|
||||
/* check if within scrollbars */
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
@@ -2650,12 +2651,46 @@ char UI_view2d_mouse_in_scrollers_ex(
|
||||
return 0;
|
||||
}
|
||||
|
||||
char UI_view2d_rect_in_scrollers_ex(const ARegion *ar,
|
||||
const View2D *v2d,
|
||||
const rcti *rect,
|
||||
int *r_scroll)
|
||||
{
|
||||
const int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
*r_scroll = scroll;
|
||||
|
||||
/* clamp x,y to region-coordinates first */
|
||||
rcti rect_region = *rect;
|
||||
BLI_rcti_translate(&rect_region, -ar->winrct.xmin, ar->winrct.ymin);
|
||||
|
||||
/* check if within scrollbars */
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (IN_2D_HORIZ_SCROLL_RECT(v2d, &rect_region)) {
|
||||
return 'h';
|
||||
}
|
||||
}
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (IN_2D_VERT_SCROLL_RECT(v2d, &rect_region)) {
|
||||
return 'v';
|
||||
}
|
||||
}
|
||||
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
char UI_view2d_mouse_in_scrollers(const ARegion *ar, const View2D *v2d, int x, int y)
|
||||
{
|
||||
int scroll_dummy = 0;
|
||||
return UI_view2d_mouse_in_scrollers_ex(ar, v2d, x, y, &scroll_dummy);
|
||||
}
|
||||
|
||||
char UI_view2d_rect_in_scrollers(const ARegion *ar, const View2D *v2d, const rcti *rect)
|
||||
{
|
||||
int scroll_dummy = 0;
|
||||
return UI_view2d_rect_in_scrollers_ex(ar, v2d, rect, &scroll_dummy);
|
||||
}
|
||||
|
||||
/* ******************* view2d text drawing cache ******************** */
|
||||
|
||||
typedef struct View2DString {
|
||||
|
||||
@@ -39,6 +39,7 @@ set(INC_SYS
|
||||
|
||||
set(SRC
|
||||
area.c
|
||||
area_query.c
|
||||
area_utils.c
|
||||
glutil.c
|
||||
screen_context.c
|
||||
|
||||
@@ -901,33 +901,65 @@ static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar)
|
||||
#define AZONEPAD_ICON (0.45f * U.widget_unit)
|
||||
static void region_azone_edge(AZone *az, ARegion *ar)
|
||||
{
|
||||
int clip_axis = -1;
|
||||
switch (az->edge) {
|
||||
case AE_TOP_TO_BOTTOMRIGHT:
|
||||
az->x1 = ar->winrct.xmin;
|
||||
az->y1 = ar->winrct.ymax - AZONEPAD_EDGE;
|
||||
az->x2 = ar->winrct.xmax;
|
||||
az->y2 = ar->winrct.ymax + AZONEPAD_EDGE;
|
||||
if (ar->overlap) {
|
||||
clip_axis = 0;
|
||||
}
|
||||
break;
|
||||
case AE_BOTTOM_TO_TOPLEFT:
|
||||
az->x1 = ar->winrct.xmin;
|
||||
az->y1 = ar->winrct.ymin + AZONEPAD_EDGE;
|
||||
az->x2 = ar->winrct.xmax;
|
||||
az->y2 = ar->winrct.ymin - AZONEPAD_EDGE;
|
||||
if (ar->overlap) {
|
||||
clip_axis = 0;
|
||||
}
|
||||
break;
|
||||
case AE_LEFT_TO_TOPRIGHT:
|
||||
az->x1 = ar->winrct.xmin - AZONEPAD_EDGE;
|
||||
az->y1 = ar->winrct.ymin;
|
||||
az->x2 = ar->winrct.xmin + AZONEPAD_EDGE;
|
||||
az->y2 = ar->winrct.ymax;
|
||||
if (ar->overlap) {
|
||||
clip_axis = 1;
|
||||
}
|
||||
break;
|
||||
case AE_RIGHT_TO_TOPLEFT:
|
||||
az->x1 = ar->winrct.xmax + AZONEPAD_EDGE;
|
||||
az->y1 = ar->winrct.ymin;
|
||||
az->x2 = ar->winrct.xmax - AZONEPAD_EDGE;
|
||||
az->y2 = ar->winrct.ymax;
|
||||
if (ar->overlap) {
|
||||
clip_axis = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Constrain action zones to usable area of region.
|
||||
* Needed so blank areas of the region are interactive and aciton zones don't get in the way. */
|
||||
if (clip_axis == 0) {
|
||||
az->x1 = max_ii(az->x1,
|
||||
(ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmin)) -
|
||||
UI_REGION_OVERLAP_MARGIN);
|
||||
az->x2 = min_ii(az->x2,
|
||||
(ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmax)) +
|
||||
UI_REGION_OVERLAP_MARGIN);
|
||||
}
|
||||
else if (clip_axis == 1) {
|
||||
az->y1 = max_ii(az->y1,
|
||||
(ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymin)) -
|
||||
UI_REGION_OVERLAP_MARGIN);
|
||||
az->y2 = min_ii(az->y2,
|
||||
(ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymax)) +
|
||||
UI_REGION_OVERLAP_MARGIN);
|
||||
}
|
||||
|
||||
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
||||
}
|
||||
|
||||
|
||||
123
source/blender/editors/screen/area_query.c
Normal file
123
source/blender/editors/screen/area_query.c
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup edscr
|
||||
*
|
||||
* Query functions for area/region.
|
||||
*/
|
||||
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "RNA_types.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
bool ED_region_overlap_isect_x(const ARegion *ar, const int event_x)
|
||||
{
|
||||
BLI_assert(ar->overlap);
|
||||
/* No contents, skip it. */
|
||||
if (ar->v2d.mask.xmin == ar->v2d.mask.xmax) {
|
||||
return false;
|
||||
}
|
||||
return BLI_rctf_isect_x(&ar->v2d.tot,
|
||||
UI_view2d_region_to_view_x(&ar->v2d, event_x - ar->winrct.xmin));
|
||||
}
|
||||
|
||||
bool ED_region_overlap_isect_y(const ARegion *ar, const int event_y)
|
||||
{
|
||||
BLI_assert(ar->overlap);
|
||||
/* No contents, skip it. */
|
||||
if (ar->v2d.mask.ymin == ar->v2d.mask.ymax) {
|
||||
return false;
|
||||
}
|
||||
return BLI_rctf_isect_y(&ar->v2d.tot,
|
||||
UI_view2d_region_to_view_y(&ar->v2d, event_y - ar->winrct.ymin));
|
||||
}
|
||||
|
||||
bool ED_region_overlap_isect_xy(const ARegion *ar, const int event_xy[2])
|
||||
{
|
||||
return (ED_region_overlap_isect_x(ar, event_xy[0]) &&
|
||||
ED_region_overlap_isect_y(ar, event_xy[1]));
|
||||
}
|
||||
|
||||
bool ED_region_overlap_isect_x_with_margin(const ARegion *ar, const int event_x, const int margin)
|
||||
{
|
||||
BLI_assert(ar->overlap);
|
||||
/* No contents, skip it. */
|
||||
if (ar->v2d.mask.xmin == ar->v2d.mask.xmax) {
|
||||
return false;
|
||||
}
|
||||
int region_x = event_x - ar->winrct.xmin;
|
||||
return ((ar->v2d.tot.xmin <= UI_view2d_region_to_view_x(&ar->v2d, region_x + margin)) &&
|
||||
(ar->v2d.tot.xmax >= UI_view2d_region_to_view_x(&ar->v2d, region_x - margin)));
|
||||
}
|
||||
|
||||
bool ED_region_overlap_isect_y_with_margin(const ARegion *ar, const int event_y, const int margin)
|
||||
{
|
||||
BLI_assert(ar->overlap);
|
||||
/* No contents, skip it. */
|
||||
if (ar->v2d.mask.ymin == ar->v2d.mask.ymax) {
|
||||
return false;
|
||||
}
|
||||
int region_y = event_y - ar->winrct.ymin;
|
||||
return ((ar->v2d.tot.ymin <= UI_view2d_region_to_view_y(&ar->v2d, region_y + margin)) &&
|
||||
(ar->v2d.tot.ymax >= UI_view2d_region_to_view_y(&ar->v2d, region_y - margin)));
|
||||
}
|
||||
|
||||
bool ED_region_overlap_isect_xy_with_margin(const ARegion *ar,
|
||||
const int event_xy[2],
|
||||
const int margin)
|
||||
{
|
||||
return (ED_region_overlap_isect_x_with_margin(ar, event_xy[0], margin) &&
|
||||
ED_region_overlap_isect_y_with_margin(ar, event_xy[1], margin));
|
||||
}
|
||||
|
||||
bool ED_region_contains_xy(const ARegion *ar, const int event_xy[2])
|
||||
{
|
||||
/* Only use the margin when inside the region. */
|
||||
if (BLI_rcti_isect_pt_v(&ar->winrct, event_xy)) {
|
||||
if (ar->overlap) {
|
||||
const int overlap_margin = UI_REGION_OVERLAP_MARGIN;
|
||||
/* Note the View2D.tot isn't reliable for headers with spacers otherwise
|
||||
* we'd check #ED_region_overlap_isect_xy_with_margin for both bases. */
|
||||
if (ar->v2d.keeptot == V2D_KEEPTOT_STRICT) {
|
||||
/* Header. */
|
||||
rcti rect;
|
||||
BLI_rcti_init_pt_radius(&rect, event_xy, overlap_margin);
|
||||
if (UI_region_but_find_rect_over(ar, &rect) == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Side-bar & any other kind of overlapping region. */
|
||||
if (!ED_region_overlap_isect_xy_with_margin(ar, event_xy, overlap_margin)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -683,7 +683,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
|
||||
if (sa) {
|
||||
/* make overlap active when mouse over */
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (BLI_rcti_isect_pt_v(&ar->winrct, xy)) {
|
||||
if (ED_region_contains_xy(ar, xy)) {
|
||||
scr->active_region = ar;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
@@ -2951,15 +2952,23 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
return action;
|
||||
}
|
||||
|
||||
static int wm_event_inside_i(wmEvent *event, rcti *rect)
|
||||
static bool wm_event_inside_rect(const wmEvent *event, const rcti *rect)
|
||||
{
|
||||
if (wm_event_always_pass(event)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
if (BLI_rcti_isect_pt_v(rect, &event->x)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wm_event_inside_region(const wmEvent *event, const ARegion *ar)
|
||||
{
|
||||
if (wm_event_always_pass(event)) {
|
||||
return true;
|
||||
}
|
||||
return ED_region_contains_xy(ar, &event->x);
|
||||
}
|
||||
|
||||
static ScrArea *area_event_inside(bContext *C, const int xy[2])
|
||||
@@ -3246,12 +3255,13 @@ void wm_event_do_handlers(bContext *C)
|
||||
ED_area_azones_update(sa, &event->x);
|
||||
}
|
||||
|
||||
if (wm_event_inside_i(event, &sa->totrct)) {
|
||||
if (wm_event_inside_rect(event, &sa->totrct)) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
if ((action & WM_HANDLER_BREAK) == 0) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (wm_event_inside_i(event, &ar->winrct)) {
|
||||
if (wm_event_inside_region(event, ar)) {
|
||||
|
||||
CTX_wm_region_set(C, ar);
|
||||
|
||||
/* call even on non mouse events, since the */
|
||||
|
||||
Reference in New Issue
Block a user