diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 10:14:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 10:19:46 +0300 |
commit | 767a39572772a5252a993159aa4d9eb64bf936b6 (patch) | |
tree | a62f0d9c73cdeb73772a7459f11ab1052077a124 /source/blender/editors/interface | |
parent | 0bd61227c246a488bd06b76fba213c44448379c7 (diff) |
Fix redraws from non-existing scrollbars
Cursor motion was often causing redraws.
Distance to scrollbars that don't exist in hidden regions
caused redraws (for alpha fading).
Check if scrollbars are used before calculating fade.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 13 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 7 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 20ca492c8d1..72f5a75904b 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2429,16 +2429,20 @@ void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac) * Check if mouse is within scrollers * * \param x, y: Mouse coordinates in screen (not region) space. + * \param r_scroll: Mapped view2d scroll flag. * * \return appropriate code for match. * - 'h' = in horizontal scroller. * - 'v' = in vertical scroller. * - 0 = not in scroller. */ -short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y) +char UI_view2d_mouse_in_scrollers_ex( + const ARegion *ar, View2D *v2d, int x, int y, + int *r_scroll) { int co[2]; int scroll = view2d_scroll_mapped(v2d->scroll); + *r_scroll = scroll; /* clamp x,y to region-coordinates first */ co[0] = x - ar->winrct.xmin; @@ -2456,6 +2460,13 @@ short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y) return 0; } +char UI_view2d_mouse_in_scrollers( + const ARegion *ar, View2D *v2d, int x, int y) +{ + int scroll_dummy = 0; + return UI_view2d_mouse_in_scrollers_ex(ar, v2d, x, y, &scroll_dummy); +} + /* ******************* view2d text drawing cache ******************** */ typedef struct View2DString { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 0ec6e3d5fd2..8df786b2a7f 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1587,7 +1587,7 @@ typedef struct v2dScrollerMove { View2D *v2d; /* View2D data that this operation affects */ ARegion *ar; /* region that the scroller is in */ - short scroller; /* scroller that mouse is in ('h' or 'v') */ + char scroller; /* scroller that mouse is in ('h' or 'v') */ short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active color?) float fac; /* view adjustment factor, based on size of region */ @@ -1694,7 +1694,7 @@ static bool scroller_activate_poll(bContext *C) } /* initialize customdata for scroller manipulation operator */ -static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, short in_scroller) +static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, const char in_scroller) { v2dScrollerMove *vsm; View2DScrollers *scrollers; @@ -1928,10 +1928,9 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent * { ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; - short in_scroller = 0; /* check if mouse in scrollbars, if they're enabled */ - in_scroller = UI_view2d_mouse_in_scrollers(ar, v2d, event->x, event->y); + const char in_scroller = UI_view2d_mouse_in_scrollers(ar, v2d, event->x, event->y); /* if in a scroller, init customdata then set modal handler which will catch mousedown to start doing useful stuff */ if (in_scroller) { |