patch from lincoln to make MIDI track height changes no longer just grow note height...
[ardour.git] / gtk2_ardour / audio_region_view.cc
index 72e133892289bc600319d303d8360e913c28e27d..bd311d7e06fb03931f39fcc57bb768b804e30f34 100644 (file)
@@ -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;
        }
 
@@ -252,6 +250,10 @@ AudioRegionView::~AudioRegionView ()
                gnome_canvas_waveview_cache_destroy (*cache);
        }
 
+       for (vector<ScopedConnection*>::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;
@@ -473,22 +475,23 @@ AudioRegionView::set_height (gdouble height)
        // FIXME: ick
        height -= 2;
 
-       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 {
@@ -496,11 +499,16 @@ 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 ();
        reset_fade_shapes ();
+
+       if (name_pixbuf) {
+               name_pixbuf->raise_to_top();
+       }
 }
 
 void
@@ -767,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)
 {
@@ -841,11 +835,11 @@ AudioRegionView::create_waves ()
        // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
        RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&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;
@@ -855,6 +849,16 @@ AudioRegionView::create_waves ()
                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()) {
@@ -866,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, gui_context())) {
+                       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 {
@@ -888,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<RouteTimeAxisView*>(&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;
@@ -962,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) {
@@ -1157,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) {
 
@@ -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();
+}