Revision: 17829
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17829
Author:   aligorith
Date:     2008-12-14 09:32:21 +0100 (Sun, 14 Dec 2008)

Log Message:
-----------
View2D: Cosmetic changes and bugfixes

* 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...

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/interface/interface.h
    
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_node/space_node.c
    
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_view2d_types.h

Modified: 
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-14 02:22:29 UTC (rev 17828)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-14 08:32:21 UTC (rev 17829)
@@ -5052,8 +5052,7 @@
        
        /* 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 @@
                                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 @@
                                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 @@
                        {
                                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 @@
                                                        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;

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.h    
2008-12-14 02:22:29 UTC (rev 17828)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.h    
2008-12-14 08:32:21 UTC (rev 17829)
@@ -274,6 +274,7 @@
 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);

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c   
    2008-12-14 02:22:29 UTC (rev 17828)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c   
    2008-12-14 08:32:21 UTC (rev 17829)
@@ -179,19 +179,19 @@
        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 @@
                
                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,36 +224,141 @@
                }
                
                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();
+       glShadeModel(GL_FLAT);
+}
+
 /* plain fake antialiased unfilled round rectangle */
 void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float 
rad, float asp)
 {

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-14 02:22:29 UTC (rev 17828)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-14 08:32:21 UTC (rev 17829)
@@ -57,6 +57,26 @@
 /* *********************************************************************** */
 /* 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 @@
        }
        
        /* 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 @@
        curheight= height= cur->ymax - cur->ymin;
        

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to