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

Log Message:
-----------
View2D - Vertical (within area) syncing for channel lists to stay in sync with 
the relevant keyframes...

I still need to work out how to get this to work correctly as soon as an Action 
Editor instance is created.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_ops.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_time/time_header.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-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-21 11:56:42 UTC (rev 17990)
@@ -5102,6 +5102,7 @@
                                ar->regiontype= RGN_TYPE_CHANNELS;
                                ar->alignment= RGN_ALIGN_LEFT;
                                ar->v2d.scroll= V2D_SCROLL_BOTTOM;
+                               ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
                                break;
                        case SPACE_NLA:
                                ar= MEM_callocN(sizeof(ARegion), "area region 
from do_versions");
@@ -5179,6 +5180,7 @@
                                ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
                                ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+                               ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
                                //ar->v2d.flag |= V2D_IS_INITIALISED;
                                break;
                        }
@@ -5190,6 +5192,7 @@
                                ar->v2d.scroll |= 
(V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
                                ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
                                ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+                               ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
                                //ar->v2d.flag |= V2D_IS_INITIALISED;
                                break;
                        }

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c     
2008-12-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c     
2008-12-21 11:56:42 UTC (rev 17990)
@@ -228,11 +228,11 @@
        float sfra, efra;
        int xmin, xmax;
        
-       /* convert min/max values from borderselect to region coordinates */
-       xmin= RNA_int_get(op->ptr, "xmin")/* - ar->winrct.xmin*/;
-       xmax= RNA_int_get(op->ptr, "xmax")/* - ar->winrct.xmin*/;
+       /* get min/max values from border select rect (already in region 
coordinates, not screen) */
+       xmin= RNA_int_get(op->ptr, "xmin");
+       xmax= RNA_int_get(op->ptr, "xmax");
        
-       /* convert min/max values to frames */
+       /* convert min/max values to frames (i.e. region to 'tot' rect) */
        UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL);
        UI_view2d_region_to_view(&ar->v2d, xmax, 0, &efra, NULL);
        
@@ -244,10 +244,10 @@
        if (efra < 1) efra = 1.0f;
        if (efra < sfra) efra= sfra;
        
-       scene->r.psfra= (int)sfra;
-       scene->r.pefra= (int)efra;
+       scene->r.psfra= (int)floor(sfra + 0.5f);
+       scene->r.pefra= (int)floor(efra + 0.5f);
        
-       //BIF_undo_push("Clear Preview Range");
+       //BIF_undo_push("Set Preview Range");
        
        return OPERATOR_FINISHED;
 } 

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-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-21 11:56:42 UTC (rev 17990)
@@ -125,6 +125,7 @@
 
 struct wmWindowManager;
 struct bScreen;
+struct ScrArea;
 struct bContext;
 
 typedef struct View2DGrid View2DGrid;
@@ -138,6 +139,7 @@
 
 void UI_view2d_curRect_validate(struct View2D *v2d);
 void UI_view2d_curRect_reset(struct View2D *v2d);
+void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D 
*v2dcur, int flag);
 
 void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
 
@@ -165,7 +167,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_sync(struct bScreen *screen, struct View2D *v2dcur, int flag);
 
 /* 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-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-21 11:56:42 UTC (rev 17990)
@@ -508,6 +508,70 @@
 
 /* ------------------ */
 
