Don't allow drag of automation range unless the mouse is inside the range.
[ardour.git] / gtk2_ardour / streamview.cc
index 6e3d62291d8b160064a410c00a18a5576ff38a61..a29ad7b4ccc3fb2a2d0efa074a32f9ca5a214e55 100644 (file)
@@ -74,24 +74,20 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
 
        canvas_rect->property_outline_what() = (guint32) (0x2|0x8);  // outline RHS and bottom
 
-       canvas_rect->signal_event().connect (bind (
-                       mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event),
+       canvas_rect->signal_event().connect (sigc::bind (
+                       sigc::mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event),
                        canvas_rect, &_trackview));
 
        if (_trackview.is_track()) {
-               _trackview.track()->DiskstreamChanged.connect (
-                               mem_fun (*this, &StreamView::diskstream_changed));
-               _trackview.session().TransportStateChange.connect (
-                               mem_fun (*this, &StreamView::transport_changed));
-               _trackview.session().TransportLooped.connect (
-                               mem_fun (*this, &StreamView::transport_looped));
-               _trackview.get_diskstream()->RecordEnableChanged.connect (
-                               mem_fun (*this, &StreamView::rec_enable_changed));
-               _trackview.session().RecordStateChanged.connect (
-                               mem_fun (*this, &StreamView::sess_rec_enable_changed));
+               _trackview.track()->DiskstreamChanged.connect (*this, boost::bind (&StreamView::diskstream_changed, this), gui_context());
+               _trackview.get_diskstream()->RecordEnableChanged.connect (*this, boost::bind (&StreamView::rec_enable_changed, this), gui_context());
+
+               _trackview.session()->TransportStateChange.connect (*this, boost::bind (&StreamView::transport_changed, this), gui_context());
+               _trackview.session()->TransportLooped.connect (*this, boost::bind (&StreamView::transport_looped, this), gui_context());
+               _trackview.session()->RecordStateChanged.connect (*this, boost::bind (&StreamView::sess_rec_enable_changed, this), gui_context());
        }
 
-       ColorsChanged.connect (mem_fun (*this, &StreamView::color_handler));
+       ColorsChanged.connect (sigc::mem_fun (*this, &StreamView::color_handler));
 }
 
 StreamView::~StreamView ()
@@ -186,7 +182,7 @@ StreamView::add_region_view_weak (boost::weak_ptr<Region> r)
 void
 StreamView::add_region_view (boost::shared_ptr<Region> r)
 {
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::add_region_view_weak), boost::weak_ptr<Region>(r)));
+       ENSURE_GUI_THREAD (*this, &StreamView::add_region_view_weak, boost::weak_ptr<Region>(r));
 
        add_region_view_internal (r, true);
 
@@ -198,7 +194,7 @@ StreamView::add_region_view (boost::shared_ptr<Region> r)
 void
 StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
 {
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::remove_region_view), weak_r));
+       ENSURE_GUI_THREAD (*this, &StreamView::remove_region_view, weak_r)
 
        boost::shared_ptr<Region> r (weak_r.lock());
 
@@ -210,6 +206,7 @@ StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
                if (((*i)->region()) == r) {
                        RegionView* rv = *i;
                        region_views.erase (i);
+                       cerr << "Deleting RV for " << r->name() << " @ " << r << endl;
                        delete rv;
                        break;
                }
@@ -234,9 +231,7 @@ StreamView::display_diskstream (boost::shared_ptr<Diskstream> ds)
 {
        playlist_change_connection.disconnect();
        playlist_changed (ds);
-       playlist_change_connection = ds->PlaylistChanged.connect (bind (
-                       mem_fun (*this, &StreamView::playlist_changed_weak),
-                       boost::weak_ptr<Diskstream> (ds)));
+       ds->PlaylistChanged.connect (playlist_change_connection, boost::bind (&StreamView::playlist_changed_weak, this, boost::weak_ptr<Diskstream> (ds)), gui_context());
 }
 
 void
@@ -290,9 +285,9 @@ StreamView::layer_regions()
                i = tmp;
        }
 
