X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_region_view.cc;h=bd311d7e06fb03931f39fcc57bb768b804e30f34;hb=dab0dacc66dcc190b4408ba75e3807973582cbd6;hp=30c426567f9a55d9125dd6aa5bc1c70764246d7d;hpb=f6fdd8dcbf41f864e9f0cc32dabe81fe3533ddfe;p=ardour.git diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 30c426567f..bd311d7e06 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -27,7 +27,6 @@ #include "ardour/playlist.h" #include "ardour/audioregion.h" #include "ardour/audiosource.h" -#include "ardour/audio_diskstream.h" #include "ardour/profile.h" #include "ardour/session.h" @@ -111,7 +110,6 @@ AudioRegionView::AudioRegionView (const AudioRegionView& other) , _amplitude_above_axis(1.0) , _flags(0) , fade_color(0) - { Gdk::Color c; int r,g,b,a; @@ -133,7 +131,6 @@ AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_pt , _amplitude_above_axis(1.0) , _flags(0) , fade_color(0) - { Gdk::Color c; int r,g,b,a; @@ -165,7 +162,8 @@ AudioRegionView::init (Gdk::Color const & basic_color, bool wfd) store_flags (); } - if (trackview.editor().new_regionviews_display_gain()) { + /* make envelope visible if it has anything interesting in it */ + if (audio_region()->envelope()->size() > 2) { _flags |= EnvelopeVisible; } @@ -222,7 +220,8 @@ AudioRegionView::init (Gdk::Color const & basic_color, bool wfd) region_muted (); region_sync_changed (); - region_resized (BoundsChanged); + + region_resized (ARDOUR::bounds_change); set_waveview_data_src(); region_locked (); envelope_active_changed (); @@ -251,6 +250,10 @@ AudioRegionView::~AudioRegionView () gnome_canvas_waveview_cache_destroy (*cache); } + for (vector::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) { + delete *i; + } + /* all waveviews etc will be destroyed when the group is destroyed */ delete gain_line; @@ -264,29 +267,29 @@ AudioRegionView::audio_region() const } void -AudioRegionView::region_changed (Change what_changed) +AudioRegionView::region_changed (const PropertyChange& what_changed) { - ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed) - //cerr << "AudioRegionView::region_changed() called" << endl; + ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed); + // cerr << "AudioRegionView::region_changed() called" << endl; - RegionView::region_changed(what_changed); + RegionView::region_changed (what_changed); - if (what_changed & AudioRegion::ScaleAmplitudeChanged) { + if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) { region_scale_amplitude_changed (); } - if (what_changed & AudioRegion::FadeInChanged) { - fade_in_changed (); + if (what_changed.contains (ARDOUR::Properties::fade_in)) { + fade_in_changed (); } - if (what_changed & AudioRegion::FadeOutChanged) { + if (what_changed.contains (ARDOUR::Properties::fade_out)) { fade_out_changed (); } - if (what_changed & AudioRegion::FadeInActiveChanged) { + if (what_changed.contains (ARDOUR::Properties::fade_in_active)) { fade_in_active_changed (); } - if (what_changed & AudioRegion::FadeOutActiveChanged) { + if (what_changed.contains (ARDOUR::Properties::fade_out_active)) { fade_out_active_changed (); } - if (what_changed & AudioRegion::EnvelopeActiveChanged) { + if (what_changed.contains (ARDOUR::Properties::envelope_active)) { envelope_active_changed (); } } @@ -372,13 +375,17 @@ AudioRegionView::region_renamed () } void -AudioRegionView::region_resized (Change what_changed) +AudioRegionView::region_resized (const PropertyChange& what_changed) { AudioGhostRegion* agr; RegionView::region_resized(what_changed); + PropertyChange interesting_stuff; - if (what_changed & Change (StartChanged|LengthChanged)) { + interesting_stuff.add (ARDOUR::Properties::start); + interesting_stuff.add (ARDOUR::Properties::length); + + if (what_changed.contains (interesting_stuff)) { for (uint32_t n = 0; n < waves.size(); ++n) { waves[n]->property_region_start() = _region->start(); @@ -468,24 +475,23 @@ AudioRegionView::set_height (gdouble height) // FIXME: ick height -= 2; - _height = height; - - for (uint32_t n=0; n < wcnt; ++n) { + for (uint32_t n = 0; n < wcnt; ++n) { gdouble ht; if ((height) < NAME_HIGHLIGHT_THRESH) { - ht = ((height-2*wcnt) / (double) wcnt); + ht = ((height - 2 * wcnt) / (double) wcnt); } else { - ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt); + ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt); } - gdouble yoff = n * (ht+1); + gdouble yoff = n * (ht + 1); waves[n]->property_height() = ht; waves[n]->property_y() = yoff + 2; } if (gain_line) { + if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) { gain_line->hide (); } else { @@ -493,7 +499,8 @@ AudioRegionView::set_height (gdouble height) gain_line->show (); } } - gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE - 2)); + + gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2); } manage_zero_line (); @@ -502,7 +509,6 @@ AudioRegionView::set_height (gdouble height) if (name_pixbuf) { name_pixbuf->raise_to_top(); } - } void @@ -769,20 +775,6 @@ AudioRegionView::set_colors () } } -void -AudioRegionView::show_region_editor () -{ - if (editor == 0) { - editor = new AudioRegionEditor (trackview.session(), audio_region(), *this); - // GTK2FIX : how to ensure float without realizing - // editor->realize (); - // trackview.editor.ensure_float (*editor); - } - - editor->present (); - editor->show_all(); -} - void AudioRegionView::set_waveform_visible (bool yn) { @@ -843,11 +835,11 @@ AudioRegionView::create_waves () // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG RouteTimeAxisView& atv (*(dynamic_cast(&trackview))); // ick - if (!atv.get_diskstream()) { + if (!atv.track()) { return; } - ChanCount nchans = atv.get_diskstream()->n_channels(); + ChanCount nchans = atv.track()->n_channels(); // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data // << " and channels = " << nchans.n_audio() << endl; @@ -857,6 +849,16 @@ AudioRegionView::create_waves () tmp_waves.push_back (0); } + for (vector::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()) { @@ -868,7 +870,7 @@ AudioRegionView::create_waves () // 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_connection)) { + 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 { @@ -890,7 +892,7 @@ 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(&trackview))); // ick - uint32_t nchans = atv.get_diskstream()->n_channels().n_audio(); + uint32_t nchans = atv.track()->n_channels().n_audio(); uint32_t n; uint32_t nwaves = std::min (nchans, audio_region()->n_channels()); gdouble ht; @@ -964,7 +966,8 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) tmp_waves.clear (); /* all waves created, don't hook into peaks ready anymore */ - data_ready_connection.disconnect (); + delete _data_ready_connections[which]; + _data_ready_connections[which] = 0; #if 0 if (!zero_line) { @@ -981,7 +984,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) void AudioRegionView::peaks_ready_handler (uint32_t which) { - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&AudioRegionView::create_one_wave, this, which, false)); + Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false)); // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl; } @@ -1017,6 +1020,10 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev) gain_line->view_to_model_coord (x, y); + /* XXX STATEFUL: can't convert to stateful diff until we + can represent automation data with it. + */ + trackview.session()->begin_reversible_command (_("add gain control point")); XMLNode &before = audio_region()->envelope()->get_state(); @@ -1155,7 +1162,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv) AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position); uint32_t nchans; - nchans = rtv->get_diskstream()->n_channels().n_audio(); + nchans = rtv->track()->n_channels().n_audio(); for (uint32_t n = 0; n < nchans; ++n) { @@ -1186,8 +1193,6 @@ AudioRegionView::add_ghost (TimeAxisView& tv) ghost->set_colors(); ghosts.push_back (ghost); - ghost->GoingAway.connect (boost::bind (&RegionView::remove_ghost, this, _1)); - return ghost; } @@ -1368,3 +1373,14 @@ AudioRegionView::update_coverage_frames (LayerDisplay d) fade_in_handle->raise_to_top (); fade_out_handle->raise_to_top (); } + +void +AudioRegionView::show_region_editor () +{ + if (editor == 0) { + editor = new AudioRegionEditor (trackview.session(), audio_region()); + } + + editor->present (); + editor->show_all(); +}