added prototypes for bottom_sel_action and friends.
[blender.git] / source / blender / src / editaction.c
index 2b76fafdf015b74c449b35347602182d8923cb9e..e9081b0fbfced0f078261dd721e1d7c7fb4a2324 100644 (file)
 #include <string.h>
 #include <math.h>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include "MEM_guardedalloc.h"
 
 #include "PIL_time.h"
 #include "nla.h"
 
 extern int count_action_levels (bAction *act);
+void top_sel_action();
+void up_sel_action();
+void bottom_sel_action();
+void down_sel_action();
 
 #define BEZSELECTED(bezt)   (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
 
 /* Local Function prototypes, are forward needed */
 static void hilight_channel (bAction *act, bActionChannel *chan, short hilight);
 
-static void up_sel_action(void);
-static void down_sel_action(void);
-static void top_sel_action(void);
-static void bottom_sel_action(void);
-
 /* Implementation */
 
 short showsliders = 0;
@@ -1017,35 +1012,35 @@ void transform_actionchannel_keys(int mode, int dummy)
                                                break;
                                        }
                                }
-                       }
-       
-                       if (mode=='s'){
-                               sprintf(str, "sizeX: %.3f", fac);
-                               headerprint(str);
-                       }
-                       else if (mode=='g'){
-                               sprintf(str, "deltaX: %.3f", fac);
-                               headerprint(str);
-                       }
-                       else if (mode=='t') {
-                               float fac= 2.0*(cval[0]-sval[0])/(maxx-minx);
-                               CLAMP(fac, -1.0f, 1.0f);
-                               sprintf(str, "TimeSlide: %.3f", fac);
-                               headerprint(str);
-                       }
        
-                       if (G.saction->lock) {
-                               if(ob) {
-                                       ob->ctime= -1234567.0f;
-                                       if(ob->pose || ob_get_key(ob))
-                                               DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-                                       else
-                                               DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
+                               if (mode=='s'){
+                                       sprintf(str, "sizeX: %.3f", fac);
+                                       headerprint(str);
+                               }
+                               else if (mode=='g'){
+                                       sprintf(str, "deltaX: %.3f", fac);
+                                       headerprint(str);
+                               }
+                               else if (mode=='t') {
+                                       float fac= 2.0*(cval[0]-sval[0])/(maxx-minx);
+                                       CLAMP(fac, -1.0f, 1.0f);
+                                       sprintf(str, "TimeSlide: %.3f", fac);
+                                       headerprint(str);
+                               }
+               
+                               if (G.saction->lock) {
+                                       if(ob) {
+                                               ob->ctime= -1234567.0f;
+                                               if(ob->pose || ob_get_key(ob))
+                                                       DAG_object_flush_update(G.scene, ob, OB_RECALC);
+                                               else
+                                                       DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
+                                       }
+                                       force_draw_plus(SPACE_VIEW3D, 0);
+                               }
+                               else {
+                                       force_draw(0);
                                }
-                               force_draw_plus(SPACE_VIEW3D, 0);
-                       }
-                       else {
-                               force_draw(0);
                        }
                }
                
@@ -1061,7 +1056,7 @@ void transform_actionchannel_keys(int mode, int dummy)
                ob->ctime= -1234567.0f;
 
                if(ob->pose || ob_get_key(ob))
-                       DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+                       DAG_object_flush_update(G.scene, ob, OB_RECALC);
                else
                        DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
        }
@@ -1743,6 +1738,67 @@ void set_ipotype_actionchannels(int ipotype)
        allqueue(REDRAWNLA, 0);
 }
 
+void set_extendtype_actionchannels(int extendtype)
+{
+       bAction *act; 
+       bActionChannel *chan;
+       short event;
+
+       /* Get the selected action, exit if none are selected 
+        */
+       act = G.saction->action;
+       if (!act)
+               return;
+
+       if (extendtype == SET_EXTEND_POPUP) {
+               /* Present a popup menu asking the user what type
+                * of IPO curve he/she/GreenBTH wants. ;)
+                */
+               event
+                       =  pupmenu("Channel Extending Type %t|"
+                                          "Constant %x1|"
+                                          "Extrapolation %x2|"
+                                          "Cyclic %x3|"
+                                          "Cyclic extrapolation %x4");
+               if(event < 1) return;
+               extendtype = event;
+       }
+       
+       /* Loop through the channels and for the selected ones set
+        * the type for each Ipo curve in the channel Ipo (based on
+        * the value from the popup).
+        */
+       for (chan = act->chanbase.first; chan; chan=chan->next){
+               if (chan->flag & ACHAN_SELECTED) {
+                       if (chan->ipo) {
+                               switch (extendtype) {
+                               case SET_EXTEND_CONSTANT:
+                                       setexprap_ipoloop(chan->ipo, IPO_HORIZ);
+                                       break;
+                               case SET_EXTEND_EXTRAPOLATION:
+                                       setexprap_ipoloop(chan->ipo, IPO_DIR);
+                                       break;
+                               case SET_EXTEND_CYCLIC:
+                                       setexprap_ipoloop(chan->ipo, IPO_CYCL);
+                                       break;
+                               case SET_EXTEND_CYCLICEXTRAPOLATION:
+                                       setexprap_ipoloop(chan->ipo, IPO_CYCLX);
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /* Clean up and redraw stuff
+        */
+       remake_action_ipos (act);
+       BIF_undo_push("Set Ipo type Action channel");
+       allspace(REMAKEIPO, 0);
+       allqueue(REDRAWACTION, 0);
+       allqueue(REDRAWIPO, 0);
+       allqueue(REDRAWNLA, 0);
+}
+
 void set_snap_actionchannels(void) 
 {