svn merge ^/trunk/blender -r40644:40720
[blender-staging.git] / source / blender / editors / transform / transform_conversions.c
index 30436fad77208c639bb709d86cdc12c3266661ae..ea71e89f88377b37675c50d1a9764bde04ff9e41 100644 (file)
@@ -2322,6 +2322,12 @@ void flushTransNodes(TransInfo *t)
 }
 
 /* *** SEQUENCE EDITOR *** */
+
+/* commented _only_ because the meta may have animaion data which
+ * needs moving too [#28158] */
+
+#define SEQ_TX_NESTED_METAS
+
 void flushTransSeq(TransInfo *t)
 {
        ListBase *seqbasep= seq_give_editing(t->scene, FALSE)->seqbasep; /* Editing null check already done */
@@ -2347,9 +2353,13 @@ void flushTransSeq(TransInfo *t)
 
                switch (tdsq->sel_flag) {
                case SELECT:
+#ifdef SEQ_TX_NESTED_METAS
+                       if ((seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
+                               seq->start= new_frame - tdsq->start_offset;
+#else
                        if (seq->type != SEQ_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
                                seq->start= new_frame - tdsq->start_offset;
-
+#endif
                        if (seq->depth==0) {
                                seq->machine= (int)floor(td2d->loc[1] + 0.5f);
                                CLAMP(seq->machine, 1, MAXSEQ);
@@ -2404,7 +2414,7 @@ void flushTransSeq(TransInfo *t)
                seq_prev= seq;
        }
 
-       if (t->mode == TFM_TIME_TRANSLATE) { /* originally TFM_TIME_EXTEND, transform changes */
+       if (t->mode == TFM_SEQ_SLIDE) { /* originally TFM_TIME_EXTEND, transform changes */
                /* Special annoying case here, need to calc metas with TFM_TIME_EXTEND only */
                seq= seqbasep->first;
 
@@ -2906,7 +2916,7 @@ static void posttrans_gpd_clean (bGPdata *gpd)
 /* Called during special_aftertrans_update to make sure selected keyframes replace
  * any other keyframes which may reside on that frame (that is not selected).
  */
-static void posttrans_fcurve_clean (FCurve *fcu)
+static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
 {
        float *selcache;        /* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
        int len, index, i;      /* number of frames in cache, item index */
@@ -2955,7 +2965,7 @@ static void posttrans_fcurve_clean (FCurve *fcu)
                        }
                }
                
-               testhandles_fcurve(fcu);
+               testhandles_fcurve(fcu, use_handle);
        }
 
        /* free cache */
@@ -2986,11 +2996,11 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
                
                if (adt) {
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
-                       posttrans_fcurve_clean(ale->key_data);
+                       posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
                }
                else
-                       posttrans_fcurve_clean(ale->key_data);
+                       posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
        }
 
        /* free temp data */
@@ -3011,12 +3021,11 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
        /* only include points that occur on the right side of cfra */
        for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
                if (bezt->f2 & SELECT) {
-                       /* fully select the other two keys */
-                       bezt->f1 |= SELECT;
-                       bezt->f3 |= SELECT;
-
-                       if (FrameOnMouseSide(side, bezt->vec[1][0], cfra))
+                       /* no need to adjust the handle selection since they are assumed
+                        * selected (like graph editor with SIPO_NOHANDLES) */
+                       if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
                                count += 1;
+                       }
                }
        }
 
@@ -3441,9 +3450,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
                for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-                               const char sel1= use_handle ? bezt->f1 & SELECT : 0;
                                const char sel2= bezt->f2 & SELECT;
-                               const char sel3= use_handle ? bezt->f3 & SELECT : 0;
+                               const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
+                               const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
 
                                if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
                                        /* for 'normal' pivots - just include anything that is selected.
@@ -3534,9 +3543,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
                for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-                               const char sel1= use_handle ? bezt->f1 & SELECT : 0;
                                const char sel2= bezt->f2 & SELECT;
-                               const char sel3= use_handle ? bezt->f3 & SELECT : 0;
+                               const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
+                               const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
 
                                TransDataCurveHandleFlags *hdata = NULL;
                                /* short h1=1, h2=1; */ /* UNUSED */
@@ -3596,7 +3605,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                }
                
                /* Sets handles based on the selection */
-               testhandles_fcurve(fcu);
+               testhandles_fcurve(fcu, use_handle);
        }
        
        /* cleanup temp list */
@@ -3800,7 +3809,7 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
                        sort_time_fcurve(fcu);
                        
                        /* make sure handles are all set correctly */
-                       testhandles_fcurve(fcu);
+                       testhandles_fcurve(fcu, use_handle);
                }
        }
 }
@@ -3958,6 +3967,11 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
                else {
                        /* Nested, different rules apply */
 
+#ifdef SEQ_TX_NESTED_METAS
+                       *flag= (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+                       *count= 1; /* ignore the selection for nested */
+                       *recursive = (seq->type == SEQ_META     );
+#else
                        if (seq->type == SEQ_META) {
                                /* Meta's can only directly be moved between channels since they
                                 * dont have their start and length set directly (children affect that)
@@ -3972,6 +3986,7 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
                                *count= 1; /* ignore the selection for nested */
                                *recursive = 0;
                        }
+#endif
                }
        }
 }
@@ -4947,11 +4962,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                                {
                                        if (adt) {
                                                ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
-                                               posttrans_fcurve_clean(fcu);
+                                               posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
                                                ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
                                        }
                                        else
-                                               posttrans_fcurve_clean(fcu);
+                                               posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
                                }
                        }
                        
@@ -5031,6 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
        else if (t->spacetype == SPACE_IPO) {
                SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
                bAnimContext ac;
+               const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
                
                /* initialise relevant anim-context 'context' data */
                if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -5059,11 +5075,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                                {
                                        if (adt) {
                                                ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
-                                               posttrans_fcurve_clean(fcu);
+                                               posttrans_fcurve_clean(fcu, use_handle);
                                                ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
                                        }
                                        else
-                                               posttrans_fcurve_clean(fcu);
+                                               posttrans_fcurve_clean(fcu, use_handle);
                                }
                        }