Various fixes to multiple-2D panner signal handling. Should fix some or all of ...
[ardour.git] / gtk2_ardour / crossfade_edit.cc
index c1201f2f9a91fca313de9dce9105df30006aca15..382f6afd09b114b5ad0392a39f64811d03ae3751 100644 (file)
@@ -73,7 +73,7 @@ CrossfadeEditor::Half::Half ()
 }
 
 CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr<Crossfade> xf, double my, double mxy)
-       : ArdourDialog (_("ardour: x-fade edit")),
+       : ArdourDialog (_("Edit Crossfade")),
          xfade (xf),
          clear_button (_("Clear")),
          revert_button (_("Reset")),
@@ -93,7 +93,10 @@ CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr<Crossfade> 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);
 
@@ -291,9 +294,9 @@ CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr<Crossfade> xf, d
 
        curve_select_clicked (In);
 
-       xfade->PropertyChanged.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 +311,8 @@ CrossfadeEditor::~CrossfadeEditor()
        for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
                delete *i;
        }
+
+       delete _peaks_ready_connection;
 }
 
 void
@@ -497,6 +502,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;
@@ -1126,11 +1143,14 @@ CrossfadeEditor::make_waves (boost::shared_ptr<AudioRegion> 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<AudioRegion>(region), which), peaks_ready_connection, gui_context())) {
+               if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr<AudioRegion>(region), which), &_peaks_ready_connection, gui_context())) {
                        WaveView* waveview = new WaveView (*(canvas->root()));
 
                        waveview->property_data_src() = region.get();
@@ -1176,7 +1196,9 @@ CrossfadeEditor::peaks_ready (boost::weak_ptr<AudioRegion> 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);
 }