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>2019-04-23 09:43:50 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-23 09:51:00 +0300
commitbe3adb51de21652d64a6839cd5614c5096064c6a (patch)
treeb76f6346673205ed3aeb33a4768bd2a182a4c605 /source/blender/editors/interface/view2d.c
parent310f288bb03b4197f54b7d7b6d611669f2604d04 (diff)
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
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 4e53e59d7c0..096ea230bbe 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -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 {