Revision: 17802
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17802
Author:   ton
Date:     2008-12-12 17:29:33 +0100 (Fri, 12 Dec 2008)

Log Message:
-----------
2.5

Fixes in view2d:

- mask/slider rects were calculated wrong 1 pixel (was overlapping)
- found bug with outliner stretching on area-edge-dragging. It required
  an extra mapping of the 'cur view' via mask to actual region.
- added v2d sanity check for uninitialized v2d's
- removed cruft in do_versions for headers (gets catched with above)
- added header-view2d-initialize function, for new-space calls

Fixes in areamanager:

- fixes in 'new space' for time/outliner/view2d
  (unfinished)

For Joshua:

- Making time window higher shows it doesn't update 'cur'. Not sure
  what kind of v2d flag should be checked or set?

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/screen/area.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/editors/space_view3d/space_view3d.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-12 11:41:05 UTC (rev 17801)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-12 16:29:33 UTC (rev 17802)
@@ -5051,34 +5051,13 @@
                ar->alignment= RGN_ALIGN_TOP;
        
        /* 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.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;
        
-       ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
-       
-       ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
-       ar->v2d.mask.xmax= sa->winx;
-       ar->v2d.mask.ymax= HEADERY;
-       
-       ar->v2d.cur.xmin= sa->headbutofs;
-       ar->v2d.cur.xmax= sa->winx + sa->headbutofs;
-       ar->v2d.tot.xmin= 0.0f;
-       ar->v2d.tot.xmax= sa->headbutlen;
-       
-       if (ar->alignment == RGN_ALIGN_BOTTOM) {
-               ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
-               ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was 
area->headrct.ymin?
-               ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
-       }
-       else {
-               // XXX what were the extents of the old headers?
-               ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
-               ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was 
area->headrct.ymin?
-               ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
-       }
 }
 
 /* 2.50 patch */

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-12 11:41:05 UTC (rev 17801)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-12 16:29:33 UTC (rev 17802)
@@ -117,8 +117,8 @@
 struct View2D *UI_view2d_fromcontext(const struct bContext *C);
 struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
 void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
+void UI_view2d_header_default(struct View2D *v2d);
 
-
 /* operators */
 void ui_view2d_operatortypes(void);
 void UI_view2d_keymap(struct wmWindowManager *wm);

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-12 11:41:05 UTC (rev 17801)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-12 16:29:33 UTC (rev 17802)
@@ -35,6 +35,8 @@
 #include "DNA_space_types.h"
 #include "DNA_view2d_types.h"
 
+#include "BLI_blenlib.h"
+
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
 
@@ -62,10 +64,13 @@
 // XXX pre2.5 -> this used to be called  calc_scrollrcts()
 void UI_view2d_size_update(View2D *v2d, int winx, int winy)
 {
+       v2d->winx= winx;
+       v2d->winy= winy;
+       
        /* mask - view frame */
        v2d->mask.xmin= v2d->mask.ymin= 0;
-       v2d->mask.xmax= winx;
-       v2d->mask.ymax= winy;
+       v2d->mask.xmax= winx - 1;       /* -1 yes! masks are pixels */
+       v2d->mask.ymax= winy - 1;
        
        /* scrollbars shrink mask area, but should be based off regionsize 
         *      - they can only be on one edge of the region they define
@@ -76,13 +81,13 @@
                        /* on left-hand edge of region */
                        v2d->vert= v2d->mask;
                        v2d->vert.xmax= V2D_SCROLL_WIDTH;
-                       v2d->mask.xmin= V2D_SCROLL_WIDTH;
+                       v2d->mask.xmin= v2d->vert.xmax + 1;
                }
                else if (v2d->scroll & V2D_SCROLL_RIGHT) {
                        /* on right-hand edge of region */
                        v2d->vert= v2d->mask;
                        v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
-                       v2d->mask.xmax= v2d->vert.xmin;
+                       v2d->mask.xmax= v2d->vert.xmin - 1;
                }
                
                /* horizontal scrollbar */
@@ -90,16 +95,29 @@
                        /* on bottom edge of region (V2D_SCROLL_BOTTOM_O is 
outliner, the ohter is for standard) */
                        v2d->hor= v2d->mask;
                        v2d->hor.ymax= V2D_SCROLL_HEIGHT;
-                       v2d->mask.ymin= V2D_SCROLL_HEIGHT;
+                       v2d->mask.ymin= v2d->hor.ymax + 1;
                }
                else if (v2d->scroll & V2D_SCROLL_TOP) {
                        /* on upper edge of region */
                        v2d->hor= v2d->mask;
                        v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
-                       v2d->mask.ymax= v2d->hor.ymin;
+                       v2d->mask.ymax= v2d->hor.ymin - 1;
                }
        }
        
+       /* cope with unitialized veriables for simple cases, like header or 
outliner */
+       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);
+                       BLI_init_rctf(&v2d->cur, v2d->mask.xmin, 
v2d->mask.xmax, v2d->mask.ymin, v2d->mask.ymax);
+                       
+                       v2d->min[0]= v2d->max[0]= winx;
+                       v2d->min[1]= v2d->max[1]= winy;
+                       v2d->minzoom= 1.0f;
+                       v2d->maxzoom= 1.0f;
+               }
+       }
+       
        /* make sure that 'cur' rect is in a valid state as a result of these 
changes */
        UI_view2d_curRect_validate(v2d);
 }
@@ -372,6 +390,7 @@
                        }
                }
        }
+       
 }
 
 /* ------------------ */
@@ -476,15 +495,41 @@
 /* *********************************************************************** */
 /* View Matrix Setup */
 
