diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-23 11:50:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-23 11:51:11 +0300 |
commit | e92baab34893f5a5b3d6f59238fdb7855b72d7fe (patch) | |
tree | 457da9be1190b111803eb4a92e7b9384f243cfcd /source/blender/editors/interface/view2d.c | |
parent | 37b5c52f111d4fe6e024c1cd66ba965b3b6bd83d (diff) | |
parent | d886e32270edb8273ec48a41d1bdcef1fe802835 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 506 |
1 files changed, 253 insertions, 253 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 012809910bf..530a6e28860 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -4,7 +4,7 @@ * 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. + * 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 @@ -17,7 +17,7 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * + * * Contributor(s): Blender Foundation, Joshua Leung * * ***** END GPL LICENSE BLOCK ***** @@ -119,7 +119,7 @@ static int view2d_scroll_mapped(int scroll) static void view2d_masks(View2D *v2d, bool check_scrollers) { int scroll; - + /* mask - view frame */ v2d->mask.xmin = v2d->mask.ymin = 0; v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */ @@ -144,9 +144,9 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) } } } - + scroll = view2d_scroll_mapped(v2d->scroll); - + /* scrollers are based off regionsize * - they can only be on one to two edges of the region they define * - if they overlap, they must not occupy the corners (which are reserved for other widgets) @@ -170,7 +170,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */ v2d->vert.xmin = v2d->vert.xmax - scroll_width; } - + /* horizontal scroller */ if (scroll & (V2D_SCROLL_BOTTOM)) { /* on bottom edge of region */ @@ -182,7 +182,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) v2d->hor = v2d->mask; v2d->hor.ymin = v2d->hor.ymax - scroll_height; } - + /* adjust vertical scroller if there's a horizontal scroller, to leave corner free */ if (scroll & V2D_SCROLL_VERTICAL) { if (scroll & (V2D_SCROLL_BOTTOM)) { @@ -225,20 +225,20 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM); v2d->minzoom = 0.01f; v2d->maxzoom = 1000.0f; - - /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now + + /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now * - region can resize 'tot' later to fit other data * - keeptot is only within bounds, as strict locking is not that critical * - view is aligned for (0,0) -> (winx-1, winy-1) setup */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_BOUNDS; - + if (do_init) { v2d->tot.xmin = v2d->tot.ymin = 0.0f; v2d->tot.xmax = (float)(winx - 1); v2d->tot.ymax = (float)(winy - 1); - + v2d->cur = v2d->tot; } /* scrollers - should we have these by default? */ @@ -251,28 +251,28 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* zoom + aspect ratio are locked */ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); v2d->minzoom = v2d->maxzoom = 1.0f; - + /* tot rect has strictly regulated placement, and must only occur in +/- quadrant */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); v2d->keeptot = V2D_KEEPTOT_STRICT; tot_changed = do_init; - + /* scroller settings are currently not set here... that is left for regions... */ break; } - /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead. + /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead. * zoom, aspect ratio, and alignment restrictions are set here */ case V2D_COMMONVIEW_STACK: { /* zoom + aspect ratio are locked */ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); v2d->minzoom = v2d->maxzoom = 1.0f; - + /* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_STRICT; tot_changed = do_init; - + /* scroller settings are currently not set here... that is left for regions... */ break; } @@ -282,14 +282,14 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* zoom + aspect ratio are locked */ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); v2d->minzoom = v2d->maxzoom = 1.0f; - + if (do_init) { v2d->tot.xmin = 0.0f; v2d->tot.xmax = winx; v2d->tot.ymin = 0.0f; v2d->tot.ymax = winy; v2d->cur = v2d->tot; - + v2d->min[0] = v2d->max[0] = (float)(winx - 1); v2d->min[1] = v2d->max[1] = (float)(winy - 1); } @@ -297,10 +297,10 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_STRICT; tot_changed = do_init; - + /* panning in y-axis is prohibited */ v2d->keepofs = V2D_LOCKOFS_Y; - + /* absolutely no scrollers allowed */ v2d->scroll = 0; break; @@ -308,15 +308,15 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* panels view, with horizontal/vertical align */ case V2D_COMMONVIEW_PANELS_UI: { - + /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM | V2D_KEEPZOOM); v2d->minzoom = 0.5f; v2d->maxzoom = 2.0f; - + v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); v2d->keeptot = V2D_KEEPTOT_BOUNDS; - + /* note, scroll is being flipped in ED_region_panels() drawing */ v2d->scroll |= (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); @@ -327,16 +327,16 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) if (do_init) { float panelzoom = (style) ? style->panelzoom : 1.0f; - + v2d->tot.xmin = 0.0f; v2d->tot.xmax = winx; - + v2d->tot.ymax = 0.0f; v2d->tot.ymin = -winy; - + v2d->cur.xmin = 0.0f; v2d->cur.xmax = (winx) * panelzoom; - + v2d->cur.ymax = 0.0f; v2d->cur.ymin = (-winy) * panelzoom; } @@ -347,29 +347,29 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* we don't do anything here, as settings should be fine, but just make sure that rect */ break; } - + /* set initialized flag so that View2D doesn't get reinitialised next time again */ v2d->flag |= V2D_IS_INITIALISED; /* store view size */ v2d->winx = winx; v2d->winy = winy; - + /* set masks (always do), but leave scroller scheck to totrect_set */ view2d_masks(v2d, 0); - + if (do_init) { /* Visible by default. */ v2d->alpha_hor = v2d->alpha_vert = 255; } - + /* set 'tot' rect before setting cur? */ /* XXX confusing stuff here still - I made this function not check scroller hide - that happens in totrect_set */ if (tot_changed) UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init); else ui_view2d_curRect_validate_resize(v2d, !do_init, 0); - + } /** @@ -382,16 +382,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas float totwidth, totheight, curwidth, curheight, width, height; float winx, winy; rctf *cur, *tot; - + /* use mask as size of region that View2D resides in, as it takes into account * scrollbars already - keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */ winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1); winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1); - + /* get pointers to rcts for less typing */ cur = &v2d->cur; tot = &v2d->tot; - + /* we must satisfy the following constraints (in decreasing order of importance): * - alignment restrictions are respected * - cur must not fall outside of tot @@ -399,7 +399,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas * - zoom must not be excessive (check either sizes or zoom values) * - aspect ratio should be respected (NOTE: this is quite closely related to zoom too) */ - + /* Step 1: if keepzoom, adjust the sizes of the rects only * - firstly, we calculate the sizes of the rects * - curwidth and curheight are saved as reference... modify width and height values here @@ -409,14 +409,14 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */ curwidth = width = BLI_rctf_size_x(cur); curheight = height = BLI_rctf_size_y(cur); - + /* if zoom is locked, size on the appropriate axis is reset to mask size */ if (v2d->keepzoom & V2D_LOCKZOOM_X) width = winx; if (v2d->keepzoom & V2D_LOCKZOOM_Y) height = winy; - - /* values used to divide, so make it safe + + /* values used to divide, so make it safe * NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to * get enough resolution in Graph Editor for editing some curves */ @@ -424,7 +424,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas if (height < FLT_MIN) height = 1; if (winx < 1) winx = 1; if (winy < 1) winy = 1; - + /* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */ if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) { float zoom, oldzoom; @@ -445,11 +445,11 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas height *= zoom / oldzoom; } } - /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits + /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits * NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this */ else if (v2d->keepzoom & V2D_LIMITZOOM) { - + /* check if excessive zoom on x-axis */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { const float zoom = winx / width; @@ -460,7 +460,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas width = winx / v2d->maxzoom; } } - + /* check if excessive zoom on y-axis */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { const float zoom = winy / height; @@ -477,21 +477,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas CLAMP(width, v2d->min[0], v2d->max[0]); CLAMP(height, v2d->min[1], v2d->max[1]); } - + /* check if we should restore aspect ratio (if view size changed) */ if (v2d->keepzoom & V2D_KEEPASPECT) { bool do_x = false, do_y = false, do_cur /* , do_win */ /* UNUSED */; float curRatio, winRatio; - + /* when a window edge changes, the aspect ratio can't be used to - * find which is the best new 'cur' rect. thats why it stores 'old' + * find which is the best new 'cur' rect. thats why it stores 'old' */ if (winx != v2d->oldwinx) do_x = true; if (winy != v2d->oldwiny) do_y = true; - + curRatio = height / width; winRatio = winy / winx; - + /* both sizes change (area/region maximized) */ if (do_x == do_y) { if (do_x && do_y) { @@ -508,7 +508,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } do_cur = do_x; /* do_win = do_y; */ /* UNUSED */ - + if (do_cur) { if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) { /* special exception for Outliner (and later channel-lists): @@ -518,12 +518,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas */ if (winx < v2d->oldwinx) { float temp = v2d->oldwinx - winx; - + cur->xmin -= temp; cur->xmax -= temp; - - /* width does not get modified, as keepaspect here is just set to make - * sure visible area adjusts to changing view shape! + + /* width does not get modified, as keepaspect here is just set to make + * sure visible area adjusts to changing view shape! */ } } @@ -540,7 +540,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas if (winy < v2d->oldwiny) { float temp = v2d->oldwiny - winy; - + if (v2d->align & V2D_ALIGN_NO_NEG_Y) { cur->ymin -= temp; cur->ymax -= temp; @@ -557,16 +557,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas height = width * winRatio; } } - + /* store region size for next time */ v2d->oldwinx = (short)winx; v2d->oldwiny = (short)winy; } - + /* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */ if ((width != curwidth) || (height != curheight)) { float temp, dh; - + /* resize from centerpoint, unless otherwise specified */ if (width != curwidth) { if (v2d->keepofs & V2D_LOCKOFS_X) { @@ -581,7 +581,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas else { temp = BLI_rctf_cent_x(cur); dh = width * 0.5f; - + cur->xmin = temp - dh; cur->xmax = temp + dh; } @@ -599,21 +599,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas else { temp = BLI_rctf_cent_y(cur); dh = height * 0.5f; - + cur->ymin = temp - dh; cur->ymax = temp + dh; } } } - + /* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */ if (v2d->keeptot) { float temp, diff; - + /* recalculate extents of cur */ curwidth = BLI_rctf_size_x(cur); curheight = BLI_rctf_size_y(cur); - + /* width */ if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) { /* if zoom doesn't have to be maintained, just clamp edges */ @@ -621,28 +621,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas if (cur->xmax > tot->xmax) cur->xmax = tot->xmax; } else if (v2d->keeptot == V2D_KEEPTOT_STRICT) { - /* This is an exception for the outliner (and later channel-lists, headers) + /* This is an exception for the outliner (and later channel-lists, headers) * - must clamp within tot rect (absolutely no excuses) * --> therefore, cur->xmin must not be less than tot->xmin */ if (cur->xmin < tot->xmin) { /* move cur across so that it sits at minimum of tot */ temp = tot->xmin - cur->xmin; - + cur->xmin += temp; cur->xmax += temp; } else if (cur->xmax > tot->xmax) { - /* - only offset by difference of cur-xmax and tot-xmax if that would not move + /* - only offset by difference of cur-xmax and tot-xmax if that would not move * cur-xmin to lie past tot-xmin * - otherwise, simply shift to tot-xmin??? */ temp = cur->xmax - tot->xmax; - + if ((cur->xmin - temp) < tot->xmin) { /* only offset by difference from cur-min and tot-min */ temp = cur->xmin - tot->xmin; - + cur->xmin -= temp; cur->xmax -= temp; } @@ -656,7 +656,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* This here occurs when: * - width too big, but maintaining zoom (i.e. widths cannot be changed) * - width is OK, but need to check if outside of boundaries - * + * * So, resolution is to just shift view by the gap between the extremities. * We favour moving the 'minimum' across, as that's origin for most things * (XXX - in the past, max was favored... if there are bugs, swap!) @@ -665,28 +665,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ temp = BLI_rctf_cent_x(tot); diff = curwidth * 0.5f; - + cur->xmin = temp - diff; cur->xmax = temp + diff; } else if (cur->xmin < tot->xmin) { /* move cur across so that it sits at minimum of tot */ temp = tot->xmin - cur->xmin; - + cur->xmin += temp; cur->xmax += temp; } else if (cur->xmax > tot->xmax) { - /* - only offset by difference of cur-xmax and tot-xmax if that would not move + /* - only offset by difference of cur-xmax and tot-xmax if that would not move * cur-xmin to lie past tot-xmin * - otherwise, simply shift to tot-xmin??? */ temp = cur->xmax - tot->xmax; - + if ((cur->xmin - temp) < tot->xmin) { /* only offset by difference from cur-min and tot-min */ temp = cur->xmin - tot->xmin; - + cur->xmin -= temp; cur->xmax -= temp; } @@ -696,7 +696,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } } } - + /* height */ if ((curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM))) { /* if zoom doesn't have to be maintained, just clamp edges */ @@ -707,7 +707,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* This here occurs when: * - height too big, but maintaining zoom (i.e. heights cannot be changed) * - height is OK, but need to check if outside of boundaries - * + * * So, resolution is to just shift view by the gap between the extremities. * We favour moving the 'minimum' across, as that's origin for most things */ @@ -715,37 +715,37 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ temp = BLI_rctf_cent_y(tot); diff = curheight * 0.5f; - + cur->ymin = temp - diff; cur->ymax = temp + diff; } else if (cur->ymin < tot->ymin) { /* there's still space remaining, so shift up */ temp = tot->ymin - cur->ymin; - + cur->ymin += temp; cur->ymax += temp; } else if (cur->ymax > tot->ymax) { /* there's still space remaining, so shift down */ temp = cur->ymax - tot->ymax; - + cur->ymin -= temp; cur->ymax -= temp; } } } - + /* Step 4: Make sure alignment restrictions are respected */ if (v2d->align) { /* If alignment flags are set (but keeptot is not), they must still be respected, as although - * they don't specify any particular bounds to stay within, they do define ranges which are + * they don't specify any particular bounds to stay within, they do define ranges which are * invalid. * - * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these + * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these * invalid zones, otherwise we offset. */ - + /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { /* width is in negative-x half */ @@ -761,7 +761,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas v2d->cur.xmin = 0.0f; } } - + /* handle height - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { /* height is in negative-y half */ @@ -778,7 +778,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } } } - + /* set masks */ view2d_masks(v2d, mask_scrollers); } @@ -795,11 +795,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) { ScrArea *sa; ARegion *ar; - + /* don't continue if no view syncing to be done */ if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0) return; - + /* check if doing within area syncing (i.e. channels/vertical) */ if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) { for (ar = area->regionbase.first; ar; ar = ar->next) { @@ -817,14 +817,14 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) v2dcur->cur.ymin = ar->v2d.cur.ymin; v2dcur->cur.ymax = ar->v2d.cur.ymax; } - + /* region possibly changed, so refresh */ ED_region_tag_redraw_no_rebuild(ar); } } } } - + /* check if doing whole screen syncing (i.e. time/horizontal) */ if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) { for (sa = screen->areabase.first; sa; sa = sa->next) { @@ -843,7 +843,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) v2dcur->cur.xmin = ar->v2d.cur.xmin; v2dcur->cur.xmax = ar->v2d.cur.xmax; } - + /* region possibly changed, so refresh */ ED_region_tag_redraw_no_rebuild(ar); } @@ -861,11 +861,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) void UI_view2d_curRect_reset(View2D *v2d) { float width, height; - + /* assume width and height of 'cur' rect by default, should be same size as mask */ width = (float)(BLI_rcti_size_x(&v2d->mask) + 1); height = (float)(BLI_rcti_size_y(&v2d->mask) + 1); - + /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { /* width is in negative-x half */ @@ -880,11 +880,11 @@ void UI_view2d_curRect_reset(View2D *v2d) else { /* width is centered around (x == 0) */ const float dx = width / 2.0f; - + v2d->cur.xmin = -dx; v2d->cur.xmax = dx; } - + /* handle height - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { /* height is in negative-y half */ @@ -899,7 +899,7 @@ void UI_view2d_curRect_reset(View2D *v2d) else { /* height is centered around (y == 0) */ const float dy = height / 2.0f; - + v2d->cur.ymin = -dy; v2d->cur.ymax = dy; } @@ -911,11 +911,11 @@ void UI_view2d_curRect_reset(View2D *v2d) void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize) { // int scroll = view2d_scroll_mapped(v2d->scroll); - + /* don't do anything if either value is 0 */ width = abs(width); height = abs(height); - + /* hrumf! */ /* XXX: there are work arounds for this in the panel and file browse code. */ /* round to int, because this is called with width + V2D_SCROLL_WIDTH */ @@ -923,13 +923,13 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz // width -= (int)V2D_SCROLL_WIDTH; // if (scroll & V2D_SCROLL_VERTICAL) // height -= (int)V2D_SCROLL_HEIGHT; - + if (ELEM(0, width, height)) { if (G.debug & G_DEBUG) printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info return; } - + /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { /* width is in negative-x half */ @@ -944,11 +944,11 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz else { /* width is centered around (x == 0) */ const float dx = (float)width / 2.0f; - + v2d->tot.xmin = -dx; v2d->tot.xmax = dx; } - + /* handle height - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { /* height is in negative-y half */ @@ -963,14 +963,14 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz else { /* height is centered around (y == 0) */ const float dy = (float)height / 2.0f; - + v2d->tot.ymin = -dy; v2d->tot.ymax = dy; } - + /* make sure that 'cur' rect is in a valid state as a result of these changes */ ui_view2d_curRect_validate_resize(v2d, resize, 1); - + } void UI_view2d_totRect_set(View2D *v2d, int width, int height) @@ -978,12 +978,12 @@ void UI_view2d_totRect_set(View2D *v2d, int width, int height) int scroll = view2d_scroll_mapped(v2d->scroll); UI_view2d_totRect_set_resize(v2d, width, height, 0); - + /* solve bad recursion... if scroller state changed, mask is different, so you get different rects */ if (scroll != view2d_scroll_mapped(v2d->scroll)) { UI_view2d_totRect_set_resize(v2d, width, height, 0); } - + } bool UI_view2d_tab_set(View2D *v2d, int tab) @@ -1054,21 +1054,21 @@ void UI_view2d_zoom_cache_reset(void) static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) { *curmasked = v2d->cur; - + if (view2d_scroll_mapped(v2d->scroll)) { float sizex = BLI_rcti_size_x(&v2d->mask); float sizey = BLI_rcti_size_y(&v2d->mask); - + /* prevent tiny or narrow regions to get invalid coordinates - mask can get negative even... */ if (sizex > 0.0f && sizey > 0.0f) { float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1); float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); - + if (v2d->mask.xmin != 0) curmasked->xmin -= dx * (float)v2d->mask.xmin; if (v2d->mask.xmax + 1 != v2d->winx) curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1); - + if (v2d->mask.ymin != 0) curmasked->ymin -= dy * (float)v2d->mask.ymin; if (v2d->mask.ymax + 1 != v2d->winy) @@ -1085,7 +1085,7 @@ void UI_view2d_view_ortho(View2D *v2d) const int sizey = BLI_rcti_size_y(&v2d->mask); const float eps = 0.001f; float xofs = 0.0f, yofs = 0.0f; - + /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing, * but only applied where requested */ @@ -1095,12 +1095,12 @@ void UI_view2d_view_ortho(View2D *v2d) xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex; if (sizey > 0) yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey; - + /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); BLI_rctf_translate(&curmasked, -xofs, -yofs); - + /* XXX ton: this flag set by outliner, for icons */ if (v2d->flag & V2D_PIXELOFS_X) { curmasked.xmin = floorf(curmasked.xmin) - (eps + xofs); @@ -1110,7 +1110,7 @@ void UI_view2d_view_ortho(View2D *v2d) curmasked.ymin = floorf(curmasked.ymin) - (eps + yofs); curmasked.ymax = floorf(curmasked.ymax) - (eps + yofs); } - + /* set matrix on all appropriate axes */ wmOrtho2(curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax); } @@ -1124,23 +1124,23 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis) { rctf curmasked; float xofs, yofs; - + /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing, * but only applied where requested */ /* XXX temp (ton) */ xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f; yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f; - + /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); - + /* only set matrix with 'cur' coordinates on relevant axes */ if (xaxis) wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs); else wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs); -} +} /* Restore view matrices after drawing */ @@ -1149,10 +1149,10 @@ void UI_view2d_view_restore(const bContext *C) ARegion *ar = CTX_wm_region(C); int width = BLI_rcti_size_x(&ar->winrct) + 1; int height = BLI_rcti_size_y(&ar->winrct) + 1; - + wmOrtho2(0.0f, (float)width, 0.0f, (float)height); gpuLoadIdentity(); - + // ED_region_pixelspace(CTX_wm_region(C)); } @@ -1173,25 +1173,25 @@ static void step_to_grid(float *step, int *power, int unit) { const float loga = (float)log10(*step); float rem; - + *power = (int)(loga); - + rem = loga - (*power); rem = (float)pow(10.0, rem); - + if (loga < 0.0f) { if (rem < 0.2f) rem = 0.2f; else if (rem < 0.5f) rem = 0.5f; else rem = 1.0f; - + *step = rem * (float)pow(10.0, (*power)); - + /* for frames, we want 1.0 frame intervals only */ if (unit == V2D_UNIT_FRAMES) { rem = 1.0f; *step = 2.0f; /* use 2 since there are grid lines drawn in between, this way to get 1 line per frane */ } - + /* prevents printing 1.0 2.0 3.0 etc */ if (rem == 1.0f) (*power)++; } @@ -1199,9 +1199,9 @@ static void step_to_grid(float *step, int *power, int unit) if (rem < 2.0f) rem = 2.0f; else if (rem < 5.0f) rem = 5.0f; else rem = 10.0f; - + *step = rem * (float)pow(10.0, (*power)); - + (*power)++; /* prevents printing 1.0, 2.0, 3.0, etc. */ if (rem == 10.0f) (*power)++; @@ -1229,14 +1229,14 @@ View2DGrid *UI_view2d_grid_calc( View2DGrid *grid; float space, seconddiv; - + /* check that there are at least some workable args */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) return NULL; - + /* grid here is allocated... */ grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid"); - + /* rule: gridstep is minimal GRIDSTEP pixels */ if (xunits == V2D_UNIT_SECONDS) { seconddiv = (float)(0.01 * FPS); @@ -1244,7 +1244,7 @@ View2DGrid *UI_view2d_grid_calc( else { seconddiv = 1.0f; } - + /* calculate x-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { space = BLI_rctf_size_x(&v2d->cur); @@ -1257,14 +1257,14 @@ View2DGrid *UI_view2d_grid_calc( grid->dx *= seconddiv; } } - + if (xclamp == V2D_GRID_CLAMP) { CLAMP_MIN(grid->dx, 0.1f); CLAMP_MIN(grid->powerx, 0); grid->powerx -= 2; } } - + /* calculate y-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { space = BLI_rctf_size_y(&v2d->cur); @@ -1281,7 +1281,7 @@ View2DGrid *UI_view2d_grid_calc( CLAMP_MIN(grid->powery, 1); } } - + /* calculate start position */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv)); @@ -1289,14 +1289,14 @@ View2DGrid *UI_view2d_grid_calc( } else grid->startx = v2d->cur.xmin; - + if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy)); if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy; } else grid->starty = v2d->cur.ymin; - + return grid; } @@ -1308,7 +1308,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC), horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC); unsigned char grid_line_color[3]; - + /* check for grid first, as it may not exist */ if (grid == NULL) return; @@ -1351,47 +1351,47 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec1[0] = vec2[0] = grid->startx; vec1[1] = grid->starty; vec2[1] = v2d->cur.ymax; - + /* minor gridlines */ step = vertical_minor_step; if (step != 0) { UI_GetThemeColor3ubv(TH_GRID, grid_line_color); - + for (a = 0; a < step; a++) { immSkipAttrib(color); immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); immVertex2fv(pos, vec2); - + vec2[0] = vec1[0] += grid->dx; } } - + /* major gridlines */ vec2[0] = vec1[0] -= 0.5f * grid->dx; UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color); - + step++; for (a = 0; a <= step; a++) { immSkipAttrib(color); immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); immVertex2fv(pos, vec2); - + vec2[0] = vec1[0] -= grid->dx; } } - + /* horizontal lines */ if (flag & V2D_HORIZONTAL_LINES) { /* only major gridlines */ vec1[1] = vec2[1] = grid->starty; vec1[0] = grid->startx; vec2[0] = v2d->cur.xmax; - + step = horizontal_major_step; - + UI_GetThemeColor3ubv(TH_GRID, grid_line_color); for (a = 0; a <= step; a++) { @@ -1399,14 +1399,14 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); immVertex2fv(pos, vec2); - + vec2[1] = vec1[1] += grid->dy; } - + /* fine grid lines */ vec2[1] = vec1[1] -= 0.5f * grid->dy; step++; - + if (flag & V2D_HORIZONTAL_FINELINES) { UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color); for (a = 0; a < step; a++) { @@ -1414,33 +1414,33 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); immVertex2fv(pos, vec2); - + vec2[1] = vec1[1] -= grid->dy; } } } - + /* Axes are drawn as darker lines */ UI_GetThemeColorShade3ubv(TH_GRID, -50, grid_line_color); - + /* horizontal axis */ if (flag & V2D_HORIZONTAL_AXIS) { vec1[0] = v2d->cur.xmin; vec2[0] = v2d->cur.xmax; vec1[1] = vec2[1] = 0.0f; - + immSkipAttrib(color); immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); immVertex2fv(pos, vec2); } - + /* vertical axis */ if (flag & V2D_VERTICAL_AXIS) { vec1[1] = v2d->cur.ymin; vec2[1] = v2d->cur.ymax; vec1[0] = vec2[0] = 0.0f; - + immSkipAttrib(color); immVertex2fv(pos, vec1); immAttrib3ubv(color, grid_line_color); @@ -1456,7 +1456,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) { float start_x, start_y; int count_x, count_y; - + start_x = v2d->cur.xmin; if (start_x < 0.0) start_x += -(float)fmod(v2d->cur.xmin, step); @@ -1478,7 +1478,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) count_y = 0; else count_y = (v2d->cur.ymax - start_y) / step + 1; - + if (count_x > 0 || count_y > 0) { Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1486,10 +1486,10 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); - + immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4); - + immAttrib3fv(color, theme_color); for (int i = 0; i < count_x ; start_x += step, i++) { immVertex2f(pos, start_x, v2d->cur.ymin); @@ -1500,16 +1500,16 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) immVertex2f(pos, v2d->cur.xmin, start_y); immVertex2f(pos, v2d->cur.xmax, start_y); } - + /* X and Y axis */ UI_GetThemeColorShade3fv(TH_BACK, -18, theme_color); - + immAttrib3fv(color, theme_color); immVertex2f(pos, 0.0f, v2d->cur.ymin); immVertex2f(pos, 0.0f, v2d->cur.ymax); immVertex2f(pos, v2d->cur.xmin, 0.0f); immVertex2f(pos, v2d->cur.xmax, 0.0f); - + immEnd(); immUnbindProgram(); } @@ -1542,12 +1542,12 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s for (int level = 0; level < totlevels; ++level) { UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color); - + int i = (int)(v2d->cur.xmin / lstep); if (v2d->cur.xmin > 0.0f) i++; float start = i * lstep; - + for (; start < v2d->cur.xmax; start += lstep, ++i) { if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) continue; @@ -1557,12 +1557,12 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s immAttrib3ubv(color, grid_line_color); immVertex2f(pos, start, v2d->cur.ymax); } - + i = (int)(v2d->cur.ymin / lstep); if (v2d->cur.ymin > 0.0f) i++; start = i * lstep; - + for (; start < v2d->cur.ymax; start += lstep, ++i) { if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) continue; @@ -1572,7 +1572,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s immAttrib3ubv(color, grid_line_color); immVertex2f(pos, v2d->cur.xmax, start); } - + lstep *= level_size; offset -= 6; } @@ -1623,10 +1623,10 @@ struct View2DScrollers { /* focus bubbles */ int vert_min, vert_max; /* vertical scrollbar */ int hor_min, hor_max; /* horizontal scrollbar */ - + rcti hor, vert; /* exact size of slider backdrop */ int horfull, vertfull; /* set if sliders are full, we don't draw them */ - + /* scales */ View2DGrid *grid; /* grid for coordinate drawing */ short xunits, xclamp; /* units and clamping options for x-axis */ @@ -1643,16 +1643,16 @@ View2DScrollers *UI_view2d_scrollers_calc( float fac1, fac2, totsize, scrollsize; int scroll = view2d_scroll_mapped(v2d->scroll); int smaller; - + /* scrollers is allocated here... */ scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers"); - + /* Always update before drawing (for dynamically sized scrollers). */ view2d_masks(v2d, false); - + vert = v2d->vert; hor = v2d->hor; - + /* slider rects need to be smaller than region */ smaller = (int)(0.1f * U.widget_unit); hor.xmin += smaller; @@ -1661,26 +1661,26 @@ View2DScrollers *UI_view2d_scrollers_calc( hor.ymin += smaller; else hor.ymax -= smaller; - + if (scroll & V2D_SCROLL_LEFT) vert.xmin += smaller; else vert.xmax -= smaller; vert.ymin += smaller; vert.ymax -= smaller; - + CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE); CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE); - + /* store in scrollers, used for drawing */ scrollers->vert = vert; scrollers->hor = hor; - + /* scroller 'buttons': * - These should always remain within the visible region of the scrollbar * - They represent the region of 'tot' that is visible in 'cur' */ - + /* horizontal scrollers */ if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ @@ -1693,15 +1693,15 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers->hor_min = hor.xmin; else scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize)); - + fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize; if (fac2 >= 1.0f) scrollers->hor_max = hor.xmax; else scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize)); - + /* prevent inverted sliders */ - if (scrollers->hor_min > scrollers->hor_max) + if (scrollers->hor_min > scrollers->hor_max) scrollers->hor_min = scrollers->hor_max; /* prevent sliders from being too small, and disappearing */ if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) { @@ -1710,9 +1710,9 @@ View2DScrollers *UI_view2d_scrollers_calc( CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLLER_HANDLE_SIZE, hor.xmax); CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE); } - + } - + /* vertical scrollers */ if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ @@ -1725,27 +1725,27 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers->vert_min = vert.ymin; else scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize)); - + fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize; if (fac2 >= 1.0f) scrollers->vert_max = vert.ymax; else scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize)); - + /* prevent inverted sliders */ - if (scrollers->vert_min > scrollers->vert_max) + if (scrollers->vert_min > scrollers->vert_max) scrollers->vert_min = scrollers->vert_max; /* prevent sliders from being too small, and disappearing */ if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) { - + scrollers->vert_max = scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE; - + CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLLER_HANDLE_SIZE, vert.ymax); CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE); } } - + /* grid markings on scrollbars */ if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) { /* store clamping */ @@ -1753,12 +1753,12 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers->xunits = xunits; scrollers->yclamp = yclamp; scrollers->yunits = yunits; - + scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert)); } - + /* return scrollers */ return scrollers; } @@ -1768,11 +1768,11 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power { int len; char timecode_str[32]; - + /* adjust the scale unit to work ok */ if (dir == 'v') { - /* here we bump up the power by factor of 10, as - * rotation values (hence 'degrees') are divided by 10 to + /* here we bump up the power by factor of 10, as + * rotation values (hence 'degrees') are divided by 10 to * be able to show the curves at the same time */ if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) { @@ -1780,7 +1780,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power val *= 10; } } - + /* get string to print */ if (unit == V2D_UNIT_SECONDS) { /* not neces*/ @@ -1789,7 +1789,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power else { BLI_timecode_string_from_time_seconds(timecode_str, sizeof(timecode_str), power, val); } - + /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ len = strlen(timecode_str); if (dir == 'h') { @@ -1799,13 +1799,13 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power else x -= 4 * len; } - + /* Add degree sympbol to end of string for vertical scrollbar? */ if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) { timecode_str[len] = 186; timecode_str[len + 1] = 0; } - + /* draw it */ BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)); } @@ -1822,35 +1822,35 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* Color for scrollbar backs */ UI_GetThemeColor4ubv(TH_BACK, scrollers_back_color); - + /* make copies of rects for less typing */ vert = vs->vert; hor = vs->hor; - + /* horizontal scrollbar */ if (scroll & V2D_SCROLL_HORIZONTAL) { uiWidgetColors wcol = btheme->tui.wcol_scroll; const float alpha_fac = v2d->alpha_hor / 255.0f; rcti slider; int state; - + slider.xmin = vs->hor_min; slider.xmax = vs->hor_max; slider.ymin = hor.ymin; slider.ymax = hor.ymax; - + state = (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE) ? UI_SCROLL_PRESSED : 0; - + wcol.inner[3] *= alpha_fac; wcol.item[3] *= alpha_fac; wcol.outline[3] *= alpha_fac; btheme->tui.widget_emboss[3] *= alpha_fac; /* will be reset later */ - + /* show zoom handles if: * - zooming on x-axis is allowed (no scroll otherwise) * - slider bubble is large enough (no overdraw confusion) - * - scale is shown on the scroller - * (workaround to make sure that button windows don't show these, + * - scale is shown on the scroller + * (workaround to make sure that button windows don't show these, * and only the time-grids with their zoomability can do so) */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && @@ -1861,27 +1861,27 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v } UI_draw_widget_scroll(&wcol, &hor, &slider, state); - + /* scale indicators */ if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) { const int font_id = BLF_default(); View2DGrid *grid = vs->grid; float fac, dfac, fac2, val; - - /* the numbers: convert grid->startx and -dx to scroll coordinates + + /* the numbers: convert grid->startx and -dx to scroll coordinates * - fac is x-coordinate to draw to * - dfac is gap between scale markings */ fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor); - + dfac = grid->dx / BLI_rctf_size_x(&v2d->cur); dfac = dfac * BLI_rcti_size_x(&hor); - + /* set starting value, and text color */ UI_FontThemeColor(font_id, TH_TEXT); val = grid->startx; - + /* if we're clamping to whole numbers only, make sure entries won't be repeated */ if (vs->xclamp == V2D_GRID_CLAMP) { while (grid->dx < 0.9999f) { @@ -1899,25 +1899,25 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v BLF_batch_draw_begin(); for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) { - + /* make prints look nicer for scrollers */ if (fac < hor.xmin + 0.5f * U.widget_unit) continue; - + switch (vs->xunits) { case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h'); break; - + case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h'); break; - + case V2D_UNIT_SECONDS: /* seconds */ fac2 = val / (float)FPS; scroll_printstr(scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h'); break; - + case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */ /* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v'); @@ -1929,31 +1929,31 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v } } } - + /* vertical scrollbar */ if (scroll & V2D_SCROLL_VERTICAL) { uiWidgetColors wcol = btheme->tui.wcol_scroll; rcti slider; const float alpha_fac = v2d->alpha_vert / 255.0f; int state; - + slider.xmin = vert.xmin; slider.xmax = vert.xmax; slider.ymin = vs->vert_min; slider.ymax = vs->vert_max; - + state = (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE) ? UI_SCROLL_PRESSED : 0; - + wcol.inner[3] *= alpha_fac; wcol.item[3] *= alpha_fac; wcol.outline[3] *= alpha_fac; btheme->tui.widget_emboss[3] *= alpha_fac; /* will be reset later */ - + /* show zoom handles if: * - zooming on y-axis is allowed (no scroll otherwise) * - slider bubble is large enough (no overdraw confusion) - * - scale is shown on the scroller - * (workaround to make sure that button windows don't show these, + * - scale is shown on the scroller + * (workaround to make sure that button windows don't show these, * and only the time-grids with their zoomability can do so) */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && @@ -1962,16 +1962,16 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v { state |= UI_SCROLL_ARROWS; } - + UI_draw_widget_scroll(&wcol, &vert, &slider, state); - - + + /* scale indiators */ if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) { View2DGrid *grid = vs->grid; float fac, dfac, val; - - /* the numbers: convert grid->starty and dy to scroll coordinates + + /* the numbers: convert grid->starty and dy to scroll coordinates * - fac is y-coordinate to draw to * - dfac is gap between scale markings * - these involve a correction for horizontal scrollbar @@ -1979,38 +1979,38 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v */ fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); fac = vert.ymin + fac * BLI_rcti_size_y(&vert); - + dfac = grid->dy / BLI_rctf_size_y(&v2d->cur); dfac = dfac * BLI_rcti_size_y(&vert); - + /* set starting value, and text color */ const int font_id = BLF_default(); UI_FontThemeColor(font_id, TH_TEXT); val = grid->starty; - + /* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */ if (vs->yclamp == V2D_GRID_CLAMP) fac += 0.5f * dfac; - + /* draw vertical steps */ if (dfac > 0.0f) { BLF_rotation(font_id, M_PI_2); BLF_enable(font_id, BLF_ROTATION); for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) { - + /* make prints look nicer for scrollers */ if (fac < vert.ymin + 10) continue; - + scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v'); } - + BLF_disable(font_id, BLF_ROTATION); } } } - + /* Was changed above, so reset. */ btheme->tui.widget_emboss[3] = emboss_alpha; } @@ -2055,21 +2055,21 @@ void UI_view2d_listview_cell_to_view( rect->ymin = rect->ymax = 0.0f; return; } - + /* x-coordinates */ rect->xmin = startx + (float)(columnwidth * column); rect->xmax = startx + (float)(columnwidth * (column + 1)); - + if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { /* simply negate the values for the coordinates if in negative half */ rect->xmin = -rect->xmin; rect->xmax = -rect->xmax; } - + /* y-coordinates */ rect->ymin = starty + (float)(rowheight * row); rect->ymax = starty + (float)(rowheight * (row + 1)); - + if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { /* simply negate the values for the coordinates if in negative half */ rect->ymin = -rect->ymin; @@ -2095,21 +2095,21 @@ void UI_view2d_listview_view_to_cell( /* adjust view coordinates to be all positive ints, corrected for the start offset */ const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx); const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty); - + /* sizes must not be negative */ if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) { if (column) *column = 0; if (row) *row = 0; - + return; } - + /* get column */ if ((column) && (columnwidth > 0)) *column = x / columnwidth; else if (column) *column = 0; - + /* get row */ if ((row) && (rowheight > 0)) *row = y / rowheight; @@ -2131,11 +2131,11 @@ void UI_view2d_listview_visible_cells( /* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */ if (v2d) { /* min */ - UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, + UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, v2d->cur.xmin, v2d->cur.ymin, column_min, row_min); /* max*/ - UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, + UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, v2d->cur.xmax, v2d->cur.ymax, column_max, row_max); } } @@ -2196,7 +2196,7 @@ bool UI_view2d_view_to_region_clip(View2D *v2d, float x, float y, int *r_region_ /* express given coordinates as proportional values */ x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); - + /* check if values are within bounds */ if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) { *r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask))); @@ -2348,7 +2348,7 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) * * \param x, y: scale on each axis */ -void UI_view2d_scale_get(View2D *v2d, float *x, float *y) +void UI_view2d_scale_get(View2D *v2d, float *x, float *y) { if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); @@ -2423,11 +2423,11 @@ short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y) { int co[2]; int scroll = view2d_scroll_mapped(v2d->scroll); - + /* clamp x,y to region-coordinates first */ co[0] = x - ar->winrct.xmin; co[1] = y - ar->winrct.ymin; - + /* check if within scrollbars */ if (scroll & V2D_SCROLL_HORIZONTAL) { if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h'; @@ -2435,7 +2435,7 @@ short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y) if (scroll & V2D_SCROLL_VERTICAL) { if (IN_2D_VERT_SCROLL(v2d, co)) return 'v'; } - + /* not found */ return 0; } @@ -2464,7 +2464,7 @@ void UI_view2d_text_cache_add( const char *str, size_t str_len, const char col[4]) { int mval[2]; - + BLI_assert(str_len == strlen(str)); if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) { |