Revision: 17871
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17871
Author:   aligorith
Date:     2008-12-15 12:58:57 +0100 (Mon, 15 Dec 2008)

Log Message:
-----------
View2D: Simplification and documentation of settings

I've gone through and simplified some of the redundant options while 
documenting the various settings (in the code and also in the Wiki Doc), to 
make it clearer how to use each option.

'Preset' view-types have yet to be fully implemented, but started groundwork 
for this. Only some commonly used view configurations will be defined using 
this method. For all others, they still need to define all relavent view 
settings themselves (as there's too much variation in terms of the various 
editor's use of View2D).

IPO Editor now draws with channels on the left, like all other anim editors. 
Now, how to make this wider...

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/interface/view2d_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/space_ipo.c
    branches/blender2.5/blender/source/blender/editors/space_nla/space_nla.c
    
branches/blender2.5/blender/source/blender/editors/space_sequencer/space_sequencer.c
    branches/blender2.5/blender/source/blender/editors/space_sound/space_sound.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-15 11:45:17 UTC (rev 17870)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-15 11:58:57 UTC (rev 17871)
@@ -5078,7 +5078,7 @@
                                ar= MEM_callocN(sizeof(ARegion), "area region 
from do_versions");
                                BLI_addtail(lb, ar);
                                ar->regiontype= RGN_TYPE_CHANNELS;
-                               ar->alignment= RGN_ALIGN_RIGHT;
+                               ar->alignment= RGN_ALIGN_LEFT; 
                                
                                break;
                        case SPACE_ACTION:
@@ -5113,7 +5113,7 @@
                                memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
                                
                                ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
-                               ar->v2d.scroll |= 
(V2D_SCROLL_RIGHT|V2D_SCROLL_HORIZONTAL_O);
+                               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|V2D_KEEPASPECT);
                                ar->v2d.keeptot = 2;
@@ -5124,7 +5124,7 @@
                                SpaceTime *stime= (SpaceTime *)sl;
                                memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
                                ar->v2d.keepofs |= V2D_LOCKOFS_Y;
                                ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
@@ -5137,8 +5137,8 @@
                                SpaceIpo *sipo= (SpaceIpo *)sl;
                                memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
-                               ar->v2d.scroll |= 
(V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_LEFT);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
                                break;
                        }
                        case SPACE_SOUND:
@@ -5146,7 +5146,7 @@
                                SpaceSound *ssound= (SpaceSound *)sl;
                                memcpy(&ar->v2d, &ssound->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.scroll |= (V2D_SCROLL_LEFT);
                                break;
                        }
@@ -5155,7 +5155,7 @@
                                SpaceNla *snla= (SpaceNla *)sl;
                                memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
                                break;
                        }
@@ -5164,7 +5164,7 @@
                                SpaceAction *saction= (SpaceAction *)sl;
                                memcpy(&ar->v2d, &saction->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
                                break;
                        }
@@ -5173,8 +5173,8 @@
                                SpaceSeq *sseq= (SpaceSeq *)sl;
                                memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
                                
-                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
-                               ar->v2d.scroll |= 
(V2D_SCROLL_RIGHT|V2D_SCROLL_SCALE_RIGHT);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+                               ar->v2d.scroll |= 
(V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
                                break;
                        }
                        case SPACE_NODE:

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-15 11:45:17 UTC (rev 17870)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-15 11:58:57 UTC (rev 17871)
@@ -35,43 +35,70 @@
 /* ------------------------------------------ */
 /* Settings and Defines:                                       */
 
+/* ---- General Defines ---- */
+
 /* generic value to use when coordinate lies out of view when converting */
 #define V2D_IS_CLIPPED 12000
 
+/* common View2D view types */
+enum {
+               /* custom view type (region has defined all necessary flags 
already) */
+       V2D_COMMONVIEW_CUSTOM = 0,
+               /* listview (i.e. Outliner) */
+       V2D_COMMONVIEW_LIST,
+               /* headers (this is basically the same as listview, but no 
y-panning) */
+       V2D_COMMONVIEW_HEADER,
+} eView2D_CommonViewTypes;
+
+/* ---- Defines for Scroller/Grid Arguments ----- */
+
 /* 'dummy' argument to pass when argument is irrelevant */
 #define V2D_ARG_DUMMY          -1
 
+/* Grid units */
+enum {
+       /* for drawing time */
+       V2D_UNIT_SECONDS = 0,
+       V2D_UNIT_FRAMES,
+       
+       /* for drawing values */
+       V2D_UNIT_VALUES,
+       V2D_UNIT_DEGREES,
+       V2D_UNIT_TIME,
+       V2D_UNIT_SECONDSSEQ,
+} eView2D_Units;
 
