+ drag_end ();
+}
+
+void
+AudioRegionView::redraw_start_xfade ()
+{
+ boost::shared_ptr<AudioRegion> ar (audio_region());
+
+ if (!ar->fade_in() || ar->fade_in()->empty()) {
+ return;
+ }
+
+ show_start_xfade();
+
+ redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
+}
+
+void
+AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
+{
+ int32_t const npoints = trackview.editor().frame_to_pixel (len);
+
+ if (npoints < 3) {
+ return;
+ }
+
+ if (!start_xfade_in) {
+ start_xfade_in = new ArdourCanvas::Line (*group);
+ start_xfade_in->property_width_pixels() = 1;
+ start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ if (!start_xfade_out) {
+ start_xfade_out = new ArdourCanvas::Line (*group);
+ start_xfade_out->property_width_pixels() = 1;
+ uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 128);
+ start_xfade_out->property_fill_color_rgba() = col;
+ }
+
+ if (!start_xfade_rect) {
+ start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
+ start_xfade_rect->property_draw() = true;
+ start_xfade_rect->property_fill() = true;;
+ start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
+ start_xfade_rect->property_outline_pixels() = 0;
+ start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
+ start_xfade_rect->set_data ("regionview", this);
+ }
+
+ Points* points = get_canvas_points ("xfade edit redraw", npoints);
+ boost::scoped_array<float> vec (new float[npoints]);
+
+ double effective_height;
+ if (_height >= NAME_HIGHLIGHT_THRESH) {
+ effective_height = _height - NAME_HIGHLIGHT_SIZE - 2;
+ } else {
+ effective_height = _height - 2;
+ }
+
+ ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
+ }
+
+ start_xfade_rect->property_x1() = ((*points)[0]).get_x();
+ start_xfade_rect->property_y1() = 1.0;
+ start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
+ start_xfade_rect->property_y2() = effective_height;
+ start_xfade_rect->show ();
+
+ start_xfade_in->property_points() = *points;
+ start_xfade_in->show ();
+ start_xfade_in->raise_to_top ();
+
+ /* fade out line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
+
+ if (!inverse) {
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
+ }
+
+ } else {
+
+ inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
+ }
+ }
+
+ start_xfade_out->property_points() = *points;
+ start_xfade_out->show ();
+ start_xfade_out->raise_to_top ();
+
+ start_xfade_rect->raise_to_top (); //this needs to be topmost so the lines don't steal mouse focus
+
+ show_start_xfade();
+
+ delete points;
+}
+
+void
+AudioRegionView::redraw_end_xfade ()
+{
+ boost::shared_ptr<AudioRegion> ar (audio_region());
+
+ if (!ar->fade_out() || ar->fade_out()->empty()) {
+ return;
+ }
+
+ show_end_xfade();
+
+ redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
+}
+
+void
+AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
+{
+ int32_t const npoints = trackview.editor().frame_to_pixel (len);
+
+ if (npoints < 3) {
+ return;
+ }
+
+ if (!end_xfade_in) {
+ end_xfade_in = new ArdourCanvas::Line (*group);
+ end_xfade_in->property_width_pixels() = 1;
+ end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ if (!end_xfade_out) {
+ end_xfade_out = new ArdourCanvas::Line (*group);
+ end_xfade_out->property_width_pixels() = 1;
+ uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 128);
+ end_xfade_out->property_fill_color_rgba() = col;
+ }
+
+ if (!end_xfade_rect) {
+ end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
+ end_xfade_rect->property_draw() = true;
+ end_xfade_rect->property_fill() = true;;
+ end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
+ end_xfade_rect->property_outline_pixels() = 0;
+ end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
+ end_xfade_rect->set_data ("regionview", this);
+ }
+
+ Points* points = get_canvas_points ("xfade edit redraw", npoints);
+ boost::scoped_array<float> vec (new float[npoints]);
+
+ ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
+
+ double rend = trackview.editor().frame_to_pixel (_region->length() - len);
+
+ double effective_height;
+ if (_height >= NAME_HIGHLIGHT_THRESH) {
+ effective_height = _height - NAME_HIGHLIGHT_SIZE - 2;
+ } else {
+ effective_height = _height - 2;
+ }
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
+ }
+
+ end_xfade_rect->property_x1() = ((*points)[0]).get_x();
+ end_xfade_rect->property_y1() = 1;
+ end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
+ end_xfade_rect->property_y2() = effective_height;
+ end_xfade_rect->show ();
+
+ end_xfade_in->property_points() = *points;
+ end_xfade_in->show ();
+ end_xfade_in->raise_to_top ();
+
+ /* fade in line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
+
+ if (!inverse) {
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
+ }
+
+ } else {
+
+ inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
+ }
+ }
+
+ end_xfade_out->property_points() = *points;
+ end_xfade_out->show ();
+ end_xfade_out->raise_to_top ();
+
+ end_xfade_rect->raise_to_top (); //this needs to be topmost so the lines don't steal mouse focus
+
+ show_end_xfade();
+
+ delete points;
+}
+
+void
+AudioRegionView::hide_xfades ()
+{
+ hide_start_xfade ();
+ hide_end_xfade ();
+}
+
+void
+AudioRegionView::hide_start_xfade ()
+{
+ if (start_xfade_in) {
+ start_xfade_in->hide();
+ }
+ if (start_xfade_out) {
+ start_xfade_out->hide();
+ }
+ if (start_xfade_rect) {
+ start_xfade_rect->hide ();
+ }
+
+ _start_xfade_visible = false;
+}
+
+void
+AudioRegionView::hide_end_xfade ()
+{
+ if (end_xfade_in) {
+ end_xfade_in->hide();
+ }
+ if (end_xfade_out) {
+ end_xfade_out->hide();
+ }
+ if (end_xfade_rect) {
+ end_xfade_rect->hide ();
+ }
+
+ _end_xfade_visible = false;
+}
+
+void
+AudioRegionView::show_start_xfade ()
+{
+ if (start_xfade_in) {
+ start_xfade_in->show();
+ }
+ if (start_xfade_out) {
+ start_xfade_out->show();
+ }
+ if (start_xfade_rect) {
+ start_xfade_rect->show ();
+ }
+
+ _start_xfade_visible = true;
+}
+
+void
+AudioRegionView::show_end_xfade ()
+{
+ if (end_xfade_in) {
+ end_xfade_in->show();
+ }
+ if (end_xfade_out) {
+ end_xfade_out->show();
+ }
+ if (end_xfade_rect) {
+ end_xfade_rect->show ();
+ }
+
+ _end_xfade_visible = true;
+}
+
+void
+AudioRegionView::show_xfades ()
+{
+ show_start_xfade ();
+ show_end_xfade ();
+}
+
+void
+AudioRegionView::drag_start ()
+{
+ TimeAxisViewItem::drag_start ();
+
+ //we used to hide xfades here. I don't see the point with the new model, but we can re-implement if needed
+}
+
+void
+AudioRegionView::drag_end ()
+{
+ TimeAxisViewItem::drag_end ();
+
+ //see comment for drag_start
+}
+
+void
+AudioRegionView::parameter_changed (string const & p)
+{
+ if (p == "show-waveforms") {
+ setup_waveform_visibility ();
+ } else if (p == "waveform-scale") {
+ setup_waveform_scale ();
+ } else if (p == "waveform-shape") {
+ setup_waveform_shape ();
+ }