X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fcrossfade_edit.cc;h=0c8daafb045995826673acdb50616d103a4c61db;hb=4336bb25d739cd007811ccd0298a15acc5e20787;hp=c5d7b8d1b557090f3ec6341b66fd85361017cbc2;hpb=ce7a5e1c9fa3edf2d9cc66875505e402a0aaa6f6;p=ardour.git diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc index c5d7b8d1b5..0c8daafb04 100644 --- a/gtk2_ardour/crossfade_edit.cc +++ b/gtk2_ardour/crossfade_edit.cc @@ -27,6 +27,7 @@ #include +#include "pbd/memento_command.h" #include "ardour/automation_list.h" #include "evoral/Curve.hpp" #include "ardour/crossfade.h" @@ -73,7 +74,7 @@ CrossfadeEditor::Half::Half () } CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr xf, double my, double mxy) - : ArdourDialog (_("ardour: x-fade edit")), + : ArdourDialog (_("Edit Crossfade")), xfade (xf), clear_button (_("Clear")), revert_button (_("Reset")), @@ -93,11 +94,14 @@ CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr xf, d fade_out_table (3, 3), select_in_button (_("Fade In")), - select_out_button (_("Fade Out")) + select_out_button (_("Fade Out")), + + _peaks_ready_connection (0) + { set_session (s); - set_wmclass (X_("ardour_automationedit"), "Ardour"); + set_wmclass (X_("ardour_automationedit"), PROGRAM_NAME); set_name ("CrossfadeEditWindow"); set_position (Gtk::WIN_POS_MOUSE); @@ -291,9 +295,9 @@ CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr xf, d curve_select_clicked (In); - xfade->StateChanged.connect (state_connection, ui_bind (&CrossfadeEditor::xfade_changed, this, _1), gui_context()); + xfade->PropertyChanged.connect (state_connection, invalidator (*this), ui_bind (&CrossfadeEditor::xfade_changed, this, _1), gui_context()); - _session->AuditionActive.connect (_session_connections, ui_bind (&CrossfadeEditor::audition_state_changed, this, _1), gui_context()); + _session->AuditionActive.connect (_session_connections, invalidator (*this), ui_bind (&CrossfadeEditor::audition_state_changed, this, _1), gui_context()); show_all_children(); } @@ -308,6 +312,8 @@ CrossfadeEditor::~CrossfadeEditor() for (list::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) { delete *i; } + + delete _peaks_ready_connection; } void @@ -413,15 +419,16 @@ CrossfadeEditor::point_event (GdkEvent* event, Point* point) if (point_grabbed) { double new_x, new_y; - /* can't drag first or last points horizontally */ + /* can't drag first or last points horizontally or vertically */ if (point == fade[current].points.front() || point == fade[current].points.back()) { new_x = point->x; + new_y = point->y; } else { new_x = (event->motion.x - canvas_border)/effective_width(); + new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height()); } - new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height()); point->move_to (x_coordinate (new_x), y_coordinate (new_y), new_x, new_y); redraw (); @@ -497,6 +504,18 @@ CrossfadeEditor::add_control_point (double x, double y) void CrossfadeEditor::Point::move_to (double nx, double ny, double xfract, double yfract) { + if ( xfract < 0.0 ) { + xfract = 0.0; + } else if ( xfract > 1.0 ) { + xfract = 1.0; + } + + if ( yfract < 0.0 ) { + yfract = 0.0; + } else if ( yfract > 1.0 ) { + yfract = 1.0; + } + const double half_size = rint(size/2.0); double x1 = nx - half_size; double x2 = nx + half_size; @@ -624,7 +643,7 @@ CrossfadeEditor::canvas_allocation (Gtk::Allocation& /*alloc*/) void -CrossfadeEditor::xfade_changed (PropertyChange) +CrossfadeEditor::xfade_changed (const PropertyChange&) { set (xfade->fade_in(), In); set (xfade->fade_out(), Out); @@ -637,7 +656,7 @@ CrossfadeEditor::redraw () return; } - nframes_t len = xfade->length (); + framecnt_t len = xfade->length (); fade[current].normative_curve.clear (); fade[current].gain_curve.clear (); @@ -766,7 +785,14 @@ CrossfadeEditor::apply_preset (Preset *preset) void CrossfadeEditor::apply () { + _session->begin_reversible_command (_("Edit crossfade")); + + XMLNode& before = xfade->get_state (); + _apply_to (xfade); + + _session->add_command (new MementoCommand (*xfade.get(), &before, &xfade->get_state ())); + _session->commit_reversible_command (); } void @@ -847,7 +873,7 @@ CrossfadeEditor::reset () set (xfade->fade_in(), In); set (xfade->fade_out(), Out); - curve_select_clicked (current); + curve_select_clicked (current); } void @@ -1126,11 +1152,14 @@ CrossfadeEditor::make_waves (boost::shared_ptr region, WhichFade wh ht = canvas->get_allocation().get_height() / (double) nchans; spu = xfade->length() / (double) effective_width(); + delete _peaks_ready_connection; + _peaks_ready_connection = 0; + for (uint32_t n = 0; n < nchans; ++n) { gdouble yoff = n * ht; - if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr(region), which), peaks_ready_connection, gui_context())) { + if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr(region), which), &_peaks_ready_connection, gui_context())) { WaveView* waveview = new WaveView (*(canvas->root())); waveview->property_data_src() = region.get(); @@ -1176,7 +1205,9 @@ CrossfadeEditor::peaks_ready (boost::weak_ptr wr, WhichFade which) will be ready by the time we want them. but our API forces us to provide this, so .. */ - peaks_ready_connection.disconnect (); + delete _peaks_ready_connection; + _peaks_ready_connection = 0; + make_waves (r, which); } @@ -1184,11 +1215,11 @@ void CrossfadeEditor::audition (Audition which) { AudioPlaylist& pl (_session->the_auditioner()->prepare_playlist()); - nframes_t preroll; - nframes_t postroll; - nframes_t left_start_offset; - nframes_t right_length; - nframes_t left_length; + framecnt_t preroll; + framecnt_t postroll; + framecnt_t left_start_offset; + framecnt_t right_length; + framecnt_t left_length; if (which != Right && preroll_button.get_active()) { preroll = _session->frame_rate() * 2; //2 second hardcoded preroll for now