+ if (!end_xfade_out) {
+ end_xfade_out = new ArdourCanvas::PolyLine (group);
+ CANVAS_DEBUG_NAME (end_xfade_out, string_compose ("xfade end out line for %1", region()->name()));
+ end_xfade_out->set_outline_color (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine());
+ end_xfade_out->set_outline_width (2.0);
+ }
+
+ if (!end_xfade_rect) {
+ end_xfade_rect = new ArdourCanvas::Rectangle (group);
+ CANVAS_DEBUG_NAME (end_xfade_rect, string_compose ("xfade end rect for %1", region()->name()));
+ end_xfade_rect->set_fill (true);
+ end_xfade_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ActiveCrossfade());
+ end_xfade_rect->set_outline (0);
+ end_xfade_rect->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);
+ }
+
+ end_xfade_rect->set (ArdourCanvas::Rect (points.front().x, 1.0, points.back().x, effective_height));
+ end_xfade_rect->show ();
+
+ end_xfade_in->set (points);
+ end_xfade_in->show ();
+ end_xfade_in->raise_to_top ();
+
+ /* fade in line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
+ Points ipoints;
+ Points::size_type npoints = points.size();
+
+ ipoints.assign (npoints, Duple());
+
+ if (!inverse) {
+
+ const double rend = trackview.editor().sample_to_pixel (_region->length() - points.back().y);
+
+ for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) {
+ ArdourCanvas::Duple &p (ipoints[pci]);
+ p.x = rend + i;
+ p.y = effective_height - points[pci].y;
+ }
+
+ } else {
+
+ boost::scoped_array<float> vec (new float[npoints]);
+ inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
+
+ const double rend = trackview.editor().sample_to_pixel (_region->length() - width);
+
+ float* vp = vec.get();
+
+ for (Points::size_type i = 0, pci = 0; i < npoints; ++i) {
+ ArdourCanvas::Duple& p (ipoints[pci++]);
+ p.x = rend + i;
+ p.y = 1.0 + effective_height - (effective_height * vp[i]);
+ }
+ }
+
+ end_xfade_out->set (ipoints);
+ 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();
+}
+
+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::set_samples_per_pixel (gdouble fpp)
+{
+ RegionView::set_samples_per_pixel (fpp);
+
+ if (Config->get_show_waveforms ()) {
+ for (uint32_t n = 0; n < waves.size(); ++n) {
+ waves[n]->set_samples_per_pixel (fpp);
+ }
+ }
+
+ if (gain_line) {
+ gain_line->reset ();
+ }
+
+ reset_fade_shapes ();
+}
+
+void
+AudioRegionView::set_amplitude_above_axis (gdouble a)
+{
+ for (uint32_t n=0; n < waves.size(); ++n) {
+ waves[n]->set_amplitude_above_axis (a);
+ }
+}
+
+void
+AudioRegionView::compute_colors (Gdk::Color const & basic_color)
+{
+ RegionView::compute_colors (basic_color);
+
+ /* gain color computed in envelope_active_changed() */
+
+ fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
+}
+
+void
+AudioRegionView::set_colors ()
+{
+ RegionView::set_colors();
+
+ if (gain_line) {
+ gain_line->set_line_color (audio_region()->envelope_active() ?
+ ARDOUR_UI::config()->get_canvasvar_GainLine() :
+ ARDOUR_UI::config()->get_canvasvar_GainLineInactive());
+ }
+
+ set_waveform_colors ();
+
+ if (start_xfade_in) {
+ start_xfade_in->set_outline_color (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine());
+ }
+ if (start_xfade_out) {
+ uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 128);
+ start_xfade_out->set_outline_color (col);
+ }
+ if (end_xfade_in) {
+ end_xfade_in->set_outline_color (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine());
+ }
+ if (end_xfade_out) {
+ uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 128);
+ end_xfade_out->set_outline_color (col);
+ }
+
+ if (start_xfade_rect) {
+ start_xfade_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ActiveCrossfade());
+ }
+ if (end_xfade_rect) {
+ end_xfade_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ActiveCrossfade());
+ }
+}
+
+void
+AudioRegionView::setup_waveform_visibility ()
+{
+ if (Config->get_show_waveforms ()) {
+ for (uint32_t n = 0; n < waves.size(); ++n) {
+ /* make sure the zoom level is correct, since we don't update
+ this when waveforms are hidden.
+ */
+ // CAIROCANVAS
+ // waves[n]->set_samples_per_pixel (_samples_per_pixel);
+ waves[n]->show();
+ }
+ } else {
+ for (uint32_t n = 0; n < waves.size(); ++n) {
+ waves[n]->hide();
+ }
+ }
+}
+
+void
+AudioRegionView::temporarily_hide_envelope ()
+{
+ if (gain_line) {
+ gain_line->hide ();
+ }
+}
+
+void
+AudioRegionView::unhide_envelope ()
+{
+ update_envelope_visibility ();
+}
+
+void
+AudioRegionView::update_envelope_visibility ()
+{
+ if (!gain_line) {
+ return;
+ }
+
+ if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
+ gain_line->add_visibility (AutomationLine::Line);
+ } else {
+ gain_line->hide ();
+ }
+}
+
+void
+AudioRegionView::create_waves ()