Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenloader/intern/readfile.c16
-rw-r--r--source/blender/editors/interface/view2d.c63
-rw-r--r--source/blender/editors/space_action/space_action.c101
-rw-r--r--source/blender/editors/space_nla/space_nla.c15
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c3
-rw-r--r--source/blender/makesdna/DNA_view2d_types.h4
6 files changed, 142 insertions, 60 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3fcf0beeb26..559d6b21249 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5079,19 +5079,21 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype= RGN_TYPE_CHANNELS;
ar->alignment= RGN_ALIGN_LEFT;
-
+ ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
break;
case SPACE_ACTION:
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
BLI_addtail(lb, ar);
ar->regiontype= RGN_TYPE_CHANNELS;
ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
break;
case SPACE_NLA:
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
BLI_addtail(lb, ar);
ar->regiontype= RGN_TYPE_CHANNELS;
ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
break;
}
}
@@ -5117,7 +5119,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
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 = V2D_KEEPTOT_STRICT;
- ar->v2d.flag |= V2D_IS_INITIALISED;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
}
break;
case SPACE_TIME:
@@ -5131,7 +5133,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;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
}
break;
case SPACE_IPO:
@@ -5141,7 +5143,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;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_SOUND:
@@ -5151,7 +5153,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;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_NLA:
@@ -5161,7 +5163,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;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_ACTION:
@@ -5171,7 +5173,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;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_SEQ:
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 3213e120135..e0e60f67fcb 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -64,7 +64,6 @@
* - 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_region_reinit(View2D *v2d, short type, int winx, int winy)
{
short tot_changed= 0;
@@ -127,8 +126,8 @@ 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_KEEPZOOM|V2D_KEEPASPECT);
v2d->minzoom= v2d->maxzoom= 1.0f;
- v2d->min[0]= v2d->max[0]= winx;
- v2d->min[1]= v2d->max[1]= winy;
+ v2d->min[0]= v2d->max[0]= winx-1;
+ v2d->min[1]= v2d->max[1]= winy-1;
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
@@ -140,6 +139,9 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* absolutely no scrollers allowed */
v2d->scroll= 0;
+
+ /* pixel offsets need to be applied for smooth UI controls */
+ v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
}
break;
@@ -335,8 +337,15 @@ void UI_view2d_curRect_validate(View2D *v2d)
}
}
else {
- /* landscape window: correct for y */
- height = width * winRatio;
+ if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winy != v2d->oldwiny)) {
+ /* special exception for Outliner (and later channel-lists):
+ * - Currently, no actions need to be taken here...
+ */
+ }
+ else {
+ /* landscape window: correct for y */
+ height = width * winRatio;
+ }
}
/* store region size for next time */
@@ -625,28 +634,30 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
}
}
-/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing
-* - this assumes viewport/scissor been set for the region, taking scrollbars into account
-*/
-
+/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing */
void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
{
wmWindow *window= CTX_wm_window(C);
rctf curmasked;
+ float xofs, yofs;
- /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied,
- * as they were causing some unwanted offsets when drawing
+ /* pixel offsets (-0.375f) are needed to get 1:1 correspondance with pixels for smooth UI drawing,
+ * but only applied where requsted
*/
+ xofs= (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
+ yofs= (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
+
+ /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
- wmOrtho2(window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
+
+ /* set matrix on all appropriate axes */
+ wmOrtho2(window, curmasked.xmin-xofs, curmasked.xmax-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
/* XXX is this necessary? */
wmLoadIdentity(window);
}
/* Set view matrices to only use one axis of 'cur' only
- * - this assumes viewport/scissor been set for the region, taking scrollbars into account
- *
* - xaxis = if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
*/
void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
@@ -654,15 +665,22 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
wmWindow *window= CTX_wm_window(C);
ARegion *ar= CTX_wm_region(C);
rctf curmasked;
+ float xofs, yofs;
- /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied,
- * as they were causing some unwanted offsets when drawing
+ /* pixel offsets (-0.375f) are needed to get 1:1 correspondance with pixels for smooth UI drawing,
+ * but only applied where requsted
*/
+ xofs= (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
+ yofs= (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 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(window, curmasked.xmin, curmasked.xmax, 0, ar->winy);
+ wmOrtho2(window, curmasked.xmin-xofs, curmasked.xmax-xofs, -yofs, ar->winy-yofs);
else
- wmOrtho2(window, 0, ar->winx, curmasked.ymin, curmasked.ymax);
+ wmOrtho2(window, -xofs, ar->winx-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
/* XXX is this necessary? */
wmLoadIdentity(window);
@@ -779,8 +797,6 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
grid->powerx-= 2;
if (grid->powerx < -2) grid->powerx= -2;
}
-
- grid->startx= v2d->cur.xmin;
}
/* calculate y-axis grid scale (only if both args are valid) */
@@ -795,8 +811,6 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
if (grid->dy < 1.0f) grid->dy= 1.0f;
if (grid->powery < 1) grid->powery= 1;
}
-
- grid->starty= v2d->cur.ymin;
}
/* calculate start position */
@@ -804,10 +818,15 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
grid->startx= seconddiv*(v2d->cur.xmin/seconddiv - fmod(v2d->cur.xmin/seconddiv, grid->dx/seconddiv));
if (v2d->cur.xmin < 0.0f) grid->startx-= grid->dx;
}
+ else
+ grid->startx= v2d->cur.xmin;
+
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
grid->starty= (v2d->cur.ymin - fmod(v2d->cur.ymin, grid->dy));
if (v2d->cur.ymin < 0.0f) grid->starty-= grid->dy;
}
+ else
+ grid->starty= v2d->cur.ymin;
return grid;
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 35b5d592637..4b29167e844 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -80,41 +80,44 @@ static SpaceLink *action_new(void)
ar->regiontype= RGN_TYPE_HEADER;
ar->alignment= RGN_ALIGN_BOTTOM;
+ /* channel list region */
+ ar= MEM_callocN(sizeof(ARegion), "channel area for action");
+ BLI_addtail(&saction->regionbase, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+
+ /* only need to set scroll settings, as this will use 'listview' v2d configuration */
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ ar->v2d.flag = V2D_VIEWSYNC_Y;
+
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for action");
BLI_addtail(&saction->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
- ar->v2d.tot.xmin= 1.0f;
- ar->v2d.tot.ymin= -1000.0f;
- ar->v2d.tot.xmax= 1000.0f;
+ ar->v2d.tot.xmin= -5.0f;
+ ar->v2d.tot.ymin= -2000.0f;
+ ar->v2d.tot.xmax= 1000.0f; // xxx - use end frame instead?
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.cur.xmin= -2.0f;
+ ar->v2d.cur.ymin= -200.0f;
+ ar->v2d.cur.xmax= 100.0f;
+ ar->v2d.cur.ymax= 0.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.max[1]= 2000.0f;
ar->v2d.minzoom= 0.01f;
ar->v2d.maxzoom= 50;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
- ar->v2d.align= V2D_ALIGN_NO_POS_X;
-
- /* channel list region XXX */
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(&saction->regionbase, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
-
+ ar->v2d.align= V2D_ALIGN_NO_POS_Y;
return (SpaceLink *)saction;
}
@@ -159,9 +162,12 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar)
static void action_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
+ SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
+ View2DGrid *grid;
+ View2DScrollers *scrollers;
float col[3];
+ int unit;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -170,13 +176,22 @@ static void action_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(C, v2d);
- /* data... */
+ /* time grid */
+ unit= (saction->flag & SACTION_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
+ grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_NOCLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
+ UI_view2d_grid_draw(C, v2d, grid, V2D_GRIDLINES_ALL);
+ UI_view2d_grid_free(grid);
+ /* data? */
+
/* reset view matrix */
UI_view2d_view_restore(C);
- /* scrollers? */
+ /* scrollers */
+ scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_NOCLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ UI_view2d_scrollers_draw(C, v2d, scrollers);
+ UI_view2d_scrollers_free(scrollers);
}
void action_operatortypes(void)
@@ -190,6 +205,46 @@ void action_keymap(struct wmWindowManager *wm)
}
/* add handlers, stuff you only do once or on area/region changes */
+static void action_channel_area_init(wmWindowManager *wm, ARegion *ar)
+{
+ ListBase *keymap;
+
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
+
+ /* own keymap */
+ keymap= WM_keymap_listbase(wm, "Action", SPACE_ACTION, 0); /* XXX weak? */
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+}
+
+static void action_channel_area_draw(const bContext *C, ARegion *ar)
+{
+ /* draw entirely, view changes should be handled here */
+ //SpaceAction *saction= C->area->spacedata.first;
+ View2D *v2d= &ar->v2d;
+ View2DScrollers *scrollers;
+ float col[3];
+
+ /* clear and setup matrix */
+ UI_GetThemeColor3fv(TH_BACK, col);
+ glClearColor(col[0], col[1], col[2], 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ UI_view2d_view_ortho(C, v2d);
+
+ /* data... */
+
+
+ /* reset view matrix */
+ UI_view2d_view_restore(C);
+
+ /* scrollers */
+ scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ UI_view2d_scrollers_draw(C, v2d, scrollers);
+ UI_view2d_scrollers_free(scrollers);
+}
+
+
+/* add handlers, stuff you only do once or on area/region changes */
static void action_header_area_init(wmWindowManager *wm, ARegion *ar)
{
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
@@ -261,11 +316,11 @@ void ED_spacetype_action(void)
/* regions: channels */
art= MEM_callocN(sizeof(ARegionType), "spacetype action region");
art->regionid = RGN_TYPE_CHANNELS;
- art->minsizex = 200;
+ 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_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 6bb42527241..58f7b92e872 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -78,6 +78,14 @@ static SpaceLink *nla_new(void)
ar->regiontype= RGN_TYPE_HEADER;
ar->alignment= RGN_ALIGN_BOTTOM;
+ /* channel list region XXX */
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(&snla->regionbase, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for nla");
@@ -106,13 +114,6 @@ static SpaceLink *nla_new(void)
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
-
-
- /* channel list region XXX */
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(&snla->regionbase, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
return (SpaceLink *)snla;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 4fa10adcd91..ba694754e13 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -555,7 +555,8 @@ static SpaceLink *outliner_new(void)
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_KEEPZOOM|V2D_KEEPASPECT);
- ar->v2d.keeptot= 2; /* XXX make define */
+ ar->v2d.keeptot= V2D_KEEPTOT_STRICT;
+ ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
return (SpaceLink*)soutliner;
}
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index ff96e9092e5..20b14b178ac 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -92,6 +92,10 @@ typedef struct View2D {
#define V2D_VIEWSYNC_X (1<<0)
/* within region view2d vertical locking */
#define V2D_VIEWSYNC_Y (1<<1)
+ /* apply pixel offsets on x-axis */
+#define V2D_PIXELOFS_X (1<<2)
+ /* apply pixel offsets on y-axis */
+#define V2D_PIXELOFS_Y (1<<3)
/* view settings need to be set still... */
#define V2D_IS_INITIALISED (1<<10)