2.5 - Assorted View2D related fixes
authorJoshua Leung <aligorith@gmail.com>
Fri, 12 Dec 2008 23:25:54 +0000 (23:25 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 12 Dec 2008 23:25:54 +0000 (23:25 +0000)
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.

source/blender/blenloader/intern/readfile.c
source/blender/editors/include/UI_view2d.h
source/blender/editors/interface/view2d.c
source/blender/editors/space_ipo/space_ipo.c
source/blender/editors/space_outliner/outliner_header.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/makesdna/DNA_space_types.h

index 7548c9ca97066a9ed2ff5ccbdacde280fafc844d..6172731b425dc5b639428401eb4127d20a3c28ef 100644 (file)
@@ -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:
index 6f379ec3f7bc8a8e4f8e8bbcffe2381370143216..04537ed69b19d3456205813aeba7ff2805350e7f 100644 (file)
 
 
 /* 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)
 
 
 /* ------------------------------------------ */
index 73dd1cdb3ea532509527a73918f0aab5369c0602..66eeb930ab5c8329a0e54ebd269d4419569889e8 100644 (file)
@@ -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));
                }
        }
index 9b119beef639ec2b7ff155c9864608334934b2b8..675becb3308791a20e2e85350be659e2c5c3c43c 100644 (file)
@@ -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);
        
index 87e3253dae9726cf082cc173ce8ec6e9847a9782..2765d80cf8cede59b2b461e8ba0bb52c0215ed68 100644 (file)
@@ -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
        
index 229c473625f3362e4eaa8be594904466f7fed408..7ddcd87d8671ef8b66a85669d4b3861916ac63c7 100644 (file)
@@ -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)
index 3d8047c61000039db09971a1f050579e618261ef..d1af38b9e2554ea1cf9caa1041050ef4e4fd699b 100644 (file)
@@ -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) */