X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fstreamview.cc;h=c211804fc492d2e90e1e25cf17f0a4171d0dd598;hb=deb2033a346d5a4638b9ee4e8eba66cd1b9a54e4;hp=ab61338d2d40633b8d4932b2732db4b20db8fefc;hpb=ef038c1a84ecd541a540d5a5baa677d7663e535c;p=ardour.git diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index ab61338d2d..c211804fc4 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -57,8 +57,8 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group) , region_color(_trackview.color()) , stream_base_color(0xFFFFFFFF) , _layers (1) - , height(tv.height) , _layer_display (Overlaid) + , height(tv.height) , last_rec_data_frame(0) { /* set_position() will position the group */ @@ -70,20 +70,23 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group) canvas_rect->property_y2() = (double) tv.current_height(); canvas_rect->raise(1); // raise above tempo lines - // DR-way canvas_rect->property_outline_what() = (guint32) (0x2|0x8); // outline RHS and bottom - // 2.0 way - //canvas_rect->property_outline_what() = (guint32) (0x1|0x2|0x8); // outline ends and bottom - // (Fill/Outline colours set in derived classes) - canvas_rect->signal_event().connect (bind (mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview)); + canvas_rect->signal_event().connect (bind ( + 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 ( + 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)); } ColorsChanged.connect (mem_fun (*this, &StreamView::color_handler)); @@ -211,18 +214,75 @@ StreamView::display_diskstream (boost::shared_ptr ds) { playlist_change_connection.disconnect(); playlist_changed (ds); - playlist_change_connection = ds->PlaylistChanged.connect (bind (mem_fun (*this, &StreamView::playlist_changed), ds)); + playlist_change_connection = ds->PlaylistChanged.connect (bind ( + mem_fun (*this, &StreamView::playlist_changed_weak), + boost::weak_ptr (ds))); +} + +void +StreamView::layer_regions() +{ + // In one traversal of the region view list: + // - Build a list of region views sorted by layer + // - Remove invalid views from the actual region view list + RegionViewList copy; + list::iterator i, tmp; + for (i = region_views.begin(); i != region_views.end(); ) { + tmp = i; + tmp++; + + if (!(*i)->is_valid()) { + delete *i; + region_views.erase (i); + i = tmp; + continue; + } else { + (*i)->enable_display(true); + } + + if (copy.size() == 0) { + copy.push_front((*i)); + i = tmp; + continue; + } + + RegionViewList::iterator k = copy.begin(); + RegionViewList::iterator l = copy.end(); + l--; + + if ((*i)->region()->layer() <= (*k)->region()->layer()) { + copy.push_front((*i)); + i = tmp; + continue; + } else if ((*i)->region()->layer() >= (*l)->region()->layer()) { + copy.push_back((*i)); + i = tmp; + continue; + } + + for (RegionViewList::iterator j = copy.begin(); j != copy.end(); ++j) { + if ((*j)->region()->layer() >= (*i)->region()->layer()) { + copy.insert(j, (*i)); + break; + } + } + + i = tmp; + } + + // Fix canvas layering by raising each in the sorted list order + for (RegionViewList::iterator i = copy.begin(); i != copy.end(); ++i) { + region_layered (*i); + } } void StreamView::playlist_modified_weak (boost::weak_ptr ds) { boost::shared_ptr sp (ds.lock()); - if (!sp) { - return; + if (sp) { + playlist_modified (sp); } - - playlist_modified (sp); } void @@ -240,15 +300,26 @@ StreamView::playlist_modified (boost::shared_ptr ds) } } +void +StreamView::playlist_changed_weak (boost::weak_ptr ds) +{ + boost::shared_ptr sp (ds.lock()); + if (sp) { + playlist_changed (sp); + } +} + void StreamView::playlist_changed (boost::shared_ptr ds) { - /* XXX: binding to a shared_ptr, is this ok? */ - ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_changed), ds)); + ENSURE_GUI_THREAD (bind ( + mem_fun (*this, &StreamView::playlist_changed_weak), + boost::weak_ptr (ds))); /* disconnect from old playlist */ - for (vector::iterator i = playlist_connections.begin(); i != playlist_connections.end(); ++i) { + for (vector::iterator i = playlist_connections.begin(); + i != playlist_connections.end(); ++i) { (*i).disconnect(); } @@ -266,7 +337,9 @@ StreamView::playlist_changed (boost::shared_ptr 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()->Modified.connect (bind ( + mem_fun (*this, &StreamView::playlist_modified_weak), + ds))); } void @@ -275,7 +348,9 @@ StreamView::diskstream_changed () boost::shared_ptr 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 (bind ( + mem_fun (*this, &StreamView::display_diskstream), + t->diskstream())); } else { Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::undisplay_diskstream)); }