+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 ()
+{
+ // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
+ RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
+
+ if (!atv.track()) {
+ return;
+ }
+
+ ChanCount nchans = atv.track()->n_channels();
+
+ // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
+ // << " and channels = " << nchans.n_audio() << endl;
+
+ /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
+ for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
+ tmp_waves.push_back (0);
+ }
+
+ for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
+ delete *i;
+ }
+
+ _data_ready_connections.clear ();
+
+ for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
+ _data_ready_connections.push_back (0);
+ }
+
+ for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
+
+ if (n >= audio_region()->n_channels()) {
+ break;
+ }
+
+ // cerr << "\tchannel " << n << endl;
+
+ if (wait_for_data) {
+ if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
+ // cerr << "\tData is ready\n";
+ create_one_wave (n, true);
+ } else {
+ // cerr << "\tdata is not ready\n";
+ // we'll get a PeaksReady signal from the source in the future
+ // and will call create_one_wave(n) then.
+ }
+
+ } else {
+ // cerr << "\tdon't delay, display today!\n";
+ create_one_wave (n, true);
+ }
+
+ }
+}
+
+void
+AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
+{
+ //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
+ RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
+ uint32_t nchans = atv.track()->n_channels().n_audio();
+ uint32_t n;
+ uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
+ gdouble ht;
+
+ if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
+ ht = ((trackview.current_height()) / (double) nchans);
+ } else {
+ ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);