+/* mapping function to ensure 'cur' draws extended over the area were sliders 
are */
+static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
+{
+       *curmasked= v2d->cur;
+       
+       if (v2d->scroll) {
+               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);
+               
+               if (v2d->mask.xmin != 0)
+                       curmasked->xmin -= dx*(float)v2d->mask.xmin;
+               if (v2d->mask.xmax+1 != v2d->winx)
+                       curmasked->xmax += dx*(float)(v2d->winx - 
v2d->mask.xmax-1);
+               
+               if (v2d->mask.ymin != 0)
+                       curmasked->ymin -= dy*(float)v2d->mask.ymin;
+               if (v2d->mask.ymax+1 != v2d->winy)
+                       curmasked->ymax += dy*(float)(v2d->winy - 
v2d->mask.ymax-1);
+               
+       }
+}
+
 /* 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
- */
+*      - this assumes viewport/scissor been set for the region, taking 
scrollbars into account
+*/
+
 void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
 {
+       rctf curmasked;
+       
        /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are 
not applied, 
         * as they were causing some unwanted offsets when drawing 
         */
-       wmOrtho2(C->window, v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin, 
v2d->cur.ymax);
+       view2d_map_cur_using_mask(v2d, &curmasked);
+       wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, curmasked.ymin, 
curmasked.ymax);
        
        /* XXX is this necessary? */
        wmLoadIdentity(C->window);
@@ -498,14 +543,16 @@
 void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
 {
        ARegion *ar= C->region;
+       rctf curmasked;
        
        /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are 
not applied, 
         * as they were causing some unwanted offsets when drawing 
         */
+       view2d_map_cur_using_mask(v2d, &curmasked);
        if (xaxis)
-               wmOrtho2(C->window, v2d->cur.xmin, v2d->cur.xmax, 0, ar->winy);
+               wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, 0, 
ar->winy);
        else
-               wmOrtho2(C->window, 0, ar->winx, v2d->cur.ymin, v2d->cur.ymax);
+               wmOrtho2(C->window, 0, ar->winx, curmasked.ymin, 
curmasked.ymax);
                
        /* XXX is this necessary? */
        wmLoadIdentity(C->window);
@@ -518,6 +565,17 @@
        ED_region_pixelspace(C, C->region);
 }
 
+/* allowing horizontal pan */
+void UI_view2d_header_default(View2D *v2d)
+{
+       v2d->keepaspect= 1;
+       v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM);
+       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;
+       
+}
+
 /* *********************************************************************** */
 /* Gridlines */
 

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c    
2008-12-12 11:41:05 UTC (rev 17801)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c    
2008-12-12 16:29:33 UTC (rev 17802)
@@ -229,12 +229,12 @@
                        ar->winrct= *remainder;
                        
                        if(ar->alignment==RGN_ALIGN_TOP) {
-                               ar->winrct.ymin= ar->winrct.ymax - prefsizey;
-                               remainder->ymax= ar->winrct.ymin-1;
+                               ar->winrct.ymin= ar->winrct.ymax - prefsizey + 
1;
+                               remainder->ymax= ar->winrct.ymin - 1;
                        }
                        else {
-                               ar->winrct.ymax= ar->winrct.ymin + prefsizey;
-                               remainder->ymin= ar->winrct.ymax+1;
+                               ar->winrct.ymax= ar->winrct.ymin + prefsizey - 
1;
+                               remainder->ymin= ar->winrct.ymax + 1;
                        }
                }
        }
@@ -252,12 +252,12 @@
                        ar->winrct= *remainder;
                        
                        if(ar->alignment==RGN_ALIGN_RIGHT) {
-                               ar->winrct.xmin= ar->winrct.xmax - prefsizex;
-                               remainder->xmax= ar->winrct.xmin-1;
+                               ar->winrct.xmin= ar->winrct.xmax - prefsizex + 
1;
+                               remainder->xmax= ar->winrct.xmin - 1;
                        }
                        else {
-                               ar->winrct.xmax= ar->winrct.xmin + prefsizex;
-                               remainder->xmin= ar->winrct.xmax+1;
+                               ar->winrct.xmax= ar->winrct.xmin + prefsizex - 
1;
+                               remainder->xmin= ar->winrct.xmax + 1;
                        }
                }
        }
@@ -545,8 +545,8 @@
                                sl->regionbase.first= sl->regionbase.last= NULL;
                        }
                }
+               
        }
-       
 }
 
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
  2008-12-12 11:41:05 UTC (rev 17801)
+++ 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
  2008-12-12 16:29:33 UTC (rev 17802)
@@ -480,10 +480,32 @@
 
 static SpaceLink *outliner_new(void)
 {
+       ARegion *ar;
        SpaceOops *soutliner;
 
        soutliner= MEM_callocN(sizeof(SpaceOops), "initoutliner");
 
+       /* header */
+       ar= MEM_callocN(sizeof(ARegion), "header for outliner");
+       
+       BLI_addtail(&soutliner->regionbase, ar);
+       ar->regiontype= RGN_TYPE_HEADER;
+       ar->alignment= RGN_ALIGN_BOTTOM;
+       UI_view2d_header_default(&ar->v2d);
+       
+       /* main area */
+       ar= MEM_callocN(sizeof(ARegion), "main area for outliner");
+       
+       BLI_addtail(&soutliner->regionbase, ar);
+       ar->regiontype= RGN_TYPE_WINDOW;
+       
+       ar->v2d.scroll |= V2D_SCROLL_RIGHT;
+       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;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to