Action Editor - Added back ID browsing buttons. Only browse/delete works for now.
authorJoshua Leung <aligorith@gmail.com>
Sun, 8 Feb 2009 10:21:38 +0000 (10:21 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 8 Feb 2009 10:21:38 +0000 (10:21 +0000)
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_header.c

index 1b592238a9b7f028c4316a61345f6d7ebb5f83f7..858da27157dc8b17be0469508e3cfd28ee13a686 100644 (file)
@@ -238,10 +238,8 @@ void ACT_OT_view_all (wmOperatorType *ot)
 //     - insert key
 
 /* ******************** Copy/Paste Keyframes Operator ************************* */
-/* - The copy/paste buffer currently stores a set of Action Channels, with temporary
- *     IPO-blocks, and also temporary IpoCurves which only contain the selected keyframes.
- * - Only pastes between compatable data is possible (i.e. same achan->name, ipo-curve type, etc.)
- *     Unless there is only one element in the buffer, names are also tested to check for compatability.
+/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes 
+ *   that were selected in each of the original F-Curves
  * - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
  *     the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
  * - The earliest frame is calculated per copy operation.
@@ -276,7 +274,6 @@ void free_actcopybuf ()
  */
 static short copy_action_keys (bAnimContext *ac)
 {      
-#if 0 // XXX old animation system
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
@@ -285,11 +282,12 @@ static short copy_action_keys (bAnimContext *ac)
        free_actcopybuf();
        
        /* filter data */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_IPOKEYS);
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
        
        /* assume that each of these is an ipo-block */
        for (ale= anim_data.first; ale; ale= ale->next) {
+#if 0
                bActionChannel *achan;
                Ipo *ipo= ale->key_data;
                Ipo *ipn;
@@ -347,16 +345,21 @@ static short copy_action_keys (bAnimContext *ac)
                                }
                        }
                }
+#endif
+               //FCurve *fcu= (FCurve *)ale->key_data;
+               //FCurve *fcn;
+               //BezTriple *bezt;
+               //int i;
+               
+               
        }
        
        /* check if anything ended up in the buffer */
        if (ELEM(NULL, actcopybuf.first, actcopybuf.last))
-       //      error("Nothing copied to buffer");
                return -1;
        
        /* free temp memory */
        BLI_freelistN(&anim_data);
-#endif // XXX old animation system
        
        /* everything went fine */
        return 0;
index dedca434ce834ad2df021f89ccab1ea86a5934e3..aff87a2c34174d9901b27ab15d2a12ec5861a624 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
+#include "DNA_anim_types.h"
 #include "DNA_action_types.h"
 #include "DNA_key_types.h"
+#include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -1551,6 +1553,38 @@ static void do_action_buttons(bContext *C, void *arg, int event)
        }
 }
 
+static void saction_idpoin_handle(bContext *C, ID *id, int event)
+{
+       SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
+       Object *obact= CTX_data_active_object(C);
+       AnimData *adt= BKE_id_add_animdata((ID *)obact);
+
+       switch (event) {
+               case UI_ID_BROWSE:
+               case UI_ID_DELETE:
+                       /* we must set this action to be the one used by active object (if not pinned) */
+                       if (saction->pin == 0)
+                               obact->adt->action= saction->action;
+                       
+                       ED_area_tag_redraw(CTX_wm_area(C));
+                       ED_undo_push(C, "Assign Action");
+                       break;
+               case UI_ID_RENAME:
+                       break;
+               case UI_ID_ADD_NEW:
+                       /* XXX not implemented */
+                       break;
+               case UI_ID_OPEN:
+                       /* XXX not implemented */
+                       break;
+               case UI_ID_ALONE:
+                       /* XXX not implemented */
+                       break;
+               case UI_ID_PIN:
+                       break;
+       }
+}
+
 void action_header_buttons(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= CTX_wm_area(C);
@@ -1628,7 +1662,8 @@ void action_header_buttons(const bContext *C, ARegion *ar)
        
        xco += (90 + 8);
        
-       if (ac.data) {
+       /*if (ac.data)*/ 
+       {
                /* MODE-DEPENDENT DRAWING */
                if (saction->mode == SACTCONT_DOPESHEET) {
                        /* FILTERING OPTIONS */
@@ -1652,17 +1687,12 @@ void action_header_buttons(const bContext *C, ARegion *ar)
                }
                else if (saction->mode == SACTCONT_ACTION) { // not too appropriate for shapekeys atm...
                        /* NAME ETC */
-                               // XXX missing stuff here!
-                       //ob= OBACT;
-                       //from = (ID *)ob;
-                       
-                       //xco= std_libbuttons(block, xco, 0, B_ACTPIN, saction->pin, 
-                       //                                      B_ACTIONBROWSE, ID_AC, 0, (ID*)saction->action, 
-                       //                                      from, &(saction->actnr), B_ACTALONE, 
-                       //                                      B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);     
-                       
                        //uiClearButLock();
                        
+                       /* NAME ETC (it is assumed that */
+                       xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&saction->action, ID_AC, &saction->pin, xco, yco,
+                               saction_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_DELETE|UI_ID_FAKE_USER|UI_ID_ALONE|UI_ID_PIN);
+                       
                        xco += 8;
                }