View2D: Cosmetic changes and bugfixes
authorJoshua Leung <aligorith@gmail.com>
Sun, 14 Dec 2008 08:32:21 +0000 (08:32 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 14 Dec 2008 08:32:21 +0000 (08:32 +0000)
* Scrollers now draw using nice rounded+shaded style everywhere

* When scrollers 'bubble' completely fills a scroller or is completely out of view, the view zooming using the handles is now only activated if the mouse is within a quarter of the total length of the scroller on either end of the scroller. Otherwise, pan is activated. This should make the scrollers more usable in anim editors.

* Fixed drawing of gridlines in TimeLine - needed to adjust ymin value of cur and tot rects to accomodate for the new mask/cur adjustments as old TimeLines didn't draw with 'real' scrollbars. Also, adjusted min/max values to fit these new tot/cur rect y-sizes.

* Tidying up vars and fixing errors in declaring new View2D types in preparation for simpler method of initialising views...

source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface.h
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_time/space_time.c
source/blender/makesdna/DNA_view2d_types.h

index a2b08e4890ba3cc549ef55a44d55405d2fc98062..93cacaf61a1a108a309d2327d6d70cf43c7da06a 100644 (file)
@@ -5052,8 +5052,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
        
        /* initialise view2d data for header region, to allow panning */
        /* is copy from ui_view2d.c */
-       ar->v2d.keepaspect= 1;
-       ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM);
+       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.align = V2D_ALIGN_NO_NEG_X;
@@ -5101,9 +5100,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
                                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.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT);
                                ar->v2d.keeptot = 2;
-                               ar->v2d.keepaspect= 1;
                        }
                                break;
                        case SPACE_TIME:
@@ -5115,7 +5113,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
                                ar->v2d.keepofs |= V2D_LOCKOFS_Y;
                                ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
-                               ar->v2d.min[1]= ar->v2d.max[1]= 500.0;
+                               ar->v2d.tot.ymin= ar->v2d.cur.ymin= -10.0;
+                               ar->v2d.min[1]= ar->v2d.max[1]= 20.0;
                        }
                                break;
                        case SPACE_IPO:
@@ -5137,6 +5136,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;
                                break;
                        }
                                //case SPACE_XXX: // FIXME... add other ones
@@ -7439,8 +7439,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        simasel->v2d.minzoom= 0.5f;
                                                        simasel->v2d.maxzoom= 1.21f;                                            
                                                        simasel->v2d.scroll= 0;
-                                                       simasel->v2d.keepaspect= 1;
-                                                       simasel->v2d.keepzoom= 1;
+                                                       simasel->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT;
                                                        simasel->v2d.keeptot= 0;
                                                        simasel->prv_h = 96;
                                                        simasel->prv_w = 96;
index 330639cce93de2a6cf92837920e4dfb3313757f6..fac72b2208925e55cbf7998b76935e46b21ccae8 100644 (file)
@@ -274,6 +274,7 @@ extern void ui_do_panel(uiBlock *block, uiEvent *uevent);
 extern void ui_scale_panel(uiBlock *block);
 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
+extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
 
 /* interface_draw.c */
 extern void ui_set_embossfunc(uiBut *but, int drawtype);
index 6fe7a166b7ff0ba7a4e4a32a93e35b77a1bdfc3e..613c0b1c3b20605239659d79f3b24ffabde04450 100644 (file)
@@ -179,19 +179,19 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
        if(roundboxtype & 4) {
                
                round_box_shade_col(coltop, coldown, 0.0);
-               glVertex2f( maxx-rad, miny);
+               glVertex2f(maxx-rad, miny);
                
                for(a=0; a<7; a++) {
                        round_box_shade_col(coltop, coldown, vec[a][1]/div);
-                       glVertex2f( maxx-rad+vec[a][0], miny+vec[a][1]);
+                       glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
                }
                
                round_box_shade_col(coltop, coldown, rad/div);
-               glVertex2f( maxx, miny+rad);
+               glVertex2f(maxx, miny+rad);
        }
        else {
                round_box_shade_col(coltop, coldown, 0.0);
-               glVertex2f( maxx, miny);
+               glVertex2f(maxx, miny);
        }
        
        /* corner right-top */
