New option; "Lock Time to Other Windows" for Ipo, Action, NLA and Time
authorTon Roosendaal <ton@blender.org>
Thu, 20 Oct 2005 14:41:10 +0000 (14:41 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 20 Oct 2005 14:41:10 +0000 (14:41 +0000)
windows. If set (in View pulldown), it synchronizes the horizontal scale of
the current window with the other Windows with this option set. That way
you always have these windows showing an identical part of the time you
work on.

Also added because Action Window now displays its content relative to
NLA strips.

13 files changed:
source/blender/include/BSE_drawipo.h
source/blender/makesdna/DNA_view2d_types.h
source/blender/src/drawipo.c
source/blender/src/editaction.c
source/blender/src/editipo.c
source/blender/src/editnla.c
source/blender/src/editsound.c
source/blender/src/edittime.c
source/blender/src/header_action.c
source/blender/src/header_ipo.c
source/blender/src/header_nla.c
source/blender/src/header_sound.c
source/blender/src/header_time.c

index cd72a147741eae4f656de48ff0791b9b04659ca6..07f116d8d67b5f3c5abb646c0eb6a11c2551f715 100644 (file)
@@ -53,6 +53,7 @@ void areamouseco_to_ipoco     (struct View2D *v2d, short *mval, float *x, float *y);
 void ipoco_to_areaco           (struct View2D *v2d, float *vec, short *mval);
 void ipoco_to_areaco_noclip    (struct View2D *v2d, float *vec, short *mval);
 
+void view2d_do_locks           (struct ScrArea *cursa, int flag);
 void view2d_zoom                       (struct View2D *v2d, float factor, int winx, int winy);
 void test_view2d                       (struct View2D *v2d, int winx, int winy);
 void calc_scrollrcts           (struct ScrArea *sa, struct View2D *v2d, int winx, int winy);
index 797df42c5a37a9e126b850d6bad226eabe79516f..cfd6f682e715adab8fbd5a0c729d198595bd3a6e 100644 (file)
@@ -44,12 +44,20 @@ typedef struct View2D {
        short scroll, keeptot;
        short keepaspect, keepzoom;
        short oldwinx, oldwiny;
-       int pad;
+       int flag;
 } View2D;
 
+/* v2d->keepzoom */
 #define V2D_KEEPZOOM   0x0001  
 #define V2D_LOCKZOOM_X 0x0100
 #define V2D_LOCKZOOM_Y 0x0200
 
+/* event codes for locking function */
+#define V2D_LOCK_COPY  1
+#define V2D_LOCK_REDRAW        2
+
+/* v2d->flag */
+#define V2D_VIEWLOCK   1
+
 #endif
 
index f7870fda239fc5229c1341590d0b8b4f9aff523b..aab228c5df08daee3f8e4a1addb5a23fb2d23c77 100644 (file)
@@ -50,6 +50,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 
+#include "DNA_action_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_key_types.h"
@@ -383,7 +384,62 @@ int in_ipo_buttons(void)
        else return 1;
 }
 
