diff options
Diffstat (limited to 'source')
20 files changed, 170 insertions, 135 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index adc7c657019..5452429e8ea 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5061,7 +5061,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb) /* is copy from ui_view2d.c */ ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); ar->v2d.keepofs = V2D_LOCKOFS_Y; - ar->v2d.keeptot = 2; // this keeps the view in place when region size changes... + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; } @@ -5116,7 +5116,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); - ar->v2d.keeptot = 2; + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.flag |= V2D_IS_INITIALISED; } break; case SPACE_TIME: @@ -5130,6 +5131,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; ar->v2d.tot.ymin= ar->v2d.cur.ymin= -10.0; ar->v2d.min[1]= ar->v2d.max[1]= 20.0; + ar->v2d.flag |= V2D_IS_INITIALISED; } break; case SPACE_IPO: @@ -5139,6 +5141,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_SOUND: @@ -5148,6 +5151,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_NLA: @@ -5157,6 +5161,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_ACTION: @@ -5166,6 +5171,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_SEQ: @@ -5175,12 +5181,14 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_NODE: { SpaceNode *snode= (SpaceNode *)sl; memcpy(&ar->v2d, &snode->v2d, sizeof(View2D)); + ar->v2d.flag |= V2D_IS_INITIALISED; break; } case SPACE_BUTS: @@ -5188,6 +5196,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) SpaceButs *sbuts= (SpaceButs *)sl; memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); ar->v2d.keepzoom |= V2D_KEEPASPECT; + ar->v2d.flag |= V2D_IS_INITIALISED; break; } //case SPACE_XXX: // FIXME... add other ones diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 8d8b137732a..09d57901b0b 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -44,10 +44,14 @@ enum { /* custom view type (region has defined all necessary flags already) */ V2D_COMMONVIEW_CUSTOM = 0, + /* view canvas ('standard' view, view limits/restrictions still need to be set first!) */ + V2D_COMMONVIEW_VIEWCANVAS, /* listview (i.e. Outliner) */ V2D_COMMONVIEW_LIST, /* headers (this is basically the same as listview, but no y-panning) */ V2D_COMMONVIEW_HEADER, + /* timegrid (this sets the settings for x/horizontal, but y/vertical settings still need to be set first!) */ + V2D_COMMONVIEW_TIMELINE, } eView2D_CommonViewTypes; /* ---- Defines for Scroller/Grid Arguments ----- */ @@ -125,10 +129,7 @@ typedef struct View2DScrollers View2DScrollers; /* Prototypes: */ /* refresh and validation (of view rects) */ -void UI_view2d_regiondata_init(struct View2D *v2d, short type, int winx, int winy); -void UI_view2d_header_default(struct View2D *v2d); - -void UI_view2d_size_update(struct View2D *v2d, int winx, int winy); +void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy); void UI_view2d_curRect_validate(struct View2D *v2d); void UI_view2d_curRect_reset(struct View2D *v2d); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index fb5fbf940e8..a5ec52b3d38 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -57,32 +57,18 @@ /* *********************************************************************** */ /* Refresh and Validation */ -/* Initialise all View2D data for a given region */ +/* Initialise all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize + * - for some of these presets, it is expected that the region will have defined some + * additional settings necessary for the customisation of the 2D viewport to its requirements + * - this function should only be called from region init() callbacks, where it is expected that + * this is called before UI_view2d_size_update(), as this one checks that the rects are properly initialised. + */ // eView2D_CommonViewTypes <--- only check handle these types... -void UI_view2d_regiondata_init(View2D *v2d, short type, int winx, int winy) -{ - -} - - -/* allowing horizontal pan */ -// XXX this should become one of 'standard' setups... -void UI_view2d_header_default(View2D *v2d) +void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) { - v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); - v2d->keepofs = V2D_LOCKOFS_Y; - v2d->keeptot = 2; // this keeps the view in place when region size changes... - v2d->align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; + short tot_changed= 0; -} - -/* Adjust mask size in response to view size changes - * - This should only be called in region init() callbacks, which are - * called when the region is resized or area changes... - */ -// XXX pre2.5 -> this used to be called calc_scrollrcts() -void UI_view2d_size_update(View2D *v2d, int winx, int winy) -{ + /* store view size */ v2d->winx= winx; v2d->winy= winy; @@ -138,22 +124,96 @@ void UI_view2d_size_update(View2D *v2d, int winx, int winy) } } - /* cope with unitialized veriables for simple cases, like header or outliner */ - // XXX er... this shouldn't be here??? or at least some extra checks are needed for some things... - if ((v2d->tot.xmin==v2d->tot.xmax) || (v2d->cur.xmin==v2d->cur.xmax)) { - if (v2d->keepzoom & (V2D_KEEPZOOM|V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y)) { - BLI_init_rctf(&v2d->tot, v2d->mask.xmin, v2d->mask.xmax, v2d->mask.ymin, v2d->mask.ymax); - BLI_init_rctf(&v2d->cur, v2d->mask.xmin, v2d->mask.xmax, v2d->mask.ymin, v2d->mask.ymax); + /* initialise data if there is a need for such */ + if ((v2d->flag & V2D_IS_INITIALISED) == 0) { + v2d->flag |= V2D_IS_INITIALISED; + + /* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */ + switch (type) { + /* 'standard view' - from (0,0) to (winx,winy), with other restrictions defined by region already */ + case V2D_COMMONVIEW_VIEWCANVAS: + { + /* just set 'tot' rect alignment restictions for now */ + v2d->align= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; + tot_changed= 1; + + // XXX... should we set min/max here too? probably not essential yet + } + break; - v2d->min[0]= v2d->max[0]= winx; - v2d->min[1]= v2d->max[1]= winy; - v2d->minzoom= 1.0f; - v2d->maxzoom= 1.0f; + /* 'list/channel view' - zoom, aspect ratio, and alignment restrictions are set here */ + case V2D_COMMONVIEW_LIST: + { + /* zoom + aspect ratio are locked */ + v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|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= 1; + + /* scroller settings are currently not set here... that is left for regions... */ + } + break; + + /* 'header' regions - zoom, aspect ratio, alignment, and panning restrictions are set here */ + case V2D_COMMONVIEW_HEADER: + { + /* zoom + aspect ratio are locked */ + v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); + v2d->minzoom= v2d->maxzoom= 1.0f; + v2d->min[0]= v2d->max[0]= winx; + v2d->min[1]= v2d->max[1]= winy; + + /* 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= 1; + + /* panning in y-axis is prohibited */ + v2d->keepofs= V2D_LOCKOFS_Y; + + /* absolutely no scrollers allowed */ + v2d->scroll= 0; + } + break; + + /* 'timeline/animeditors' - only set x-axis settings (y axis settings have already been set by regions, so don't overwrite! */ + case V2D_COMMONVIEW_TIMELINE: + { + /* zoom on x-axis is free, but zoom factors are usually standard */ + v2d->minzoom= 0.5f; + v2d->maxzoom= 10.0f; + + /* size limits on x-axis are also standard */ + v2d->min[0]= 0.0f; // XXX... would 1.0f be better? + v2d->max[0]= MAXFRAMEF; + + /* scrollers for x-axis must be shown, and with scales */ + v2d->scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + + /* 'tot' rect x-axis size */ + v2d->tot.xmin= (float)(SFRA - 10); + v2d->tot.xmax= (float)(EFRA + 10); + v2d->cur.xmin= v2d->mask.xmin; + v2d->cur.xmax= v2d->mask.xmax; + tot_changed= 0; // er.. + } + break; + + /* other view types are completely defined using their own settings already */ + default: + /* we don't do anything here, as settings should be fine, but just make sure that rect */ + break; } } - /* make sure that 'cur' rect is in a valid state as a result of these changes */ - UI_view2d_curRect_validate(v2d); + /* set 'tot' rect before setting cur? */ + if (tot_changed) + UI_view2d_totRect_set(v2d, winx, winy); + else + UI_view2d_curRect_validate(v2d); } /* Ensure View2D rects remain in a viable configuration @@ -254,7 +314,7 @@ void UI_view2d_curRect_validate(View2D *v2d) do_win= do_y; if (do_cur) { - if ((v2d->keeptot == 2) && (winx != v2d->oldwinx)) { + if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) { /* special exception for Outliner (and later channel-lists): * - The view may be moved left to avoid contents being pushed out of view when view shrinks. * - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed) @@ -321,8 +381,8 @@ void UI_view2d_curRect_validate(View2D *v2d) if (cur->xmin < tot->xmin) cur->xmin= tot->xmin; if (cur->xmax > tot->xmax) cur->xmax= tot->xmax; } - else if (v2d->keeptot == 2) { - /* This is an exception for the outliner (and later channel-lists) + else if (v2d->keeptot == V2D_KEEPTOT_STRICT) { + /* 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 */ @@ -441,7 +501,9 @@ void UI_view2d_curRect_validate(View2D *v2d) /* ------------------ */ -/* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot) */ +/* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot) + * This does not take into account if zooming the view on an axis will improve the view (if allowed) + */ void UI_view2d_curRect_reset (View2D *v2d) { float width, height; @@ -950,9 +1012,6 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short return scrollers; } -/* XXX */ -extern void ui_rasterpos_safe(float x, float y, float aspect); - /* Print scale marking along a time scrollbar */ static void scroll_printstr(View2DScrollers *scrollers, float x, float y, float val, int power, short unit, char dir) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index ffc435df4b4..b945e260fb9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -716,7 +716,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) float dx, dy; /* calculate new delta transform, based on zooming mode */ - if (U.viewzoom == USER_ZOOM_SCALE) { // XXX store this setting as RNA prop? + if (U.viewzoom == USER_ZOOM_SCALE) { /* 'scale' zooming */ float dist; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index bf37f89e187..79e5fe243f8 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -79,7 +79,6 @@ static SpaceLink *action_new(void) BLI_addtail(&saction->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for action"); @@ -92,23 +91,13 @@ static SpaceLink *action_new(void) ar->v2d.tot.xmax= 1000.0f; ar->v2d.tot.ymax= 0.0f; - ar->v2d.cur.xmin= -5.0f; - ar->v2d.cur.ymin= -75.0f; - ar->v2d.cur.xmax= 65.0f; - ar->v2d.cur.ymax= 5.0f; - - ar->v2d.min[0]= 0.0f; ar->v2d.min[1]= 0.0f; - - ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= 1000.0f; - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; + ar->v2d.scroll = V2D_SCROLL_RIGHT; - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - saction->v2d.keepzoom= V2D_LOCKZOOM_Y; + ar->v2d.align= saction->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.keepzoom= saction->v2d.keepzoom= V2D_LOCKZOOM_Y; /* channel list region XXX */ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); @@ -150,7 +139,7 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Action", SPACE_ACTION, 0); /* XXX weak? */ @@ -193,7 +182,7 @@ void action_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void action_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void action_header_area_draw(const bContext *C, ARegion *ar) @@ -262,11 +251,11 @@ void ED_spacetype_action(void) /* regions: channels */ art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; - art->minsizex= 80; + art->minsizex = 200; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; -// art->init= action_channel_area_init; -// art->draw= action_channel_area_draw; + //art->init= action_channel_area_init; + //art->draw= action_channel_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 9fc7ca123dc..4c29d71f62a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -77,7 +77,6 @@ static SpaceLink *buttons_new(void) BLI_addtail(&sbuts->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for buts"); @@ -102,6 +101,7 @@ static SpaceLink *buttons_new(void) sbuts->v2d.maxzoom= 1.21f; sbuts->v2d.scroll= 0; // TODO: will we need scrollbars? + sbuts->v2d.align= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; sbuts->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT; sbuts->v2d.keeptot= 1; sbuts->v2d.cur= sbuts->v2d.tot; @@ -146,7 +146,7 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Buttons", SPACE_BUTS, 0); /* XXX weak? */ @@ -189,7 +189,7 @@ void buttons_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void buttons_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index b6d87ee0224..972e852f481 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -81,7 +81,6 @@ static SpaceLink *file_new(void) BLI_addtail(&sfile->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for file"); @@ -132,7 +131,7 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); /* XXX weak? */ @@ -175,7 +174,7 @@ void file_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void file_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void file_header_area_draw(const bContext *C, ARegion *ar) @@ -233,7 +232,6 @@ void ED_spacetype_file(void) /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; - art->minsizey= HEADERY; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; art->init= file_header_area_init; @@ -244,7 +242,6 @@ void ED_spacetype_file(void) /* regions: channels */ art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_CHANNELS; - art->minsizex= 80; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; // art->init= file_channel_area_init; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 6cefcd8321b..7d34f724de2 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -83,7 +83,6 @@ static SpaceLink *image_new(void) BLI_addtail(&simage->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -132,7 +131,7 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_VIEWCANVAS, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0); /* XXX weak? */ @@ -175,7 +174,7 @@ void image_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void image_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void image_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 7a54297a2f3..82bc6949c61 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -76,7 +76,6 @@ static SpaceLink *info_new(void) BLI_addtail(&sinfo->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for info"); @@ -120,7 +119,7 @@ static void info_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_VIEWCANVAS, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "info", SPACE_INFO, 0); /* XXX weak? */ @@ -163,7 +162,7 @@ void info_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void info_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void info_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_ipo/space_ipo.c b/source/blender/editors/space_ipo/space_ipo.c index 4272f45ea6d..0afe38ea470 100644 --- a/source/blender/editors/space_ipo/space_ipo.c +++ b/source/blender/editors/space_ipo/space_ipo.c @@ -77,7 +77,6 @@ static SpaceLink *ipo_new(void) BLI_addtail(&sipo->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* channels */ ar= MEM_callocN(sizeof(ARegion), "main area for ipo"); @@ -195,7 +194,7 @@ static void ipo_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Ipo", SPACE_IPO, 0); /* XXX weak? */ @@ -266,7 +265,7 @@ static void ipo_channel_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void ipo_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void ipo_header_area_draw(const bContext *C, ARegion *ar) @@ -335,7 +334,7 @@ void ED_spacetype_ipo(void) /* regions: channels */ art= MEM_callocN(sizeof(ARegionType), "spacetype ipo region"); art->regionid = RGN_TYPE_CHANNELS; - art->minsizex= 80; + art->minsizex= 200; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; // art->init= ipo_channel_area_init; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 71d837249fa..17f92c30502 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -77,7 +77,6 @@ static SpaceLink *nla_new(void) BLI_addtail(&snla->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for nla"); @@ -149,7 +148,7 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "NLA", SPACE_NLA, 0); /* XXX weak? */ @@ -192,7 +191,7 @@ void nla_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void nla_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void nla_header_area_draw(const bContext *C, ARegion *ar) @@ -261,11 +260,11 @@ void ED_spacetype_nla(void) /* regions: channels */ art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; - art->minsizex= 80; + art->minsizex= 200; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; -// art->init= nla_channel_area_init; -// art->draw= nla_channel_area_draw; + //art->init= nla_channel_area_init; + //art->draw= nla_channel_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 6569200196c..938cd283361 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -75,7 +75,6 @@ static SpaceLink *node_new(void) BLI_addtail(&snode->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for node"); @@ -143,7 +142,7 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_VIEWCANVAS, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0); /* XXX weak? */ @@ -186,7 +185,7 @@ void node_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void node_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void node_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index cb0b29089b7..36afb206ab6 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -394,8 +394,7 @@ static void rna_table_cell_func(void *userdata, int row, int col, rcti *rct, uiB static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) @@ -505,7 +504,7 @@ static void outliner_main_area_free(ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void outliner_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void outliner_header_area_draw(const bContext *C, ARegion *ar) @@ -545,7 +544,6 @@ static SpaceLink *outliner_new(void) BLI_addtail(&soutliner->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for outliner"); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 081da6f5505..bb31dd8dc03 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -77,7 +77,6 @@ static SpaceLink *script_new(void) BLI_addtail(&sscript->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for script"); @@ -130,7 +129,7 @@ static void script_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_VIEWCANVAS, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Script", SPACE_SCRIPT, 0); /* XXX weak? */ @@ -173,7 +172,7 @@ void script_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void script_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void script_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index b2e2aa67c25..714e6be2416 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -79,7 +79,6 @@ static SpaceLink *sequencer_new(void) BLI_addtail(&sseq->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for sequencer"); @@ -149,7 +148,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0); /* XXX weak? */ @@ -192,7 +191,7 @@ void sequencer_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void sequencer_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void sequencer_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 18e2c01a2e8..e02f7f4be12 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -77,7 +77,6 @@ static SpaceLink *sound_new(void) BLI_addtail(&ssound->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for sound"); @@ -108,6 +107,7 @@ static SpaceLink *sound_new(void) ar->v2d.scroll |= (V2D_SCROLL_LEFT); ar->v2d.keepzoom= 0; ar->v2d.keeptot= 0; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; return (SpaceLink *)ssound; @@ -144,7 +144,7 @@ static void sound_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Sound", SPACE_SOUND, 0); /* XXX weak? */ @@ -187,7 +187,7 @@ void sound_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void sound_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void sound_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 5b52e43d0f2..dee5c4b2d25 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -78,7 +78,6 @@ static SpaceLink *text_new(void) BLI_addtail(&stext->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for text"); @@ -123,7 +122,7 @@ static void text_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_VIEWCANVAS, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "Text", SPACE_TEXT, 0); /* XXX weak? */ @@ -174,7 +173,7 @@ static void text_keymap(struct wmWindowManager *wm) /* add handlers, stuff you only do once or on area/region changes */ static void text_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void text_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 9667e132e09..29426840653 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -109,7 +109,7 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_TIMELINE, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_listbase(wm, "TimeLine", SPACE_TIME, 0); /* XXX weak? */ @@ -178,7 +178,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void time_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void time_header_area_draw(const bContext *C, ARegion *ar) @@ -223,7 +223,6 @@ static SpaceLink *time_new(void) BLI_addtail(&stime->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for time"); @@ -231,26 +230,18 @@ static SpaceLink *time_new(void) BLI_addtail(&stime->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; - ar->v2d.tot.xmin= -4.0; - ar->v2d.tot.ymin= 0.0; - ar->v2d.tot.xmax= (float)EFRA + 4.0; - ar->v2d.tot.ymax= 50.0; + /* only need to set y-locks for view2d of main area, + * as the rest is taken care of by View2D preset for TimeGrids + */ + ar->v2d.min[1]= 20.0; + ar->v2d.max[1]= 20.0; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur.ymin= ar->v2d.tot.ymin= 0.0f; + ar->v2d.cur.ymax= ar->v2d.tot.ymax= 20.0f; - ar->v2d.min[0]= 1.0; - ar->v2d.min[1]= 50.0; - - ar->v2d.max[0]= 32000.0; - ar->v2d.max[1]= 50.0; - - ar->v2d.minzoom= 0.1f; - ar->v2d.maxzoom= 10.0; - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; - ar->v2d.keepofs |= V2D_LOCKOFS_Y; - ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + ar->v2d.align = V2D_ALIGN_NO_NEG_Y; + ar->v2d.keepofs = V2D_LOCKOFS_Y; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; return (SpaceLink*)stime; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 015a931d806..9ccc7afe363 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -101,7 +101,6 @@ static SpaceLink *view3d_new(void) BLI_addtail(&vd->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - UI_view2d_header_default(&ar->v2d); /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for view3d"); @@ -202,7 +201,7 @@ static void view3d_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy); + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } static void view3d_header_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index 96b3febf7f3..ff96e9092e5 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -93,7 +93,7 @@ typedef struct View2D { /* within region view2d vertical locking */ #define V2D_VIEWSYNC_Y (1<<1) /* view settings need to be set still... */ -#define V2D_NEEDS_INIT (1<<10) +#define V2D_IS_INITIALISED (1<<10) /* scroller flags for View2D (v2d->scroll) */ /* left scrollbar */ |