add 1:1 convert, add es.po: thx sergio, cwdw zoom tweak, add done beep pots, bd forma...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / tracks.C
index 0f53df742895db789f82963b445cd5331dbeceb1..bb31f6dbecd2fa59c492101819bf5aae192244cb 100644 (file)
@@ -113,14 +113,16 @@ void Tracks::clear_selected_edits()
        }
 }
 
-void Tracks::select_affected_edits(double position, Track *start_track)
+void Tracks::select_affected_edits(double position, Track *start_track, int sense)
 {
        for( Track *track=start_track; track; track=track->next ) {
                if( !track->record ) continue;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       if( edit->silence() ) continue;
                        double startproject = track->from_units(edit->startproject);
                        if( edl->equivalent(startproject, position) ) {
-                               edit->is_selected = 1;
+                               edit->is_selected = sense >= 0 ? sense :
+                                       edit->is_selected ? 0 : 1;
                                break;
                        }
                }
@@ -168,6 +170,8 @@ void Tracks::copy_from(Tracks *tracks)
        Track *new_track = 0;
 
        delete_all_tracks();
+       int solo_track_id = tracks->edl->local_session->solo_track_id;
+
        for(Track *current = tracks->first; current; current = NEXT)
        {
                switch(current->data_type)
@@ -185,6 +189,9 @@ void Tracks::copy_from(Tracks *tracks)
                        continue;
                }
                new_track->copy_from(current);
+
+               if( current->get_id() == solo_track_id )
+                       edl->local_session->solo_track_id = new_track->get_id();
        }
 }
 
@@ -515,14 +522,62 @@ double Tracks::total_length_framealigned(double fps)
        return 0;
 }
 
-void Tracks::translate_projector(float offset_x, float offset_y)
+void Tracks::translate_fauto_xy(int fauto, float dx, float dy, int all)
 {
-       for(Track *current = first; current; current = NEXT)
-       {
-               if(current->data_type == TRACK_VIDEO)
-               {
-                       ((VTrack*)current)->translate(offset_x, offset_y, 0);
-               }
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !all && !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               ((VTrack*)track)->translate(fauto, dx, dy, all);
+       }
+}
+
+void Tracks::translate_projector(float dx, float dy, int all)
+{
+       translate_fauto_xy(AUTOMATION_PROJECTOR_X, dx, dy, all);
+}
+
+void Tracks::translate_camera(float dx, float dy, int all)
+{
+       translate_fauto_xy(AUTOMATION_CAMERA_X, dx, dy, all);
+}
+
+void Tracks::crop_resize(float x, float y, float z)
+{
+       float ctr_x = edl->session->output_w / 2.;
+       float ctr_y = edl->session->output_h / 2.;
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               float px, py, pz;
+               track->get_projector(px, py, pz);
+               float old_x = px + ctr_x;
+               float old_y = py + ctr_y;
+               float nx = (old_x - x) * z;
+               float ny = (old_y - y) * z;
+               track->set_projector(nx, ny, pz * z);
+       }
+}
+
+void Tracks::crop_shrink(float x, float y, float z)
+{
+       float ctr_x = edl->session->output_w / 2.;
+       float ctr_y = edl->session->output_h / 2.;
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               float cx, cy, cz, px, py, pz;
+               track->get_camera(cx, cy, cz);
+               track->get_projector(px, py, pz);
+               float dx = x - (px + ctr_x);
+               float dy = y - (py + ctr_y);
+               cz *= pz;
+               cx += dx / cz;  cy += dy / cz;
+               track->set_camera(cx, cy, cz * z);
+               px += dx;  py += dy;
+               track->set_projector(px, py, 1 / z);
        }
 }
 
@@ -623,6 +678,12 @@ Track* Tracks::number(int number)
        return current;
 }
 
+Track* Tracks::get_track_by_id(int id)
+{
+       Track *track = edl->tracks->first;
+       while( track && track->get_id() != id ) track = track->next;
+       return track;
+}
 
 int Tracks::total_playable_vtracks()
 {
@@ -658,6 +719,7 @@ int Tracks::new_group(int id)
        for( Track *track=first; track; track=track->next ) {
                if( !track->record ) continue;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       if( edit->group_id > 0 ) continue;
                        if( !edit->is_selected ) continue;
                        edit->group_id = id;
                        ++count;
@@ -672,7 +734,7 @@ int Tracks::set_group_selected(int id, int v)
        for( Track *track=first; track; track=track->next ) {
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        if( edit->group_id != id ) continue;
-                       edit->is_selected = v;
+                       edit->is_selected = v >= 0 ? v : !edit->is_selected ? 1 : 0;
                        ++count;
                }
        }