+static View2D *spacelink_get_view2d(SpaceLink *sl)
+{
+       if(sl->spacetype==SPACE_IPO) 
+               return &((SpaceIpo *)sl)->v2d;
+       else if(sl->spacetype==SPACE_SOUND) 
+               return &((SpaceSound *)sl)->v2d;
+       if(sl->spacetype==SPACE_ACTION) 
+               return &((SpaceAction *)sl)->v2d;
+       if(sl->spacetype==SPACE_NLA) 
+               return &((SpaceNla *)sl)->v2d;
+       if(sl->spacetype==SPACE_TIME) 
+               return &((SpaceTime *)sl)->v2d;
+       
+       return NULL;
+}
+
+/* copies changes in this view from or to all 2d views with lock option open */
+void view2d_do_locks(ScrArea *cursa, int flag)
+{
+       ScrArea *sa;
+       View2D *v2d, *curv2d;
+       SpaceLink *sl;
+       
+       curv2d= spacelink_get_view2d(cursa->spacedata.first);
+       if(curv2d==NULL) return;
+       if((curv2d->flag & V2D_VIEWLOCK)==0) return;
 
+       for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+               if(sa!=cursa) {
+                       for(sl= sa->spacedata.first; sl; sl= sl->next) {
+                               
+                               v2d= spacelink_get_view2d(sl);
+                               if(v2d) {
+                                       if(v2d->flag & V2D_VIEWLOCK) {
+                                               if(flag & V2D_LOCK_COPY) {
+                                                       v2d->cur.xmin= curv2d->cur.xmin;
+                                                       v2d->cur.xmax= curv2d->cur.xmax;
+                                               }
+                                               else {
+                                                       curv2d->cur.xmin= v2d->cur.xmin;
+                                                       curv2d->cur.xmax= v2d->cur.xmax;
+                                                       scrarea_queue_winredraw(sa);
+                                               }
+                                               
+                                               if(flag & V2D_LOCK_REDRAW)
+                                                       scrarea_do_windraw(sa);
+                                               else
+                                                       scrarea_queue_winredraw(sa);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+/* event based, note: curarea is in here... */
 void view2d_zoom(View2D *v2d, float factor, int winx, int winy) 
 {
        float dx= factor*(v2d->cur.xmax-v2d->cur.xmin);
@@ -397,6 +453,7 @@ void view2d_zoom(View2D *v2d, float factor, int winx, int winy)
                v2d->cur.ymax-= dy;
        }
        test_view2d(v2d, winx, winy);
+       view2d_do_locks(curarea, V2D_LOCK_COPY);
 }
 
 
@@ -2159,6 +2216,8 @@ int view2dzoom(unsigned short event)
                        }
                
                        test_view2d(G.v2d, curarea->winx, curarea->winy);       /* cur min max rects */
+                       view2d_do_locks(curarea, V2D_LOCK_COPY|V2D_LOCK_REDRAW);
+                       
                        scrarea_do_windraw(curarea);
                        screen_swapbuffers();
                }
@@ -2177,17 +2236,14 @@ void center_currframe(void)
         */
        float width;
   
-       areawinset(curarea->win);
-       curarea->head_swap= 0;
-
        width = G.v2d->cur.xmax - G.v2d->cur.xmin;
        G.v2d->cur.xmin = CFRA - 0.5*(width);
        G.v2d->cur.xmax = CFRA + 0.5*(width);
 
        test_view2d(G.v2d, curarea->winx, curarea->winy);
-       scrarea_do_windraw(curarea);
-       screen_swapbuffers();
-       curarea->head_swap= 0;
+       view2d_do_locks(curarea, V2D_LOCK_COPY);
+
+       scrarea_queue_winredraw(curarea);
 }
 
 /* total mess function, especially with mousewheel, needs cleanup badly (ton) */
@@ -2334,6 +2390,7 @@ int view2dmove(unsigned short event)
                        G.v2d->cur.ymax+= right*dy;
                                
                        test_view2d(G.v2d, curarea->winx, curarea->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY|V2D_LOCK_REDRAW);
                                
                        scrarea_do_windraw(curarea);
                        screen_swapbuffers();
index 44f16abe886e8eb17452b9efb14b962804581511..8fb1186af1dbc1ad79905af083b8fe52f577d60a 100644 (file)
@@ -2287,11 +2287,15 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                case PADPLUSKEY:
                        view2d_zoom(G.v2d, 0.1154, sa->winx, sa->winy);
                        test_view2d(G.v2d, sa->winx, sa->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
+
                        doredraw= 1;
                        break;
                case PADMINUS:
                        view2d_zoom(G.v2d, -0.15, sa->winx, sa->winy);
                        test_view2d(G.v2d, sa->winx, sa->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
+                       
                        doredraw= 1;
                        break;
                case MIDDLEMOUSE:
index c29b98b376877d87b08d84802bb5ee5c731fa36d..53c1c7f4b6f6802f29d76df80c414d72abca6ee3 100644 (file)
@@ -890,6 +890,8 @@ static void make_editipo(void)
        else {
                ipo_default_v2d_cur(G.sipo->blocktype, &G.v2d->cur);
        }
+       
+       view2d_do_locks(curarea, V2D_LOCK_COPY);
 }
 
 /* evaluates context in the current UI */
index 89479f53d916634db97af6e48b576261e8134962..d018e58bd137b5c9ad3a12e4805a568876be8e16 100644 (file)
@@ -326,11 +326,13 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                case PADPLUSKEY:
                        view2d_zoom(G.v2d, 0.1154, sa->winx, sa->winy);
                        test_view2d(G.v2d, sa->winx, sa->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case PADMINUS:
                        view2d_zoom(G.v2d, -0.15, sa->winx, sa->winy);
                        test_view2d(G.v2d, sa->winx, sa->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case MIDDLEMOUSE:
index 5eec31adb12a47404c6bec87f23411bc74cab0b1..30b38d2c2d76508278d0d7b97df87a461d286966 100644 (file)
@@ -175,7 +175,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        G.v2d->cur.xmin+= dx;
                        G.v2d->cur.xmax-= dx;
                        test_view2d(G.v2d, curarea->winx, curarea->winy);
-
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case PADMINUS:
@@ -183,7 +183,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        G.v2d->cur.xmin-= dx;
                        G.v2d->cur.xmax+= dx;
                        test_view2d(G.v2d, curarea->winx, curarea->winy);
-
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case HOMEKEY:
index 0bb4250c5a49ab131e0580eb658c16fac27db33b..1cf94f85608ed111d264f748cb7f431fc6cab45f 100644 (file)
@@ -552,7 +552,7 @@ void winqreadtimespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        G.v2d->cur.xmin+= dx;
                        G.v2d->cur.xmax-= dx;
                        test_view2d(G.v2d, sa->winx, sa->winy);
-
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case PADMINUS:
@@ -560,7 +560,7 @@ void winqreadtimespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        G.v2d->cur.xmin-= dx;
                        G.v2d->cur.xmax+= dx;
                        test_view2d(G.v2d, sa->winx, sa->winy);
-
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        doredraw= 1;
                        break;
                case HOMEKEY:
index 49f5ee3fd0d74c1d8c542b51056a486863bfbde2..0ace342a2aeed04d547b60e45b7066f8388ce882 100644 (file)
@@ -82,6 +82,7 @@
 #define ACTMENU_VIEW_PLAYALL    3
 #define ACTMENU_VIEW_ALL        4
 #define ACTMENU_VIEW_MAXIMIZE   5
+#define ACTMENU_VIEW_LOCK              6
 
 #define ACTMENU_SEL_BORDER      0
 #define ACTMENU_SEL_ALL_KEYS    1
@@ -152,7 +153,7 @@ void do_action_buttons(unsigned short event)
                        
                        G.v2d->tot= G.v2d->cur;
                        test_view2d(G.v2d, curarea->winx, curarea->winy);
-
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
 
                        addqueue (curarea->win, REDRAW, 1);
 
@@ -210,6 +211,11 @@ static void do_action_viewmenu(void *arg, int event)
                case ACTMENU_VIEW_ALL: /* View All */
                        do_action_buttons(B_ACTHOME);
                        break;
+               case ACTMENU_VIEW_LOCK:
+                       G.v2d->flag ^= V2D_VIEWLOCK;
+                       if(G.v2d->flag & V2D_VIEWLOCK)
+                               view2d_do_locks(curarea, 0);
+                       break;
                case ACTMENU_VIEW_MAXIMIZE: /* Maximize Window */
                        /* using event B_FULL */
                        break;
@@ -231,24 +237,21 @@ static uiBlock *action_viewmenu(void *arg_unused)
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, 
                                         ACTMENU_VIEW_CENTERVIEW, "");
        
+       uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Lock Time to Other Windows|", 0, yco-=20, 
+                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 
+                                        ACTMENU_VIEW_LOCK, "");
+       
        uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
-       if(BTST(G.saction->lock, 0)) {
-               uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, 
-                                                "Update Automatically|", 0, yco-=20, 
-                                                menuwidth, 19, NULL, 0.0, 0.0, 1, 
-                                                ACTMENU_VIEW_AUTOUPDATE, "");
-       } 
-       else {
-               uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, 
-                                                "Update Automatically|", 0, yco-=20, 
-                                                menuwidth, 19, NULL, 0.0, 0.0, 1, 
-                                                ACTMENU_VIEW_AUTOUPDATE, "");
-       }
+       uiDefIconTextBut(block, BUTM, 1, BTST(G.saction->lock, 0)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Update Automatically|", 0, yco-=20, 
+                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 
+                                        ACTMENU_VIEW_AUTOUPDATE, "");
 
        uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
