diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-05-19 21:13:33 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-05-19 21:13:33 +0400 |
commit | 40ae17d2f6e2d5dbbe89321491572035c304872c (patch) | |
tree | 7f39fe42977a45878352e34d7bfdc1820ed980ff /source/blender/editors/interface/view2d.c | |
parent | 861398542f8ba71dd4783886adda21544d939763 (diff) |
UI
* Fix buttons jumping around when resizing and zoom. Part of this was
adding a tiny a 0.001f offset in UI_view2d_view_ortho, otherwise the
rounding is unpredictable (used to be 0.375f, but that was disabled).
* Fix various issues with zooming, panning panels. V2D_LOCKOFS_X/Y is
now taken into account in more places in the view2d code, to avoid
zooming into the center or panning out of the view.
* Remove "Free" align mode in buttons window (it's not really useful).
* View3D/Graph/Image editors now use the same PanelType system as the
buttons window, means some deprecated panel code could be removed.
* Some small visual tweaks for panels.
* View 2D Reset operator (Home key), to reset zoom and panning for panels.
* Added argument to set number buttons as sliders (slider=True for itemR).
* Ignore labels for button alignment (doesn't look right).
* Fix some use of context.main in py scripts, should get data from active
object instead.
* Fix autotexspace -> auto_texspace in py script.
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 79 |
1 files changed, 28 insertions, 51 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 191f38ad7d0..f2fc2deefbb 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -155,23 +155,6 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) { short tot_changed= 0; - /* XXX always set state vars for buttonsview, this is hardcoded */ - switch (type) { - /* panels view, with free/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_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; - } - break; - } - - /* initialise data if there is a need for such */ if ((v2d->flag & V2D_IS_INITIALISED) == 0) { /* set initialised flag so that View2D doesn't get reinitialised next time again */ @@ -249,28 +232,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) } break; - /* ui listviews, tries to wrap 'tot' inside region width */ - case V2D_COMMONVIEW_LIST_UI: - { - /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ - v2d->keepzoom= (V2D_KEEPASPECT|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; - - v2d->tot.xmin= 0.0f; - v2d->tot.xmax= 336.f; // XXX 320 width + 2 x PNL_DIST - - v2d->tot.ymax= 0.0f; - v2d->tot.ymin= -336.0f*((float)winy)/(float)winx; - - v2d->cur= v2d->tot; - } - break; - - /* panels view, with free/horizontal/vertical align */ + /* 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 */ @@ -465,18 +427,28 @@ void UI_view2d_curRect_validate(View2D *v2d) /* resize from centerpoint */ if (width != curwidth) { - temp= (cur->xmax + cur->xmin) * 0.5f; - dh= width * 0.5f; - - cur->xmin = temp - dh; - cur->xmax = temp + dh; + if (v2d->keepofs & V2D_LOCKOFS_X) { + cur->xmax += width - (cur->xmax - cur->xmin); + } + else { + temp= (cur->xmax + cur->xmin) * 0.5f; + dh= width * 0.5f; + + cur->xmin = temp - dh; + cur->xmax = temp + dh; + } } if (height != curheight) { - temp= (cur->ymax + cur->ymin) * 0.5f; - dh= height * 0.5f; - - cur->ymin = temp - dh; - cur->ymax = temp + dh; + if (v2d->keepofs & V2D_LOCKOFS_Y) { + cur->ymax += height - (cur->ymax - cur->ymin); + } + else { + temp= (cur->ymax + cur->ymin) * 0.5f; + dh= height * 0.5f; + + cur->ymin = temp - dh; + cur->ymax = temp + dh; + } } } @@ -872,8 +844,13 @@ void UI_view2d_view_ortho(const bContext *C, View2D *v2d) * but only applied where requsted */ /* XXX ton: fix this! */ - xofs= 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f; - yofs= 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f; + xofs= 0.0; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f; + yofs= 0.0; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f; + + /* XXX brecht: instead of zero at least use a tiny offset, otherwise + * pixel rounding is effectively random due to float inaccuracy */ + xofs= 0.001f; + yofs= 0.001f; /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); |