+/* Called by menus to activate it, or by view2d operators to make sure 
'related' views stay in synchrony */
+void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
+{
+       ScrArea *sa;
+       ARegion *ar;
+       
+       /* don't continue if no view syncing to be done */
+       if ((v2dcur->flag & 
(V2D_VIEWSYNC_SCREEN_TIME|V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
+               return;
+               
+       /* check if doing within area syncing (i.e. channels/vertical) */
+       if (v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) {
+               for (ar= area->regionbase.first; ar; ar= ar->next) {
+                       /* don't operate on self */
+                       if (v2dcur != &ar->v2d) {
+                               /* only if view has vertical locks enabled */
+                               if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
+                                       if (flag == V2D_LOCK_COPY) {
+                                               /* other views with locks on 
must copy active */
+                                               ar->v2d.cur.ymin= 
v2dcur->cur.ymin;
+                                               ar->v2d.cur.ymax= 
v2dcur->cur.ymax;
+                                       }
+                                       else { /* V2D_LOCK_SET */
+                                               /* active must copy others */
+                                               v2dcur->cur.ymin= 
ar->v2d.cur.ymin;
+                                               v2dcur->cur.ymax= 
ar->v2d.cur.ymax;
+                                       }
+                                       
+                                       /* region possibly changed, so refresh 
*/
+                                       ED_region_tag_redraw(ar);
+                               }
+                       }
+               }
+       }
+       
+       /* check if doing whole screen syncing (i.e. time/horizontal) */
+       if (v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) {
+               for (sa= screen->areabase.first; sa; sa= sa->next) {
+                       for (ar= sa->regionbase.first; ar; ar= ar->next) {
+                               /* don't operate on self */
+                               if (v2dcur != &ar->v2d) {
+                                       /* only if view has horizontal locks 
enabled */
+                                       if (ar->v2d.flag & 
V2D_VIEWSYNC_SCREEN_TIME) {
+                                               if (flag == V2D_LOCK_COPY) {
+                                                       /* other views with 
locks on must copy active */
+                                                       ar->v2d.cur.xmin= 
v2dcur->cur.xmin;
+                                                       ar->v2d.cur.xmax= 
v2dcur->cur.xmax;
+                                               }
+                                               else { /* V2D_LOCK_SET */
+                                                       /* active must copy 
others */
+                                                       v2dcur->cur.xmin= 
ar->v2d.cur.xmin;
+                                                       v2dcur->cur.xmax= 
ar->v2d.cur.xmax;
+                                               }
+                                               
+                                               /* region possibly changed, so 
refresh */
+                                               ED_region_tag_redraw(ar);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+
 /* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of 
tot) 
  * This does not take into account if zooming the view on an axis will improve 
the view (if allowed)
  */
@@ -1549,32 +1613,3 @@
        if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - 
v2d->cur.ymin);
 }
 
-/* called by menus to activate it, or by view2d operators */
-void UI_view2d_sync(bScreen *screen, View2D *v2dcur, int flag)
-{
-       ScrArea *sa;
-       ARegion *ar;
-       
-       if(!(v2dcur->flag & V2D_VIEWSYNC_X))
-               return;
-       
-       for(sa= screen->areabase.first; sa; sa= sa->next) {
-               for(ar= sa->regionbase.first; ar; ar= ar->next) {
-                       if(v2dcur != &ar->v2d) {
-                               if(ar->v2d.flag & V2D_VIEWSYNC_X) {
-                                       if(flag == V2D_LOCK_COPY) {
-                                               
-                                               ar->v2d.cur.xmin= 
v2dcur->cur.xmin;
-                                               ar->v2d.cur.xmax= 
v2dcur->cur.xmax;
-                                       }
-                                       else { /* V2D_LOCK_SET */
-                                               v2dcur->cur.xmin= 
ar->v2d.cur.xmin;
-                                               v2dcur->cur.xmax= 
ar->v2d.cur.xmax;
-                                       }
-                                       ED_region_tag_redraw(ar);
-                               }
-                       }
-               }
-       }
-}
-

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-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c   
2008-12-21 11:56:42 UTC (rev 17990)
@@ -166,7 +166,7 @@
        
        /* request updates to be done... */
        ED_area_tag_redraw(CTX_wm_area(C));
-       UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
+       UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
 }
 
 /* cleanup temp customdata  */
@@ -497,7 +497,7 @@
        
        /* request updates to be done... */
        ED_area_tag_redraw(CTX_wm_area(C));
-       UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
+       UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
 }
 
 /* --------------- Individual Operators ------------------- */
@@ -650,7 +650,7 @@
        
        /* request updates to be done... */
        ED_area_tag_redraw(CTX_wm_area(C));
-       UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
+       UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
 }
 
 /* cleanup temp customdata  */
@@ -1031,7 +1031,7 @@
        
        /* request updates to be done... */
        ED_area_tag_redraw(CTX_wm_area(C));
-       UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
+       UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
 }
 
 /* handle user input for scrollers - calculations of mouse-movement need to be 
done here, not in the apply callback! */

Modified: 
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c  
    2008-12-21 11:05:43 UTC (rev 17989)
+++ 
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c  
    2008-12-21 11:56:42 UTC (rev 17990)
@@ -89,7 +89,7 @@
        
                /* only need to set scroll settings, as this will use 
'listview' v2d configuration */
        ar->v2d.scroll = V2D_SCROLL_BOTTOM;
-       ar->v2d.flag = V2D_VIEWSYNC_Y;
+       ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
        
        /* main area */
        ar= MEM_callocN(sizeof(ARegion), "main area for action");
@@ -119,6 +119,7 @@
        ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
        ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
        ar->v2d.align= V2D_ALIGN_NO_POS_Y;
+       ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
        
        return (SpaceLink *)saction;
 }
@@ -245,8 +246,12 @@
        UI_view2d_view_ortho(C, v2d);
        
        /* data... */
+       // temp... line for testing
+       glColor3f(0, 0, 0);
+       glLineWidth(2.0f);
+       sdrawline(10, 0, 190, 0);
+       glLineWidth(1.0f);
        
-       
        /* reset view matrix */
        UI_view2d_view_restore(C);
        

Modified: 
branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/time_header.c 
2008-12-21 11:05:43 UTC (rev 17989)
+++ branches/blender2.5/blender/source/blender/editors/space_time/time_header.c 
2008-12-21 11:56:42 UTC (rev 17990)
@@ -194,8 +194,8 @@
                        break;
                case 11:
                        if(v2d) {
-                               v2d->flag ^= V2D_VIEWSYNC_X;

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