== PoseLib - Action Editor Integration (Transform) ==
authorJoshua Leung <aligorith@gmail.com>
Sat, 23 Feb 2008 04:09:34 +0000 (04:09 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 23 Feb 2008 04:09:34 +0000 (04:09 +0000)
Now it is possible to transform Pose Markers in the Action Editor. (Note: it is a bit of a quick hack)

source/blender/makesdna/DNA_action_types.h
source/blender/src/editaction.c
source/blender/src/edittime.c
source/blender/src/header_action.c

index 85e2b70ad438c14839f1070e41ec3b0e71707f4f..d1951e67661c22a24d372bf0f6d819c8abc560e9 100644 (file)
@@ -231,7 +231,9 @@ typedef enum SACTION_FLAG {
                /* don't kill overlapping keyframes after transform */
        SACTION_NOTRANSKEYCULL = (1<<4),
                /* don't include keyframes that are out of view */
-       SACTION_HORIZOPTIMISEON = (1<<5)
+       SACTION_HORIZOPTIMISEON = (1<<5),
+               /* hack for moving pose-markers (temp flag)  */
+       SACTION_POSEMARKERS_MOVE = (1<<6)
 } SACTION_FLAG;        
 
 /* SpaceAction AutoSnap Settings (also used by SpaceNLA) */
index 8b490051fe41ed8b6968fb381f6c31e9c48e77f6..1044da9d4b108861507550b7c8c38e203deba75e 100644 (file)
@@ -4277,6 +4277,11 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        action_rename_localmarker(data);
                                else if (G.qual == LR_ALTKEY)
                                        action_remove_localmarkers(data);
+                               else if (G.qual == LR_CTRLKEY) {
+                                       G.saction->flag |= SACTION_POSEMARKERS_MOVE;
+                                       transform_markers('g', 0);
+                                       G.saction->flag &= ~SACTION_POSEMARKERS_MOVE;
+                               }
                        }
                        break;
                        
index 32b46bb77903d228c8c3588810e8a0ea73799c30..34c5bb0ff96b60d2e6c2452749584e20659651eb 100644 (file)
@@ -170,6 +170,7 @@ void transform_markers(int mode, int smode) // mode and smode unused here, for c
        SpaceLink *slink= curarea->spacedata.first;
        SpaceTime *stime= curarea->spacedata.first;
        SpaceAction *saction = curarea->spacedata.first;
+       ListBase *markers;
        TimeMarker *marker, *selmarker=NULL;
        float dx, fac;
        int a, ret_val= 0, totmark=0, *oldframe, offs, firsttime=1;
@@ -177,16 +178,26 @@ void transform_markers(int mode, int smode)       // mode and smode unused here, for c
        short val, pmval[2], mval[2], mvalo[2];
        char str[32];
        