@@ -202,14 +202,14 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
                
                for(a=0; a<7; a++) {
                        round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div);
-                       glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
+                       glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
                }
                round_box_shade_col(coltop, coldown, 1.0);
-               glVertex2f( maxx-rad, maxy);
+               glVertex2f(maxx-rad, maxy);
        }
        else {
                round_box_shade_col(coltop, coldown, 1.0);
-               glVertex2f( maxx, maxy);
+               glVertex2f(maxx, maxy);
        }
        
        /* corner left-top */
@@ -224,30 +224,135 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
                }
                
                round_box_shade_col(coltop, coldown, (div-rad)/div);
-               glVertex2f( minx, maxy-rad);
+               glVertex2f(minx, maxy-rad);
        }
        else {
                round_box_shade_col(coltop, coldown, 1.0);
-               glVertex2f( minx, maxy);
+               glVertex2f(minx, maxy);
        }
        
        /* corner left-bottom */
        if(roundboxtype & 8) {
                
                round_box_shade_col(coltop, coldown, rad/div);
-               glVertex2f( minx, miny+rad);
+               glVertex2f(minx, miny+rad);
                
                for(a=0; a<7; a++) {
                        round_box_shade_col(coltop, coldown, (rad-vec[a][1])/div);
-                       glVertex2f( minx+vec[a][1], miny+rad-vec[a][0]);
+                       glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
                }
                
                round_box_shade_col(coltop, coldown, 0.0);
-               glVertex2f( minx+rad, miny);
+               glVertex2f(minx+rad, miny);
        }
        else {
                round_box_shade_col(coltop, coldown, 0.0);
-               glVertex2f( minx, miny);
+               glVertex2f(minx, miny);
+       }
+       
+       glEnd();
+       glShadeModel(GL_FLAT);
+}
+
+/* linear vertical shade within button or in outline */
+void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight)
+{
+       float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+                         {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+       float div= maxx-minx;
+       float colLeft[3], colRight[3], color[4];
+       int a;
+       
+       /* mult */
+       for(a=0; a<7; a++) {
+               vec[a][0]*= rad; vec[a][1]*= rad;
+       }
+       /* get current color, needs to be outside of glBegin/End */
+       glGetFloatv(GL_CURRENT_COLOR, color);
+
+       /* 'shade' defines strength of shading */       
+       colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0) colLeft[0]= 1.0;
+       colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0) colLeft[1]= 1.0;
+       colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0) colLeft[2]= 1.0;
+       colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0) colRight[0]= 0.0;
+       colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0) colRight[1]= 0.0;
+       colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0) colRight[2]= 0.0;
+
+       if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) {
+               glShadeModel(GL_SMOOTH);
+               glBegin(mode);
+       }
+
+       /* start with corner right-bottom */
+       if(roundboxtype & 4) {
+               round_box_shade_col(colLeft, colRight, 0.0);
+               glVertex2f(maxx-rad, miny);
+               
+               for(a=0; a<7; a++) {
+                       round_box_shade_col(colLeft, colRight, vec[a][0]/div);
+                       glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
+               }
+               
+               round_box_shade_col(colLeft, colRight, rad/div);
+               glVertex2f(maxx, miny+rad);
+       }
+       else {
+               round_box_shade_col(colLeft, colRight, 0.0);
+               glVertex2f(maxx, miny);
+       }
+       
+       /* corner right-top */
+       if(roundboxtype & 2) {
+               round_box_shade_col(colLeft, colRight, 0.0);
+               glVertex2f(maxx, maxy-rad);
+               
+               for(a=0; a<7; a++) {
+                       
+                       round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])/div);
+                       glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
+               }
+               round_box_shade_col(colLeft, colRight, (div-rad)/div);
+               glVertex2f(maxx-rad, maxy);
+       }
+       else {
+               round_box_shade_col(colLeft, colRight, 0.0);
+               glVertex2f(maxx, maxy);
+       }
+       
+       /* corner left-top */
+       if(roundboxtype & 1) {
+               round_box_shade_col(colLeft, colRight, (div-rad)/div);
+               glVertex2f(minx+rad, maxy);
+               
+               for(a=0; a<7; a++) {
+                       round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])/div);
+                       glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]);
+               }
+               
+               round_box_shade_col(colLeft, colRight, 1.0);
+               glVertex2f(minx, maxy-rad);
+       }
+       else {
+               round_box_shade_col(colLeft, colRight, 1.0);
+               glVertex2f(minx, maxy);
+       }
+       
+       /* corner left-bottom */
+       if(roundboxtype & 8) {
+               round_box_shade_col(colLeft, colRight, 1.0);
+               glVertex2f(minx, miny+rad);
+               
+               for(a=0; a<7; a++) {
+                       round_box_shade_col(colLeft, colRight, (vec[a][0])/div);
+                       glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
+               }
+               
+               round_box_shade_col(colLeft, colRight, 1.0);
+               glVertex2f(minx+rad, miny);
+       }
+       else {
+               round_box_shade_col(colLeft, colRight, 1.0);
+               glVertex2f(minx, miny);
        }
        
        glEnd();