-/* grid-units (for drawing time) */
-#define V2D_UNIT_SECONDS       0
-#define V2D_UNIT_FRAMES                1
-
-/* grid-units (for drawing values) */
-#define V2D_UNIT_VALUES                2
-#define V2D_UNIT_DEGREES       3
-#define V2D_UNIT_TIME          4
-#define V2D_UNIT_SECONDSSEQ    5
-
 /* clamping of grid values to whole numbers */
-#define V2D_GRID_NOCLAMP       0
-#define V2D_GRID_CLAMP         1
+enum {
+       V2D_GRID_NOCLAMP = 0,
+       V2D_GRID_CLAMP,
+} eView2D_Clamp;
 
-
 /* 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_FINELINES       (1<<4)
+enum {
+       V2D_HORIZONTAL_LINES            = (1<<0),
+       V2D_VERTICAL_LINES                      = (1<<1),
+       V2D_HORIZONTAL_AXIS                     = (1<<2),
+       V2D_VERTICAL_AXIS                       = (1<<3),
+       V2D_HORIZONTAL_FINELINES        = (1<<4),
+       
+       V2D_GRIDLINES_MAJOR                     = 
(V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS|V2D_HORIZONTAL_LINES|V2D_HORIZONTAL_AXIS),
+       V2D_GRIDLINES_ALL                       = 
(V2D_GRIDLINES_MAJOR|V2D_HORIZONTAL_FINELINES),
+} eView2D_Gridlines;
 
-#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)
+/* ------ Defines for Scrollers ----- */
 
+/* scroller thickness */
+#define V2D_SCROLL_HEIGHT      16
+#define V2D_SCROLL_WIDTH       16
 
+/* half the size (in pixels) of scroller 'handles' */
+#define V2D_SCROLLER_HANDLE_SIZE       5
+
 /* ------------------------------------------ */
 /* Macros:                                                             */
 
-/* test if mouse in a scrollbar */
+/* test if mouse in a scrollbar (assume that scroller availability has been 
tested) */
 #define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1]))
 #define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1]))
 
@@ -92,9 +119,14 @@
 /* Prototypes:                                             */
 
 /* refresh and validation (of view rects) */
+void UI_view2d_regiondata_init(struct View2D *v2d, short type, int winx, int 
winy);
+void UI_view2d_header_default(struct View2D *v2d);
+
 void UI_view2d_size_update(struct View2D *v2d, int winx, int winy);
+
 void UI_view2d_curRect_validate(struct View2D *v2d);
 void UI_view2d_curRect_reset(struct View2D *v2d);
+
 void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
 
 /* view matrix operations */
@@ -121,7 +153,6 @@
 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);

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-15 11:45:17 UTC (rev 17870)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-15 11:58:57 UTC (rev 17871)
@@ -57,26 +57,25 @@
 /* *********************************************************************** */
 /* 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 */
+// eView2D_CommonViewTypes <--- only check handle these types...
 void UI_view2d_regiondata_init(View2D *v2d, short type, int winx, int winy)
 {
        
 }
-#endif
 
+
+/* allowing horizontal pan */
+// XXX this should become one of 'standard' setups...
+void UI_view2d_header_default(View2D *v2d)
+{
+       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;
+       
+}
+
 /* 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...
@@ -614,16 +613,6 @@
        ED_region_pixelspace(C, C->region);
 }
 
-/* allowing horizontal pan */
-void UI_view2d_header_default(View2D *v2d)
-{
-       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;
-       
-}
-
 /* *********************************************************************** */
 /* Gridlines */
 
@@ -915,7 +904,7 @@
         */
        
        /* horizontal scrollers */
-       if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
+       if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
                /* scroller 'button' extents */
                totsize= v2d->tot.xmax - v2d->tot.xmin;
                scrollsize= hor.xmax - hor.xmin;
@@ -1086,7 +1075,7 @@
        hor= v2d->hor;
        
        /* horizontal scrollbar */
-       if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
+       if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
                /* scroller backdrop */
                UI_ThemeColorShade(TH_SHADE1, light);
                glRecti(hor.xmin,  hor.ymin,  hor.xmax,  hor.ymax);

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c   
2008-12-15 11:45:17 UTC (rev 17870)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c   
2008-12-15 11:58:57 UTC (rev 17871)
@@ -72,7 +72,7 @@

@@ 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