-       // Fix canvas layering by raising each in the sorted list order
+       // Fix canvas layering by raising each to the top in the sorted order.
        for (RegionViewList::iterator i = copy.begin(); i != copy.end(); ++i) {
-               region_layered (*i);
+               (*i)->get_canvas_group()->raise_to_top ();
        }
 }
 
@@ -310,7 +305,7 @@ void
 StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
 {
        /* we do not allow shared_ptr<T> to be bound to slots */
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_modified_weak), ds));
+       ENSURE_GUI_THREAD (*this, &StreamView::playlist_modified_weak, ds)
 
        /* update layers count and the y positions and heights of our regions */
        if (ds->playlist()) {
@@ -320,7 +315,10 @@ StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
        if (_layer_display == Stacked) {
                update_contents_height ();
                update_coverage_frames ();
-       }
+       } else {
+               /* layering has probably been modified. reflect this in the canvas. */
+               layer_regions();
+       } 
 }
 
 void
@@ -335,18 +333,11 @@ StreamView::playlist_changed_weak (boost::weak_ptr<Diskstream> ds)
 void
 StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 {
-       ENSURE_GUI_THREAD (bind (
-                       mem_fun (*this, &StreamView::playlist_changed_weak),
-                       boost::weak_ptr<Diskstream> (ds)));
+       ENSURE_GUI_THREAD (*this, &StreamView::playlist_changed_weak, boost::weak_ptr<Diskstream> (ds));
 
        /* disconnect from old playlist */
 
-       for (vector<sigc::connection>::iterator i = playlist_connections.begin();
-                       i != playlist_connections.end(); ++i) {
-               (*i).disconnect();
-       }
-
-       playlist_connections.clear();
+       playlist_connections.drop_connections ();
        undisplay_diskstream ();
 
        /* update layers count and the y positions and heights of our regions */
@@ -362,14 +353,9 @@ StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 
        /* catch changes */
 
-       playlist_connections.push_back (ds->playlist()->Modified.connect (bind (
-                       mem_fun (*this, &StreamView::playlist_modified_weak), ds)));
-
-       playlist_connections.push_back (ds->playlist()->RegionAdded.connect (
-                       mem_fun (*this, &StreamView::add_region_view_weak)));
-
-       playlist_connections.push_back (ds->playlist()->RegionRemoved.connect (
-                       mem_fun (*this, &StreamView::remove_region_view)));
+       ds->playlist()->Modified.connect (playlist_connections, boost::bind (&StreamView::playlist_modified_weak, this, ds), gui_context());
+       ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view_weak, this, _1), gui_context());
+       ds->playlist()->RegionRemoved.connect (playlist_connections, ui_bind (&StreamView::remove_region_view, this, _1), gui_context());
 }
 
 void
@@ -378,11 +364,9 @@ StreamView::diskstream_changed ()
        boost::shared_ptr<Track> t;
 
        if ((t = _trackview.track()) != 0) {
-               Gtkmm2ext::UI::instance()->call_slot (bind (
-                               mem_fun (*this, &StreamView::display_diskstream),
-                               t->diskstream()));
+               Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::display_diskstream, this, t->diskstream()));
        } else {
-               Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::undisplay_diskstream));
+               Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::undisplay_diskstream, this));
        }
 }
 
@@ -420,19 +404,19 @@ StreamView::region_layered (RegionView* rv)
 void
 StreamView::rec_enable_changed ()
 {
-       Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
+       Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::setup_rec_box, this));
 }
 
 void
 StreamView::sess_rec_enable_changed ()
 {
-       Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
+       Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::setup_rec_box, this));
 }
 
 void
 StreamView::transport_changed()
 {
-       Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
+       Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::setup_rec_box, this));
 }
 
 void
@@ -440,7 +424,7 @@ StreamView::transport_looped()
 {
        // to force a new rec region
        rec_active = false;
-       Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
+       Gtkmm2ext::UI::instance()->call_slot (boost::bind (&StreamView::setup_rec_box, this));
 }
 
 void