index 95e68ee89f02026a514ae2ca6093bc922bdbfc6b..4a762b9a778220fc9b506934ba7c480cad60f8a3 100644 (file)
 /* *********************************************************************** */
 /* Refresh and Validation */
 
+#if 0 // experimental code - not ready to be used yet!
+/* common View2D view types */
+// XXX move this to header as part of API
+enum {
+               /* 4 quadrants, centered at (0,0), zoomable and pannable, best for flexible sized data with precision needed */
+       V2D_VIEWTYPE_CANVAS     = 0,
+       V2D_VIEWTYPE_LIST,
+       V2D_VIEWTYPE_PANEL,
+               /* same as canvas, except aspect ratio is important */
+               // XXX is this more of the sort tweaks that region should do to its view2d data first?
+       V2D_VIEWTYPE_IMAGE,
+} eView2D_CommonViewTypes;
+
+/* Initialise all View2D data for a given region */
+void UI_view2d_regiondata_init(View2D *v2d, short type, int winx, int winy)
+{
+       
+}
+#endif
+
 /* 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...
@@ -106,6 +126,7 @@ 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) {
                        BLI_init_rctf(&v2d->tot, v2d->mask.xmin, v2d->mask.xmax, v2d->mask.ymin, v2d->mask.ymax);
@@ -157,10 +178,14 @@ void UI_view2d_curRect_validate(View2D *v2d)
        curheight= height= cur->ymax - cur->ymin;
        
        /* if zoom is locked, size on the appropriate axis is reset to mask size */
-       if (v2d->keepzoom & V2D_LOCKZOOM_X)
-               width= winx;
-       if (v2d->keepzoom & V2D_LOCKZOOM_Y)
-               height= winy;
+       if (v2d->keepzoom & V2D_LOCKZOOM_X) {
+               cur->xmax= cur->xmin + winx;
+               curwidth= width= winx;
+       }
+       if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
+               cur->ymax= cur->ymin + winy;
+               curheight= height= winy;
+       }
                
        /* keepzoom (V2D_KEEPZOOM set), indicates that zoom level on each axis must not exceed limits 
         * NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this
@@ -193,7 +218,7 @@ void UI_view2d_curRect_validate(View2D *v2d)
        }
        
        /* check if we should restore aspect ratio (if view size changed) */
