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:
authorJoshua Leung <aligorith@gmail.com>2008-12-13 02:25:54 +0300
committerJoshua Leung <aligorith@gmail.com>2008-12-13 02:25:54 +0300
commit56557f223fb9c9afae0965fb564b9c189e97f5cb (patch)
tree846332e23b6e1fed438d56469bdc0a4677d64fed /source/blender
parentf3dc0ba876d37f7c85c3fc1408b24f962a88642e (diff)
2.5 - Assorted View2D related fixes
IPO Editor Fixes: * Grid now draws correct. Fixed typo in gridline calculations preventing drawing from occurring. Also, set the right arguments to the appropriate View2D calls. * Limited Ton's cur<->mask mapping 'hack' to Outliner only, as it was causing problems with the drawing of the grid. Perhaps there's still some faulty code in curRect_validate that should be changed instead... * Horizontal scroller draws frames now by default. However, the values are still offset a bit, so will need further investigation. Outliner Fixes: * Fixed overlapping text problem with RNA-path and menus. Now RNA path draws as a label beside the menus, so there shouldn't be any more problems there. * do_versions code now sets all appropriate flags, as old OOPS views could cause errors with scroller drawing + view manipulation operators which depend on flags being set.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/editors/include/UI_view2d.h12
-rw-r--r--source/blender/editors/interface/view2d.c26
-rw-r--r--source/blender/editors/space_ipo/space_ipo.c62
-rw-r--r--source/blender/editors/space_outliner/outliner_header.c17
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c19
-rw-r--r--source/blender/makesdna/DNA_space_types.h7
7 files changed, 103 insertions, 44 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 7548c9ca970..6172731b425 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5099,9 +5099,11 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
- ar->v2d.scroll |= V2D_SCROLL_RIGHT;
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_HORIZONTAL_O);
ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y);
+ ar->v2d.keeptot = 2;
+ ar->v2d.keepaspect= 1;
}
break;
case SPACE_TIME:
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 6f379ec3f7b..04537ed69b1 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -58,10 +58,14 @@
/* flags for grid-lines to draw */
-#define V2D_HORIZONTAL_LINES (1<<0)
-#define V2D_VERTICAL_LINES (1<<1)
-#define V2D_HORIZONTAL_AXIS (1<<2)
-#define V2D_VERTICAL_AXIS (1<<3)
+#define V2D_HORIZONTAL_LINES (1<<0)
+#define V2D_VERTICAL_LINES (1<<1)
+#define V2D_HORIZONTAL_AXIS (1<<2)
+#define V2D_VERTICAL_AXIS (1<<3)
+#define V2D_HORIZONTAL_FINELINES (1<<4)
+
+#define V2D_GRIDLINES_MAJOR (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS|V2D_HORIZONTAL_LINES|V2D_HORIZONTAL_AXIS)
+#define V2D_GRIDLINES_ALL (V2D_GRIDLINES_MAJOR|V2D_HORIZONTAL_FINELINES)
/* ------------------------------------------ */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 73dd1cdb3ea..66eeb930ab5 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -443,6 +443,8 @@ void UI_view2d_curRect_reset (View2D *v2d)
}
}
+/* ------------------ */
+
/* Change the size of the maximum viewable area (i.e. 'tot' rect) */
void UI_view2d_totRect_set (View2D *v2d, int width, int height)
{
@@ -495,12 +497,15 @@ void UI_view2d_totRect_set (View2D *v2d, int width, int height)
/* *********************************************************************** */
/* View Matrix Setup */
-/* mapping function to ensure 'cur' draws extended over the area were sliders are */
+/* mapping function to ensure 'cur' draws extended over the area where sliders are */
static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
{
*curmasked= v2d->cur;
- if (v2d->scroll) {
+ /* currently, the following 'hack' is only necessary for Outliner, and will cause
+ * errors in all other views...
+ */
+ if ((v2d->scroll) && (v2d->keeptot==2)) {
float dx= ((float)(v2d->mask.xmax-v2d->mask.xmin+1))/(v2d->cur.xmax-v2d->cur.xmin);
float dy= ((float)(v2d->mask.ymax-v2d->mask.ymin+1))/(v2d->cur.ymax-v2d->cur.ymin);
@@ -675,7 +680,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short unit, shor
}
/* calculate y-axis grid scale */
- space= (v2d->cur.ymax - v2d->cur.ymin);
+ space= v2d->cur.ymax - v2d->cur.ymin;
pixels= winy;
grid->dy= MINGRIDSTEP * space / pixels;
@@ -739,15 +744,17 @@ void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int f
/* horizontal lines */
if (flag & V2D_HORIZONTAL_LINES) {
+ puts("draw horizontal lines");
/* only major gridlines */
- vec1[0]= grid->startx;
vec1[1]= vec2[1]= grid->starty;
+ vec1[0]= grid->startx;
vec2[0]= v2d->cur.xmax;
- step= (v2d->mask.ymax - v2d->mask.ymax + 1) / MINGRIDSTEP;
+ step= (v2d->mask.ymax - v2d->mask.ymin + 1) / MINGRIDSTEP;
UI_ThemeColor(TH_GRID);
for (a=0; a<=step; a++) {
+ printf("\t a = %d \n", a);
glBegin(GL_LINE_STRIP);
glVertex2fv(vec1);
glVertex2fv(vec2);
@@ -757,12 +764,10 @@ void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int f
}
/* fine grid lines */
- // er... only in IPO-Editor it seems (how to expose this in nice way)?
vec2[1]= vec1[1]-= 0.5f*grid->dy;
step++;
-#if 0
- if (curarea->spacetype==SPACE_IPO) {
+ if (flag & V2D_HORIZONTAL_FINELINES) {
UI_ThemeColorShade(TH_GRID, 16);
for (a=0; a<step; a++) {
glBegin(GL_LINE_STRIP);
@@ -773,7 +778,6 @@ void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int f
vec2[1]= vec1[1]-= grid->dy;
}
}
-#endif
}
/* Axes are drawn as darker lines */
@@ -890,9 +894,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
if ( !((xclamp == V2D_ARG_DUMMY) && (xunits == V2D_ARG_DUMMY) && (yclamp == V2D_ARG_DUMMY) && (yunits == V2D_ARG_DUMMY)) ) {
/* if both axes show scale, give priority to horizontal.. */
// FIXME: this doesn't do justice to the vertical scroller calculations...
- if (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)
+ if ((v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && ELEM(V2D_ARG_DUMMY, xclamp, xunits)==0)
scrollers->grid= UI_view2d_grid_calc(C, v2d, xunits, xclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
- else if (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)
+ else if (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL && ELEM(V2D_ARG_DUMMY, yclamp, yunits)==0)
scrollers->grid= UI_view2d_grid_calc(C, v2d, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
}
}
diff --git a/source/blender/editors/space_ipo/space_ipo.c b/source/blender/editors/space_ipo/space_ipo.c
index 9b119beef63..675becb3308 100644
--- a/source/blender/editors/space_ipo/space_ipo.c
+++ b/source/blender/editors/space_ipo/space_ipo.c
@@ -146,6 +146,51 @@ static SpaceLink *ipo_duplicate(SpaceLink *sl)
return (SpaceLink *)sipon;
}
+
+// XXX this should be defined in some general lib for anim editors...
+static void draw_cfra(const bContext *C, SpaceIpo *sipo, View2D *v2d)
+{
+ Scene *scene= C->scene;
+ Object *ob;
+ float vec[2];
+
+ //vec[0] = get_ipo_cfra_from_cfra(sipo, scene->r.cfra);
+ vec[0] = scene->r.cfra;
+ vec[0]*= scene->r.framelen;
+
+ vec[1]= v2d->cur.ymin;
+ UI_ThemeColor(TH_CFRAME);
+ glLineWidth(2.0);
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(vec);
+ vec[1]= v2d->cur.ymax;
+ glVertex2fv(vec);
+ glEnd();
+
+#if 0
+ if(sipo->blocktype==ID_OB) {
+ ob= (G.scene->basact) ? (G.scene->basact->object) : 0;
+ if (ob && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) {
+ vec[0]-= give_timeoffset(ob);
+
+ UI_ThemeColorShade(TH_HILITE, -30);
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(vec);
+ vec[1]= G.v2d->cur.ymin;
+ glVertex2fv(vec);
+ glEnd();
+ }
+ }
+#endif
+
+ glLineWidth(1.0);
+
+ /* Draw current frame number in a little box */
+ //draw_cfra_number(vec[0]);
+}
+
/* add handlers, stuff you only do once or on area/region changes */
static void ipo_main_area_init(wmWindowManager *wm, ARegion *ar)
{
@@ -176,11 +221,16 @@ static void ipo_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(C, v2d);
/* grid */
- unit= (sipo->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS;
- grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_CLAMP, ar->winx, ar->winy);
- UI_view2d_grid_draw(C, v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
+ unit= (sipo->flag & SIPO_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
+ grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
+ UI_view2d_grid_draw(C, v2d, grid, V2D_GRIDLINES_ALL);
UI_view2d_grid_free(grid);
-
+
+ /* data... */
+
+ /* current frame */
+ draw_cfra(C, sipo, v2d);
+
/* markers */
UI_view2d_view_orthoSpecial(C, v2d, 1);
draw_markers_time(C, 0);
@@ -189,7 +239,8 @@ static void ipo_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ // FIXME: args for scrollers depend on the type of data being shown...
+ scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_NOCLAMP, V2D_UNIT_VALUES/*unit-y*/, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -256,6 +307,7 @@ void ED_spacetype_ipo(void)
art->init= ipo_main_area_init;
art->draw= ipo_main_area_draw;
art->listener= ipo_main_area_listener;
+ art->keymapflag= ED_KEYMAP_VIEW2D;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c
index 87e3253dae9..2765d80cf8c 100644
--- a/source/blender/editors/space_outliner/outliner_header.c
+++ b/source/blender/editors/space_outliner/outliner_header.c
@@ -106,8 +106,10 @@ static void do_outliner_buttons(bContext *C, void *arg, int event)
void outliner_header_buttons(const bContext *C, ARegion *ar)
{
ScrArea *sa= C->area;
+ SpaceOops *soutliner= sa->spacedata.first;
uiBlock *block;
int xco, yco= 3;
+ char *path;
block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
uiBlockSetHandleFunc(block, do_outliner_buttons, NULL);
@@ -151,11 +153,20 @@ void outliner_header_buttons(const bContext *C, ARegion *ar)
xmax= GetButStringLength("View");
uiDefPulldownBut(block, dummy_viewmenu, C->area,
- "View", xco, yco-2, xmax-3, 24, "");
+ "View", xco, yco-2, xmax-3, 24, "");
+ xco += xmax;
+
+ /* header text */
+ xco += XIC*2;
+
+ path= (soutliner->rnapath)? soutliner->rnapath: "Main";
+ xmax= GetButStringLength(path);
+ uiDefBut(block, LABEL, 0, path, xco, yco-2, xmax-3, 24, 0, 0, 0, 0, 0, "Current RNA Path");
+ xco += xmax;
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
}
- uiBlockSetEmboss(block, UI_EMBOSS);
-
/* always as last */
sa->headbutlen= xco+XIC+80; // +80 because the last button is not an icon
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 229c473625f..7ddcd87d867 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -444,14 +444,8 @@ static void outliner_main_area_free(ARegion *ar)
static void outliner_header_area_draw(const bContext *C, ARegion *ar)
{
- SpaceOops *soutliner= C->area->spacedata.first;
float col[3];
- int width, height;
- rctf bbox;
- char *path;
-
- path= (soutliner->rnapath)? soutliner->rnapath: "Main";
-
+
if(ED_screen_area_active(C))
UI_GetThemeColor3fv(TH_HEADER, col);
else
@@ -461,17 +455,6 @@ static void outliner_header_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
outliner_header_buttons(C, ar);
-
- width= ar->winrct.xmax - ar->winrct.xmin;
- height= ar->winrct.ymax - ar->winrct.ymin;
-
- /* header text */
- UI_GetBoundingBox(UI_HELV, path, 0, &bbox);
-
- glColor3f(1.0f, 1.0f, 1.0f);
- UI_SetScale(1.0);
- UI_RasterPos(50 + 0.5f*(width - (bbox.xmax - bbox.xmin)), 0.5f*(height - (bbox.ymax - bbox.ymin)));
- UI_DrawString(UI_HELV, path, 0);
}
static void outliner_header_area_free(ARegion *ar)
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 3d8047c6100..d1af38b9e25 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -543,8 +543,11 @@ typedef struct SpaceImaSel {
#define SI_DISPGP 1<<22
/* SpaceIpo->flag */
-#define SIPO_LOCK_VIEW 1<<0
-#define SIPO_NOTRANSKEYCULL 1<<1
+#define SIPO_LOCK_VIEW (1<<0)
+#define SIPO_NOTRANSKEYCULL (1<<1)
+#define SIPO_NOHANDLES (1<<2)
+#define SIPO_NODRAWCFRANUM (1<<3)
+#define SIPO_DRAWTIME (1<<4)
/* SpaceText flags (moved from DNA_text_types.h) */