Added functionality for using TKEY in the action windows
authorChris Want <cwant@ualberta.ca>
Tue, 28 Jan 2003 03:59:33 +0000 (03:59 +0000)
committerChris Want <cwant@ualberta.ca>
Tue, 28 Jan 2003 03:59:33 +0000 (03:59 +0000)
to change the Ipo type (constant/linear/bezier) for the Ipo curves
owned by the selected channels

source/blender/include/BSE_editipo.h
source/blender/src/editaction.c
source/blender/src/editipo.c

index afafcf7242800ad793169a1a8a0992168db36fbd..938b228a84e33b61c5a67cb83daa6c3171ce21a1 100644 (file)
@@ -131,6 +131,7 @@ void sampledata_to_ipocurve(float *data, int sfra, int efra, struct IpoCurve *ic
 void ipo_record(void);    
 
 void sethandles_ipo_keys(struct Ipo *ipo, int code);
+void setipotype_ipo(struct Ipo *ipo, int code);
 void set_ipo_key_selection(struct Ipo *ipo, int sel);
 int is_ipo_key_selected(struct Ipo *ipo);
 void delete_ipo_keys(struct Ipo *ipo);
index c9ee8c546b452072c1cfeaa0820ca55519e1e5f3..bbae0fd60aca53c14b2aef792fe4a91826a82a92 100644 (file)
@@ -1338,6 +1338,43 @@ static void sethandles_actionchannel_keys(int code)
        allqueue(REDRAWNLA, 0);
 }
 
+static void set_ipotype_actionchannels(void) {
+
+       bAction *act; 
+       bActionChannel *chan;
+       short event;
+
+       /* Get the selected action, exit if none are selected 
+        */
+       act = G.saction->action;
+       if (!act)
+               return;
+
+       /* Present a popup menu asking the user what type
+        * of IPO curve he/she/GreenBTH wants. ;)
+        */
+       event= pupmenu("Channel Ipo Type %t|Constant %x1|Linear %x2|Bezier %x3");
+       if(event < 1) return;
+       
+       /* 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)
+                               setipotype_ipo(chan->ipo, event);
+               }
+       }
+
+       /* Clean up and redraw stuff
+        */
+       remake_action_ipos (act);
+       allspace(REMAKEIPO, 0);
+       allqueue(REDRAWACTION, 0);
+       allqueue(REDRAWIPO, 0);
+       allqueue(REDRAWNLA, 0);
+}
 
 void winqreadactionspace(unsigned short event, short val, char ascii)
 {
@@ -1414,6 +1451,11 @@ void winqreadactionspace(unsigned short event, short val, char ascii)
                        else sethandles_actionchannel_keys(HD_ALIGN);
                        break;
  
+                       /*** set the Ipo type  ***/
+               case TKEY:
+                       set_ipotype_actionchannels();
+                       break;
+
                case BKEY:
                        borderselect_action();
                        break;
index c5923cbe83c91dc63698170c16e7167a16d85fa9..0f2f10c7eff9e3e78b1c0f956db2c3a355ad3e49 100644 (file)
@@ -2958,6 +2958,43 @@ void sethandles_ipo(int code)
 }
 
 
+void set_ipocurve_constant(struct IpoCurve *icu) {
+       /* Sets the type of the IPO curve to constant
+        */
+       icu->ipo= IPO_CONST;
+}
+
+void set_ipocurve_linear(struct IpoCurve *icu) {
+       /* Sets the type of the IPO curve to linear
+        */
+       icu->ipo= IPO_LIN;
+}
+
+void set_ipocurve_bezier(struct IpoCurve *icu) {
+       /* Sets the type of the IPO curve to bezier
+        */
+       icu->ipo= IPO_BEZ;
+}
+
+
+void setipotype_ipo(Ipo *ipo, int code)
+{
+       /* Sets the type of the each ipo curve in the
+        * Ipo to a value based on the code
+        */
+       switch (code) {
+       case 1:
+               ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_constant);
+               break;
+       case 2:
+               ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_linear);
+               break;
+       case 3:
+               ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_bezier);
+               break;
+       }
+}
+
 void set_ipotype()
 {
        EditIpo *ei;