-       if (v2d->keepaspect) {
+       if (v2d->keepzoom & V2D_KEEPASPECT) {
                short do_x=0, do_y=0, do_cur, do_win;
                float curRatio, winRatio;
                
@@ -336,20 +361,32 @@ void UI_view2d_curRect_validate(View2D *v2d)
                                cur->ymin= temp - diff;
                                cur->ymax= temp + diff;
                        }
-                       else if (cur->xmin > tot->xmin) {
-                               /* there's still space remaining, so shift left */
-                               temp= cur->xmin - tot->xmin;
-                               
-                               cur->xmin -= temp;
-                               cur->xmax -= temp;
-                       }
-                       else if (cur->xmax < tot->xmax) {
-                               /* there's still space remaining, so shift right */
-                               temp= tot->xmax - cur->xmax;
+                       else if (cur->xmin < tot->xmin) {
+                               /* move cur across so that it sits at minimum of tot */
+                               temp= tot->xmin - cur->xmin;
                                
                                cur->xmin += temp;
                                cur->xmax += temp;
                        }
+                       else if (cur->xmax > tot->xmax) {
+                               /* - only offset by difference of cur-xmax and tot-xmax if that would not move 
+                                *      cur-xmin to lie past tot-xmin
+                                * - otherwise, simply shift to tot-xmin???
+                                */
+                               temp= cur->xmax - tot->xmax;
+                               
+                               if ((cur->xmin - temp) < tot->xmin) {
+                                       /* only offset by difference from cur-min and tot-min */
+                                       temp= cur->xmin - tot->xmin;
+                                       
+                                       cur->xmin -= temp;
+                                       cur->xmax -= temp;
+                               }
+                               else {
+                                       cur->xmin -= temp;
+                                       cur->xmax -= temp;
+                               }
+                       }
                }
                
                /* height */
@@ -570,8 +607,7 @@ void UI_view2d_view_restore(const bContext *C)
 /* allowing horizontal pan */
 void UI_view2d_header_default(View2D *v2d)
 {
-       v2d->keepaspect= 1;
-       v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM);
+       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;
@@ -1017,13 +1053,18 @@ static void scroll_printstr(View2DScrollers *scrollers, float x, float y, float
        UI_DrawString(G.fonts, str, 0); // XXX check this again when new text-drawing api is done
 }
 
-/* local define for radius of scroller 'button' caps */
-#define V2D_SCROLLCAP_RAD      5
+/* local defines for scrollers drawing */
+       /* radius of scroller 'button' caps */
+#define V2D_SCROLLCAP_RAD              5
+       /* shading factor for scroller 'bar' */
+#define V2D_SCROLLBAR_SHADE            0.1f
+       /* shading factor for scroller 'button' caps */
+#define V2D_SCROLLCAP_SHADE            0.2f
 
 /* Draw scrollbars in the given 2d-region */
 void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
 {
-       const int darker= -50, dark= -10, light= 20, lighter= 50;
+       const short darker= -50, dark= -10, light= 20, lighter= 50;
        rcti vert, hor;
        
        /* make copies of rects for less typing */
@@ -1043,41 +1084,54 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                if (v2d->keepzoom & V2D_LOCKZOOM_X) {
                        /* draw base bar as rounded shape */
                        UI_ThemeColorShade(TH_SHADE1, dark);
-                       
                        uiSetRoundBox(15);
-                       gl_round_box_shade(GL_POLYGON, 
+                       
+                       /* check that box is large enough for round drawing */
+                       if ((vs->hor_max - vs->hor_min) < (V2D_SCROLLCAP_RAD * 2)) {
+                               /* Rounded box still gets drawn at the minimum size limit
+                                * This doesn't represent extreme scaling well, but looks nicer...
+                                */
+                               float mid= 0.5f * (vs->hor_max + vs->hor_min);
+                               
+                               gl_round_box_shade(GL_POLYGON, 
+                                       mid-V2D_SCROLLCAP_RAD, hor.ymin+2, 
+                                       mid+V2D_SCROLLCAP_RAD, hor.ymax-2, 
+                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
+                       }
+                       else {
+                               /* draw rounded box as per normal */
+                               gl_round_box_shade(GL_POLYGON, 
                                        vs->hor_min, hor.ymin+2, 
                                        vs->hor_max, hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, 0.05f, -0.05f);
+                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
+                       }
                }
                else {
                        /* base bar drawn as shaded rect */
                        UI_ThemeColorShade(TH_SHADE1, dark);
                        uiSetRoundBox(0);
                        gl_round_box_shade(GL_POLYGON, 
-                                       vs->hor_min, hor.ymin+2, 
-                                       vs->hor_max, hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, 0.05f, -0.05f);
-                       
-                       /* handles draw darker */
-                       // XXX handles are drawn with the two last args set to same values, otherwise, max appears darker than min
-                       UI_ThemeColorShade(TH_SHADE1, darker);
+                               vs->hor_min, hor.ymin+2, 
+                               vs->hor_max, hor.ymax-2, 
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
                        
                        /* 'minimum' handle */
                        uiSetRoundBox(9);
+                       UI_ThemeColorShade(TH_SHADE1, darker);
+                       
                        gl_round_box_shade(GL_POLYGON, 
-                                       vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, 
-                                       vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, 0.07f, -0.07f);
-                                       //V2D_SCROLLCAP_RAD, 0, 0);
+                               vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, 
+                               vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, 
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
                        
                        /* maximum handle */
                        uiSetRoundBox(6);
+                       UI_ThemeColorShade(TH_SHADE1, darker);
+                       
                        gl_round_box_shade(GL_POLYGON, 
-                                       vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, 
-                                       vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, 0.07f, -0.07f);
-                                       //V2D_SCROLLCAP_RAD, 0, 0);
+                               vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, 
+                               vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, 
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
                }
                
                /* scale indicators */
@@ -1162,41 +1216,57 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                 *      - if view is zoomable in y, draw handles too 
                 *      - handles are drawn darker
                 */
-               // XXX gl_round_box_shade is currently hardcoded to do horizontal buts only... need a vertical region
                if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
                        /* draw base bar as rounded shape */
                        UI_ThemeColorShade(TH_SHADE1, dark);
-                       
                        uiSetRoundBox(15);
-                       gl_round_box_shade(GL_POLYGON, 
+                       
+                       /* check that box is large enough for round drawing */
+                       if ((vs->vert_max - vs->vert_min) < (V2D_SCROLLCAP_RAD * 2)) {
+                               /* Rounded box still gets drawn at the minimum size limit
+                                * This doesn't represent extreme scaling well, but looks nicer...
+                                */
+                               float mid= 0.5f * (vs->vert_max + vs->vert_min);
+                               
+                               gl_round_box_vertical_shade(GL_POLYGON, 
+                                       vert.xmin+2, mid-V2D_SCROLLCAP_RAD, 
+                                       vert.xmax-2, mid+V2D_SCROLLCAP_RAD, 
+                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
+                       }
+                       else {
+                               /* draw rounded box as per normal */
+                               gl_round_box_vertical_shade(GL_POLYGON, 
                                        vert.xmin+2, vs->vert_min, 
                                        vert.xmax-2, vs->vert_max, 
-                                       V2D_SCROLLCAP_RAD, 0.05f, -0.05f);
+                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
+                       }
                }
                else {
-                       /* for now, draw base bar as unshaded rect */
-                       // FIXME: this should be shaded horizontally too
+                       /* base bar drawn as shaded rect */
                        UI_ThemeColorShade(TH_SHADE1, dark);
-                       glRecti(vert.xmin+2, vs->vert_min,  
-                                       vert.xmax-2, vs->vert_max);
-                       
-                       /* handles draw darker */
-                       // XXX handles are drawn with the two last args set to same values, otherwise, max appears darker than min
-                       UI_ThemeColorShade(TH_SHADE1, darker);
+                       uiSetRoundBox(0);
+                       gl_round_box_vertical_shade(GL_POLYGON, 
+                               vert.xmin+2, vs->vert_min, 
+                               vert.xmax-2, vs->vert_max,
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
                        
                        /* 'minimum' handle */
+                       UI_ThemeColorShade(TH_SHADE1, darker);
                        uiSetRoundBox(12);
-                       gl_round_box_shade(GL_POLYGON, 
-                                       vert.xmin+2, vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, 
-                                       vert.xmax-2, vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, 
-                                       V2D_SCROLLCAP_RAD, 0, 0);
+                       
+                       gl_round_box_vertical_shade(GL_POLYGON, 
+                               vert.xmin+2, vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, 
+                               vert.xmax-2, vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, 
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
                        
                        /* maximum handle */
+                       UI_ThemeColorShade(TH_SHADE1, darker);
                        uiSetRoundBox(3);
-                       gl_round_box_shade(GL_POLYGON, 
-                                       vert.xmin+2, vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, 
-                                       vert.xmax-2, vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, 
-                                       V2D_SCROLLCAP_RAD, 0, 0);
+                       
+                       gl_round_box_vertical_shade(GL_POLYGON, 
+                               vert.xmin+2, vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, 
+                               vert.xmax-2, vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, 
+                               V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
                }
                
                /* scale indiators */
index 42b7515e2075ce0ab5af71fb4ce8f673792c8383..0564e6436a77a5311c6af8c8de174db3016ee58f 100644 (file)
@@ -878,11 +878,15 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
                 ((sh_min <= sc_min) && (sh_max <= sc_max)) ||
                 ((sh_min >= sc_max) && (sh_max >= sc_max)) ) 
        {
-               /* use midpoint to determine which handle to use (favour 'max' handle) */
-               if (mouse >= ((sc_max + sc_min) / 2)) 
+               /* handles are only activated if the mouse is within the relative quater lengths of the scroller */
+               int qLen = (sc_max + sc_min) / 4;
+               
+               if (mouse >= (sc_max - qLen))
                        return SCROLLHANDLE_MAX;
-               else
+               else if (mouse <= qLen)
                        return SCROLLHANDLE_MIN;
+               else
+                       return SCROLLHANDLE_BAR;
        }
        
        /* check if mouse is in or past either handle */
@@ -894,12 +898,11 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
                return SCROLLHANDLE_BAR;
        if (in_max)
                return SCROLLHANDLE_MAX;
-       else if (in_min)
+       if (in_min)
                return SCROLLHANDLE_MIN;
                
        /* unlikely to happen, though we just cover it in case */
-       else
-               return SCROLLHANDLE_BAR;
+       return SCROLLHANDLE_BAR;
 } 
 
 /* initialise customdata for scroller manipulation operator */
index ccc8f18d983bf7ac937469b36676010e87863610..9fc7ca123dc3db9a6b3892155662a5da9e872409 100644 (file)
@@ -101,9 +101,8 @@ static SpaceLink *buttons_new(void)
        sbuts->v2d.minzoom= 0.5f;
        sbuts->v2d.maxzoom= 1.21f;
        
-       sbuts->v2d.scroll= 0;
-       sbuts->v2d.keepaspect= 1;
-       sbuts->v2d.keepzoom= 1;
+       sbuts->v2d.scroll= 0;  // TODO: will we need scrollbars?
+       sbuts->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT;
        sbuts->v2d.keeptot= 1;
        sbuts->v2d.cur= sbuts->v2d.tot;
        
index 76d1034762cb56e7c078fac66956056cf3aa7be9..6569200196ccaea1a28a45404274679b8c96d23a 100644 (file)
@@ -103,8 +103,7 @@ static SpaceLink *node_new(void)
        ar->v2d.maxzoom= 1.21f;
        
        ar->v2d.scroll= 0;
-       ar->v2d.keepaspect= 1;
-       ar->v2d.keepzoom= 1;
+       ar->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT;
        ar->v2d.keeptot= 0;
        
        
index 7ddcd87d8671ef8b66a85669d4b3861916ac63c7..c687ca179079a42ed70fb9189f7abed622dcc5bb 100644 (file)
@@ -484,11 +484,9 @@ static SpaceLink *outliner_new(void)
        BLI_addtail(&soutliner->regionbase, ar);
        ar->regiontype= RGN_TYPE_WINDOW;
        
-       ar->v2d.scroll |= V2D_SCROLL_RIGHT;
+       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);
-       ar->v2d.keepaspect= 1;
-       ar->v2d.keepzoom= 1;
+       ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
        ar->v2d.keeptot= 2;     /* XXX make define */
        
        return (SpaceLink*)soutliner;
index 728beae364ee9d5fd00d8fd719752e200d540f83..9ed69979dbafa85fe2d1ca5f05615e75149ee485 100644 (file)
@@ -223,17 +223,17 @@ static SpaceLink *time_new(void)
        ar->regiontype= RGN_TYPE_WINDOW;
        
        ar->v2d.tot.xmin= -4.0;
-       ar->v2d.tot.ymin=  0.0;
+       ar->v2d.tot.ymin= -10.0;
        ar->v2d.tot.xmax= (float)EFRA + 4.0;
        ar->v2d.tot.ymax= 10;
 
        ar->v2d.cur= ar->v2d.tot;
 
        ar->v2d.min[0]= 1.0;
-       ar->v2d.min[1]= 500.0; /* XXX */
+       ar->v2d.min[1]= 20.0; /* XXX */
 
        ar->v2d.max[0]= 32000.0;
-       ar->v2d.max[1]= 500;   /* XXX */
+       ar->v2d.max[1]= 20;   /* XXX */
 
        ar->v2d.minzoom= 0.1f;
        ar->v2d.maxzoom= 10.0;
@@ -241,6 +241,7 @@ static SpaceLink *time_new(void)
        ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
        ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
        ar->v2d.keepofs |= V2D_LOCKOFS_Y;
+       ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
 
        return (SpaceLink*)stime;
 }
index e60fe90fbb92c7ff1b280514582f3a99e81bd81a..986996e43416bfb6cef7341b745fec8bfbba440b 100644 (file)
@@ -46,12 +46,12 @@ typedef struct View2D {
        
        short scroll;                                   /* scroll - scrollbars to display (bitflag) */
        short keeptot;                                  /* keeptot - 'cur' rect cannot move outside the 'tot' rect? */
-       short keepaspect;                               /* keepaspect - need to maintain aspect ratio (0 or 1 boolean only) */
        short keepzoom;                                 /* keepzoom - axes that zooming cannot occur on, and also clamp within zoom-limits */
        short keepofs;                                  /* keepofs - axes that translation is not allowed to occur on */
        
        short flag;                                             /* settings */
        short align;                                    /* alignment of content in totrect */
+       short type;                                             /* basic 'type' of View2D (for easy init) */ // err... do we want to store this?
        
        short winx, winy;                               /* storage of current winx/winy values, set in UI_view2d_size_update */
        short oldwinx, oldwiny;                 /* storage of previous winx/winy values encountered by UI_view2d_curRect_validate(), for keepaspect */
@@ -64,6 +64,7 @@ typedef struct View2D {
 
 /* view zooming restrictions, per axis (v2d->keepzoom) */
 #define V2D_KEEPZOOM           0x0001
+#define V2D_KEEPASPECT         0x0002
 #define V2D_LOCKZOOM_X         0x0100
 #define V2D_LOCKZOOM_Y         0x0200