-                        menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+                                       menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
                                         "Play Back Animation|Alt A", 0, yco-=20, 
index 44e9ddf6425d23922d8d841607cfd0698cf53ff1..1508c61830dd32a94927fb6feb71ef934bc5560e 100644 (file)
@@ -645,6 +645,11 @@ static void do_ipo_viewmenu(void *arg, int event)
        case 8:
                add_blockhandler(curarea, IPO_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
                break;  
+       case 9:
+               G.v2d->flag ^= V2D_VIEWLOCK;
+               if(G.v2d->flag & V2D_VIEWLOCK)
+                       view2d_do_locks(curarea, 0);
+               break;                  
        }
 }
 
@@ -659,8 +664,8 @@ static uiBlock *ipo_viewmenu(void *arg_unused)
        block= uiNewBlock(&curarea->uiblocks, "ipo_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
        uiBlockSetButmFunc(block, do_ipo_viewmenu, NULL);
 
-
        uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Channel Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
+       
        if (G.sipo->showkey)
                uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Keys|K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
        else
@@ -681,6 +686,8 @@ static uiBlock *ipo_viewmenu(void *arg_unused)
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
+       uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
 
        if (ei != NULL && (ei->flag & IPO_EDIT)) {
                uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move Current Frame to Selected|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
@@ -863,6 +870,7 @@ void do_ipo_buttons(short event)
                v2d->cur.ymax= v2d->tot.ymax+ dy;
 
                test_view2d(G.v2d, curarea->winx, curarea->winy);
+               view2d_do_locks(curarea, V2D_LOCK_COPY);
                if(G.sipo->ipo) G.sipo->ipo->cur = G.v2d->cur;
                
                scrarea_queue_winredraw(curarea);
@@ -880,6 +888,7 @@ void do_ipo_buttons(short event)
                        G.v2d->cur.ymin= ymin;
                        
                        test_view2d(G.v2d, curarea->winx, curarea->winy);
+                       view2d_do_locks(curarea, V2D_LOCK_COPY);
                        scrarea_queue_winredraw(curarea);
                }
                break;
index d0139b829928e17b1182d1d40b30fd727cda9d9b..ef4949bcfefd3a9ac2d35e66dda41eaca3f37375 100644 (file)
@@ -83,6 +83,7 @@ void do_nla_buttons(unsigned short event)
                v2d->cur.ymax= 5; // at least stuff is visiable then?
                
                test_view2d(G.v2d, curarea->winx, curarea->winy);
+               view2d_do_locks(curarea, V2D_LOCK_COPY);
                addqueue (curarea->win, REDRAW, 1);
                break;
        }
