diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-14 07:44:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-14 07:44:04 +0400 |
commit | 5df2a98984730de73fb62f5e63815c4b86acb4a2 (patch) | |
tree | 87a7473ffe1eeeb8929993f4d0e3c1278cdafae8 /source/blender | |
parent | 55d3277d0c8939ce6ab9de3a7b34bfc3eec41254 (diff) |
Fix T41425: UI wobbles using scrollbar
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index e30c6ca61ba..4c3aa8540fe 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1522,6 +1522,7 @@ typedef struct v2dScrollerMove { 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 */ + float fac_round; /* for pixel rounding (avoid visible UI jitter) */ float delta; /* amount moved by mouse on axis of interest */ float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */ @@ -1640,7 +1641,10 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e /* horizontal scroller - calculate adjustment factor first */ mask_size = (float)BLI_rcti_size_x(&v2d->hor); vsm->fac = BLI_rctf_size_x(&tot_cur_union) / mask_size; - + + /* pixel rounding */ + vsm->fac_round = (BLI_rctf_size_x(&v2d->cur)) / (float)(BLI_rcti_size_x(&ar->winrct) + 1); + /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, @@ -1659,6 +1663,9 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e mask_size = (float)BLI_rcti_size_y(&v2d->vert); vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size; + /* pixel rounding */ + vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / (float)(BLI_rcti_size_y(&ar->winrct) + 1); + /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, @@ -1706,6 +1713,9 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) /* calculate amount to move view by */ temp = vsm->fac * vsm->delta; + + /* round to pixel */ + temp = roundf(temp / vsm->fac_round) * vsm->fac_round; /* type of movement */ switch (vsm->zone) { |