diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-30 02:57:53 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-30 02:57:53 +0400 |
commit | 408ba429e6aa392f769aac4a442a7a06c1740326 (patch) | |
tree | 63ae81d4fd4799cf3d6e4afd444681c6fc5ea1d3 /source/blender/editors/screen | |
parent | 2df1eeba0e212fe551f2e4cbfe222bd36026670f (diff) |
2.5: Buttons View
* When resizing the window, the top position is now preserved,
instead of the center position.
* Fix zoom level not being preserved in various cases, when
changing both with and height. This replaces some earlier code
which did this at screen level but wasn't very reliable.
* Different tabs now each preserve their own scroll.
* When switching between tabs, it now scrolls to show as many
buttons as possible, instead of possibly showing empty space.
There is a trade-off here between doing that keeping the
buttons in the same place, no ideal solution exists I think.
* Change zooming in/out to be symmetric, for example doing
numpad + then - did not give the original zoom level back.
* Added some calls to avoid hanging tooltips when manipulating
the view.
Internals:
* Added V2D_KEEPOFS_X and V2D_KEEPOFS_Y to keep the top/bottom
rather than the center.
* Renamed V2D_KEEPZOOM to V2D_LIMITZOOM (seems more appropriate),
and make V2D_KEEPZOOM preserve the zoom level.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 27 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 28 |
2 files changed, 18 insertions, 37 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c74a5ca9c87..79ba11a5c55 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1132,7 +1132,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) /************************ standard UI regions ************************/ -void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context) +void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context, int contextnr) { ScrArea *sa= CTX_wm_area(C); uiStyle *style= U.uistyles.first; @@ -1142,7 +1142,10 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex View2D *v2d= &ar->v2d; View2DScrollers *scrollers; float col[3]; - int xco, yco, x, y, miny=0, w, em, header, triangle, open; + int xco, yco, x, y, miny=0, w, em, header, triangle, open, newcontext= 0; + + if(contextnr >= 0) + newcontext= UI_view2d_tab_set(v2d, contextnr); if(vertical) { w= v2d->cur.xmax - v2d->cur.xmin; @@ -1242,23 +1245,27 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex /* before setting the view */ if(vertical) { - v2d->keepofs |= V2D_LOCKOFS_X; - v2d->keepofs &= ~V2D_LOCKOFS_Y; + v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; + v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); // don't jump back when panels close or hide - y= MAX2(-y, -v2d->cur.ymin); + if(!newcontext) + y= MAX2(-y, -v2d->cur.ymin); + else + y= -y; } else { - v2d->keepofs &= ~V2D_LOCKOFS_X; - v2d->keepofs |= V2D_LOCKOFS_Y; + v2d->keepofs |= V2D_LOCKOFS_Y|V2D_KEEPOFS_X; + v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); // don't jump back when panels close or hide - x= MAX2(x, v2d->cur.xmax); + if(!newcontext) + x= MAX2(x, v2d->cur.xmax); y= -y; } // +V2D_SCROLL_HEIGHT is workaround to set the actual height - UI_view2d_totRect_set(v2d, x, y+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT); /* set the view */ UI_view2d_view_ortho(C, v2d); @@ -1282,6 +1289,8 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) // scrollbars for button regions ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom |= V2D_KEEPZOOM; + // correctly initialised User-Prefs? if(!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index dd6bb09c1e4..817959aef13 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -603,21 +603,6 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) } } -/* helper call for below, correct buttons view */ -static void screen_test_scale_region(ListBase *regionbase, float facx, float facy) -{ - ARegion *ar; - - for(ar= regionbase->first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_WINDOW) { - ar->v2d.cur.xmin *= facx; - ar->v2d.cur.xmax *= facx; - ar->v2d.cur.ymin *= facy; - ar->v2d.cur.ymax *= facy; - } - } -} - /* test if screen vertices should be scaled */ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) { @@ -668,19 +653,6 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) CLAMP(sv->vec.y, 0, winsizey); } - - /* keep buttons view2d same size */ - for(sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - if(sa->spacetype==SPACE_BUTS) - screen_test_scale_region(&sa->regionbase, facx, facy); - - for(sl= sa->spacedata.first; sl; sl= sl->next) - if(sl->spacetype==SPACE_BUTS) - screen_test_scale_region(&sl->regionbase, facx, facy); - } - } /* test for collapsed areas. This could happen in some blender version... */ |