@@ -110,6 +111,11 @@ static void do_nla_viewmenu(void *arg, int event)
        case 4: /* Maximize Window */
                /* using event B_FULL */
                break;
+       case 5:
+               G.v2d->flag ^= V2D_VIEWLOCK;
+               if(G.v2d->flag & V2D_VIEWLOCK)
+                       view2d_do_locks(curarea, 0);
+               break;                  
        }
 }
 
@@ -136,7 +142,9 @@ static uiBlock *nla_viewmenu(void *arg_unused)
        uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-               
+       uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
+       
        if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
        else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
        
index cebc9e9afd63686d982458a93c39d1e619566963..d3a577075d69e8df2cbd03873b313aba334af76d 100644 (file)
@@ -163,6 +163,7 @@ void do_sound_buttons(unsigned short event)
                }
                G.v2d->cur= G.v2d->tot;
                test_view2d(G.v2d, curarea->winx, curarea->winy);
+               view2d_do_locks(curarea, V2D_LOCK_COPY);
                scrarea_queue_winredraw(curarea);
                break;
        }
index c3261aabdeac48a08d39a8a40b3e81c9cf56eda5..0b48d51bd4713b02247a5c1b35947dea0bdafd37 100644 (file)
@@ -212,6 +212,11 @@ static void do_time_viewmenu(void *arg, int event)
                case 10:
                        timeline_frame_to_center();
                        break;
+               case 11:
+                       G.v2d->flag ^= V2D_VIEWLOCK;
+                       if(G.v2d->flag & V2D_VIEWLOCK)
+                               view2d_do_locks(curarea, 0);
+                       break;
        }
        allqueue(REDRAWVIEW3D, 0);
 }
@@ -247,7 +252,9 @@ static uiBlock *time_viewmenu(void *arg_unused)
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-               
+       uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
+       
        if (!curarea->full) 
                uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
        else