-       for(marker= G.scene->markers.first; marker; marker= marker->next) {
-               if(marker->flag & SELECT) totmark++;
+       /* hack for pose-markers in action editor */
+       if ((slink->spacetype == SPACE_ACTION) && (saction->flag & SACTION_POSEMARKERS_MOVE)) {
+               if (saction->action)
+                       markers= &saction->action->markers;
+               else
+                       markers= NULL;
+       }
+       else
+               markers= &G.scene->markers;
+       
+       for (marker= markers->first; marker; marker= marker->next) {
+               if (marker->flag & SELECT) totmark++;
        }
-       if(totmark==0) return;
+       if (totmark==0) return;
        
        oldframe= MEM_mallocN(totmark*sizeof(int), "marker array");
-       for(a=0, marker= G.scene->markers.first; marker; marker= marker->next) {
-               if(marker->flag & SELECT) {
+       for (a=0, marker= markers->first; marker; marker= marker->next) {
+               if (marker->flag & SELECT) {
                        oldframe[a]= marker->frame;
-                       selmarker= marker;      // used for hederprint
+                       selmarker= marker;      // used for headerprint
                        a++;
                }
        }
@@ -197,8 +208,7 @@ void transform_markers(int mode, int smode) // mode and smode unused here, for c
        getmouseco_areawin(pmval);
        mvalo[0]= pmval[0];
        
-       while(ret_val == 0) {
-               
+       while (ret_val == 0) {
                getmouseco_areawin(mval);
                
                if (mval[0] != mvalo[0] || firsttime) {
@@ -213,14 +223,15 @@ void transform_markers(int mode, int smode)       // mode and smode unused here, for c
                                apply_keyb_grid(&fac, 0.0, 1.0, 0.1, U.flag & USER_AUTOGRABGRID);
                        offs= (int)fac;
                        
-                       for(a=0, marker= G.scene->markers.first; marker; marker= marker->next) {
-                               if(marker->flag & SELECT) {
+                       for (a=0, marker= markers->first; marker; marker= marker->next) {
+                               if (marker->flag & SELECT) {
                                        marker->frame= oldframe[a] + offs;
                                        a++;
                                }
                        }
                        
-                       if(totmark==1) {        // we print current marker value
+                       if (totmark==1) {       
+                               /* we print current marker value */
                                if (ELEM(slink->spacetype, SPACE_TIME, SPACE_SOUND)) {
                                        if (stime->flag & TIME_DRAWFRAMES) 
                                                sprintf(str, "Marker %d offset %d", selmarker->frame, offs);
@@ -238,6 +249,7 @@ void transform_markers(int mode, int smode) // mode and smode unused here, for c
                                }
                        }
                        else {
+                               /* we only print the offset */
                                if (ELEM(slink->spacetype, SPACE_TIME, SPACE_SOUND)) { 
                                        if (stime->flag & TIME_DRAWFRAMES) 
                                                sprintf(str, "Marker offset %d ", offs);
@@ -261,20 +273,20 @@ void transform_markers(int mode, int smode)       // mode and smode unused here, for c
                else PIL_sleep_ms(10);  // idle
                
                /* emptying queue and reading events */
-               while( qtest() ) {
+               while ( qtest() ) {
                        event= extern_qread(&val);
                        
-                       if(val) {
-                               if(event==ESCKEY || event==RIGHTMOUSE) ret_val= 2;
-                               else if(event==LEFTMOUSE || event==RETKEY || event==SPACEKEY) ret_val= 1;
+                       if (val) {
+                               if (ELEM(event, ESCKEY, RIGHTMOUSE)) ret_val= 2;
+                               else if (ELEM3(event, LEFTMOUSE, RETKEY, SPACEKEY)) ret_val= 1;
                        }
                }
        }
        
        /* restore? */
-       if(ret_val==2) {
-               for(a=0, marker= G.scene->markers.first; marker; marker= marker->next) {
-                       if(marker->flag & SELECT) {
+       if (ret_val==2) {
+               for (a=0, marker= markers->first; marker; marker= marker->next) {
+                       if (marker->flag & SELECT) {
                                marker->frame= oldframe[a];
                                a++;
                        }
index dad6a3679c1113ba0bcfd7043744754ce0481b81..254903b184e6cd75e19534b87ff16e561c71f6f2 100644 (file)
@@ -204,7 +204,8 @@ enum {
        ACTMENU_MARKERS_MOVE,
        ACTMENU_MARKERS_LOCALADD,
        ACTMENU_MARKERS_LOCALRENAME,
-       ACTMENU_MARKERS_LOCALDELETE
+       ACTMENU_MARKERS_LOCALDELETE,
+       ACTMENU_MARKERS_LOCALMOVE
 };
 
 void do_action_buttons(unsigned short event)
@@ -1363,6 +1364,11 @@ static void do_action_markermenu(void *arg, int event)
                case ACTMENU_MARKERS_LOCALRENAME:
                        action_rename_localmarker(G.saction->action);
                        break;
+               case ACTMENU_MARKERS_LOCALMOVE:
+                       G.saction->flag |= SACTION_POSEMARKERS_MOVE;
+                       transform_markers('g', 0);
+                       G.saction->flag &= ~SACTION_POSEMARKERS_MOVE;
+                       break;
        }
        
        allqueue(REDRAWMARKER, 0);
@@ -1383,9 +1389,9 @@ static uiBlock *action_markermenu(void *arg_unused)
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_DUPLICATE, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Marker|X", 0, yco-=20,
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_DELETE, "");
-                                        
+                                       
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-
+                                       
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "(Re)Name Marker|Ctrl M", 0, yco-=20,
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_NAME, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move Marker|Ctrl G", 0, yco-=20,
@@ -1393,12 +1399,14 @@ static uiBlock *action_markermenu(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, "Add Local Marker|Shift L", 0, yco-=20, 
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Pose Marker|Shift L", 0, yco-=20, 
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALADD, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rename Local Marker|Ctrl Shift L", 0, yco-=20, 
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rename Pose Marker|Ctrl Shift L", 0, yco-=20, 
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALRENAME, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Local Marker|Alt L", 0, yco-=20,
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Pose Marker|Alt L", 0, yco-=20,
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALDELETE, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move Pose Marker|Ctrl L", 0, yco-=20, 
+                                        menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALMOVE, "");
        
        if(curarea->headertype==HEADERTOP) {
                uiBlockSetDirection(block, UI_DOWN);