reload plugin btn in prefs, speed gang fader tweaks
[goodguy/history.git] / cinelerra-5.1 / cinelerra / trackcanvas.C
index 5b283ff6eca69caabc5cc83683b183663c1efef3..fdd3112bb6b2fb62f315fc7c2f3fb70de94bf9ba 100644 (file)
@@ -2095,10 +2095,8 @@ int TrackCanvas::do_keyframes(int cursor_x,
                                                if (buttonpress != 3)
                                                {
                                                        if(i == AUTOMATION_FADE || i == AUTOMATION_SPEED)
-                                                               synchronize_autos(0,
-                                                                       track,
-                                                                       (FloatAuto*)mwindow->session->drag_auto,
-                                                                       1);
+                                                               fill_ganged_autos(get_double_click(), 0, track,
+                                                                       (FloatAuto*)mwindow->session->drag_auto);
                                                        mwindow->session->current_operation = pre_auto_operations[i];
                                                        update_drag_caption();
                                                        rerender = 1;
@@ -2723,69 +2721,68 @@ int TrackCanvas::test_floatline(int center_pixel,
 }
 
 
-void TrackCanvas::synchronize_autos(float change,
-               Track *skip, FloatAuto *fauto, int fill_gangs)
+void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAuto *fauto)
 {
+       if( !skip->gang ) return;
 // Handles the special case of modifying a fadeauto
 // when there are ganged faders on several tracks
-// (skip and fauto may be NULL if fill_gangs==-1)
-
-       if( fill_gangs > 0 && skip->gang ) {
-               double position = skip->from_units(fauto->position);
-               int autoidx = fauto->autos->autoidx;
-
-               for(Track *current = mwindow->edl->tracks->first; current; current = NEXT) {
-                       if( (current->data_type == skip->data_type || get_double_click()) &&
-                           current->gang && current->record && current != skip ) {
-                               int64_t current_position = current->to_units(position, 1);
-                               FloatAutos *fade_autos = (FloatAutos*)current->automation->autos[autoidx];
-                               float auto_min = mwindow->edl->local_session->automation_mins[fade_autos->autogrouptype];
-                               float auto_max = mwindow->edl->local_session->automation_maxs[fade_autos->autogrouptype];
-                               FloatAuto *previous = 0, *next = 0;
-                               FloatAuto *keyframe = (FloatAuto*)fade_autos->get_auto_at_position(current_position);
-                               if( !keyframe ) {
-// create keyframe on neighbouring track at the point in time given by fauto
-                                       float init_value = fade_autos->get_value(current_position, PLAY_FORWARD, previous, next);
-                                       float new_value = init_value + change;
-                                       CLAMP(new_value, auto_min, auto_max);
-                                       keyframe = (FloatAuto*)fade_autos->insert_auto(current_position);
-                                       keyframe->set_value(new_value);
-                               }
-                               else {
+       double position = skip->from_units(fauto->position);
+       int autoidx = fauto->autos->autoidx;
+
+       for(Track *current = mwindow->edl->tracks->first; current; current = NEXT) {
+               if( (all || current->data_type == skip->data_type) &&
+                   current->gang && current->record && current != skip ) {
+                       FloatAutos *fade_autos = (FloatAutos*)current->automation->autos[autoidx];
+                       float auto_min = mwindow->edl->local_session->automation_mins[fade_autos->autogrouptype];
+                       float auto_max = mwindow->edl->local_session->automation_maxs[fade_autos->autogrouptype];
+                       int64_t current_position = current->to_units(position, 1);
+                       FloatAuto *keyframe = (FloatAuto*)fade_autos->get_auto_at_position(position);
+                       if( keyframe ) {
 // keyframe exists, just change it
-                                       float new_value = keyframe->get_value() + change;
-                                       CLAMP(new_value, auto_min, auto_max);
-                                       keyframe->adjust_to_new_coordinates(current_position, new_value);
-// need to (re)set the position, as the existing node could be on a "equivalent" position (within half a frame)
-                               }
-
-                               mwindow->session->drag_auto_gang->append((Auto *)keyframe);
+                               float value = keyframe->get_value();
+                               float new_value = value + change;
+                               CLAMP(new_value, auto_min, auto_max);
+                               keyframe->adjust_to_new_coordinates(current_position, new_value);
                        }
+                       else if( mwindow->edl->session->auto_keyframes ) {
+// create keyframe on neighbouring track at the point in time given by fauto
+                               FloatAuto *previous = 0, *next = 0;
+                               float value = fade_autos->get_value(current_position, PLAY_FORWARD, previous, next);
+                               float new_value = value + change;
+                               CLAMP(new_value, auto_min, auto_max);
+                               keyframe = (FloatAuto*)fade_autos->insert_auto(current_position);
+                               keyframe->set_value(new_value);
+                       }
+                       else
+                               continue;
+                       mwindow->session->drag_auto_gang->append((Auto *)keyframe);
                }
        }
-       else if( !fill_gangs ) {
-               double position = skip->from_units(fauto->position);
-// Move the gangs
-               for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) {
-                       FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
-                       int64_t keyframe_position = keyframe->autos->track->to_units(position, 1);
-                       float new_value = keyframe->get_value() + change;
-                       CLAMP(new_value,
-                             mwindow->edl->local_session->automation_mins[keyframe->autos->autogrouptype],
-                             mwindow->edl->local_session->automation_maxs[keyframe->autos->autogrouptype]);
-                       keyframe->adjust_to_new_coordinates(keyframe_position, new_value);
-               }
+}
 
+void TrackCanvas::update_ganged_autos(float change, Track *skip, FloatAuto *fauto)
+{
+       double position = skip->from_units(fauto->position);
+// Move the gangs
+       for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) {
+               FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
+               int64_t keyframe_position = keyframe->autos->track->to_units(position, 1);
+               float new_value = keyframe->get_value() + change;
+               CLAMP(new_value,
+                     mwindow->edl->local_session->automation_mins[keyframe->autos->autogrouptype],
+                     mwindow->edl->local_session->automation_maxs[keyframe->autos->autogrouptype]);
+               keyframe->adjust_to_new_coordinates(keyframe_position, new_value);
        }
-       else {
+}
+
+void TrackCanvas::clear_ganged_autos()
+{
 // remove the gangs
-               for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) {
-                       FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
-                       keyframe->autos->remove_nonsequential(
-                                       keyframe);
-               }
-               mwindow->session->drag_auto_gang->remove_all();
+       for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) {
+               FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
+               keyframe->autos->remove_nonsequential(keyframe);
        }
+       mwindow->session->drag_auto_gang->remove_all();
 }
 
 
@@ -3848,7 +3845,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                        result = 1;
                        float change = value - old_value;
                        current->adjust_to_new_coordinates(position, value);
-                       synchronize_autos(change, current->autos->track, current, 0);
+                       update_ganged_autos(change, current->autos->track, current);
                        show_message(current, 1,", %.2f", current->get_value());
                }
                break;
@@ -3867,7 +3864,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                        current->set_control_in_value(
                                value * levered_position(position - current->position,
                                                         current->get_control_in_position()));
-                       synchronize_autos(0, current->autos->track, current, 0);
+                       update_ganged_autos(0, current->autos->track, current);
                        show_message(current, 1,", %.2f", current->get_control_in_value());
                }
                break; }
@@ -3881,7 +3878,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                        current->set_control_out_value(
                                value * levered_position(position - current->position,
                                                         current->get_control_out_position()));
-                       synchronize_autos(0, current->autos->track, current, 0);
+                       update_ganged_autos(0, current->autos->track, current);
                        show_message(current, 1,", %.2f", current->get_control_out_value());
                }
                break; }
@@ -4408,7 +4405,7 @@ int TrackCanvas::button_release_event()
                        load_flags |= LOAD_EDITS;
                case DRAG_FADE:
 // delete the drag_auto_gang first and remove out of order keys
-                       synchronize_autos(0, 0, 0, -1);
+                       clear_ganged_autos();
                case DRAG_CZOOM:
                case DRAG_PZOOM:
                case DRAG_PLAY: