Merging r46725 through r46963 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / transform / transform_generics.c
index 23c1fba..152576e 100644 (file)
@@ -49,6 +49,7 @@
 #include "DNA_view3d_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
 
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
@@ -637,33 +638,49 @@ static void recalcData_spaceclip(TransInfo *t)
 {
        SpaceClip *sc = t->sa->spacedata.first;
 
-       MovieClip *clip = ED_space_clip(sc);
-       ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
-       MovieTrackingTrack *track;
+       if (ED_space_clip_show_trackedit(sc)) {
+               MovieClip *clip = ED_space_clip(sc);
+               ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+               MovieTrackingTrack *track;
+               int framenr = sc->user.framenr;
 
-       flushTransTracking(t);
+               flushTransTracking(t);
 
-       track = tracksbase->first;
-       while (track) {
-               if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
-                       if (t->mode == TFM_TRANSLATION) {
-                               if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
-                                       BKE_tracking_clamp_track(track, CLAMP_PAT_POS);
-                               if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
-                                       BKE_tracking_clamp_track(track, CLAMP_SEARCH_POS);
-                       }
-                       else if (t->mode == TFM_RESIZE) {
-                               if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
-                                       BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
-                               if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
-                                       BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
+               track = tracksbase->first;
+               while (track) {
+                       if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
+                               MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+
+                               if (t->mode == TFM_TRANSLATION) {
+                                       if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+                                               BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
+                                       if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+                                               BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_POS);
+                               }
+                               else if (t->mode == TFM_RESIZE) {
+                                       if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+                                               BKE_tracking_clamp_marker(marker, CLAMP_PAT_DIM);
+                                       if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+                                               BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM);
+                               }
+                               else if (t->mode == TFM_ROTATION) {
+                                       if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+                                               BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
+                               }
                        }
+
+                       track = track->next;
                }
 
-               track = track->next;
+               DAG_id_tag_update(&clip->id, 0);
        }
+       else if (ED_space_clip_show_maskedit(sc)) {
+               Mask *mask = ED_space_clip_mask(sc);
+
+               flushTransMasking(t);
 
-       DAG_id_tag_update(&clip->id, 0);
+               DAG_id_tag_update(&mask->id, 0);
+       }
 }
 
 /* helper for recalcData() - for 3d-view transforms */
@@ -1104,6 +1121,11 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
                t->view = &ar->v2d;
                t->around = sipo->around;
        }
+       else if (t->spacetype==SPACE_CLIP) {
+               SpaceClip *sclip = sa->spacedata.first;
+               t->view = &ar->v2d;
+               t->around = sclip->around;
+       }
        else {
                if (ar) {
                        // XXX for now, get View2D  from the active region