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>2018-11-07 10:14:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-07 10:19:46 +0300
commit767a39572772a5252a993159aa4d9eb64bf936b6 (patch)
treea62f0d9c73cdeb73772a7459f11ab1052077a124
parent0bd61227c246a488bd06b76fba213c44448379c7 (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.
-rw-r--r--source/blender/editors/include/UI_view2d.h6
-rw-r--r--source/blender/editors/interface/view2d.c13
-rw-r--r--source/blender/editors/interface/view2d_ops.c7
-rw-r--r--source/blender/editors/screen/screen_ops.c12
4 files changed, 30 insertions, 8 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 92aca0a707e..8581e5d4a93 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -225,7 +225,11 @@ void UI_view2d_center_set(struct View2D *v2d, float x, float y);
void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
-short UI_view2d_mouse_in_scrollers(const struct ARegion *ar, struct View2D *v2d, int x, int y);
+char UI_view2d_mouse_in_scrollers_ex(
+ const struct ARegion *ar, struct View2D *v2d, int x, int y,
+ int *r_scroll);
+char UI_view2d_mouse_in_scrollers(
+ const struct ARegion *ar, struct View2D *v2d, int x, int y);
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y,
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) {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 5377ccb5a44..8c28d73f44b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -740,8 +740,16 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
else if (az->type == AZONE_REGION_SCROLL) {
ARegion *ar = az->ar;
View2D *v2d = &ar->v2d;
- const short isect_value = UI_view2d_mouse_in_scrollers(ar, v2d, xy[0], xy[1]);
- if (test_only) {
+ int scroll_flag = 0;
+ const int isect_value = UI_view2d_mouse_in_scrollers_ex(ar, v2d, xy[0], xy[1], &scroll_flag);
+
+ /* Check if we even have scroll bars. */
+ if (((az->direction == AZ_SCROLL_HOR) && !(scroll_flag & V2D_SCROLL_HORIZONTAL)) ||
+ ((az->direction == AZ_SCROLL_VERT) && !(scroll_flag & V2D_SCROLL_VERTICAL)))
+ {
+ /* no scrollbars, do nothing. */
+ }
+ else if (test_only) {
if (isect_value != 0) {
break;
}