another redirect dialog fix
[ardour.git] / gtk2_ardour / streamview.cc
index 46ac213f7a6b238d286046ba1993a96de23fe809..d6f2edeba9e9ef8ac645f120bbf98ebd80e956a9 100644 (file)
@@ -56,13 +56,14 @@ StreamView::StreamView (RouteTimeAxisView& tv)
        , use_rec_regions(tv.editor.show_waveforms_recording())
        , region_color(_trackview.color())
        , stream_base_color(0xFFFFFFFF)
+       , last_rec_data_frame(0)
 {
        /* set_position() will position the group */
 
        canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group);
        canvas_rect->property_x1() = 0.0;
        canvas_rect->property_y1() = 0.0;
-       canvas_rect->property_x2() = 1000000.0;
+       canvas_rect->property_x2() = _trackview.editor.frame_to_pixel (max_frames);
        canvas_rect->property_y2() = (double) tv.height;
        canvas_rect->property_outline_what() = (guint32) (0x1|0x2|0x8);  // outline ends and bottom 
        // (Fill/Outline colours set in derived classes)
@@ -111,16 +112,16 @@ StreamView::set_height (gdouble h)
                return -1;
        }
 
+       if (canvas_rect->property_y2() == h) {
+               return 0;
+       }
+
        canvas_rect->property_y2() = h;
 
        for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
                (*i)->set_height (h);
        }
 
-       /*for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
-               (*i)->set_height (h);
-       }*/
-
        for (vector<RecBoxInfo>::iterator i = rec_rects.begin(); i != rec_rects.end(); ++i) {
                RecBoxInfo &recbox = (*i);
                recbox.rectangle->property_y2() = h - 1.0;
@@ -164,9 +165,15 @@ StreamView::add_region_view (boost::shared_ptr<Region> r)
 }
 
 void
-StreamView::remove_region_view (boost::shared_ptr<Region> r)
+StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
 {
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::remove_region_view), r));
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::remove_region_view), weak_r));
+
+       boost::shared_ptr<Region> r (weak_r.lock());
+
+       if (!r) {
+               return;
+       }
 
        for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
                if (((*i)->region()) == r) {
@@ -177,27 +184,6 @@ StreamView::remove_region_view (boost::shared_ptr<Region> r)
        }
 }
 
-#if 0
-(unused)
-void
-StreamView::remove_rec_region (boost::shared_ptr<Region> r)
-{
-       ENSURE_GUI_THREAD(bind (mem_fun (*this, &StreamView::remove_rec_region), r));
-       
-       if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
-               fatal << "region deleted from non-GUI thread!" << endmsg;
-               /*NOTREACHED*/
-       } 
-
-       for (list<boost::shared_ptr<Region> >::iterator i = rec_regions.begin(); i != rec_regions.end(); ++i) {
-               if (*i == r) {
-                       rec_regions.erase (i);
-                       break;
-               }
-       }
-}
-#endif
-
 void
 StreamView::undisplay_diskstream ()
 {
@@ -221,9 +207,7 @@ StreamView::playlist_modified ()
 {
        ENSURE_GUI_THREAD (mem_fun (*this, &StreamView::playlist_modified));
 
-       for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
-               region_layered (*i);
-       }
+       redisplay_diskstream ();
 }
 
 void
@@ -246,20 +230,9 @@ StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 
        /* catch changes */
 
-       playlist_connections.push_back (ds->playlist()->RegionAdded.connect (mem_fun (*this, &StreamView::add_region_view)));
-       playlist_connections.push_back (ds->playlist()->RegionRemoved.connect (mem_fun (*this, &StreamView::remove_region_view)));
-       playlist_connections.push_back (ds->playlist()->StateChanged.connect (mem_fun (*this, &StreamView::playlist_state_changed)));
        playlist_connections.push_back (ds->playlist()->Modified.connect (mem_fun (*this, &StreamView::playlist_modified)));
 }
 
-void
-StreamView::playlist_state_changed (Change ignored)
-{
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_state_changed), ignored));
-
-       redisplay_diskstream ();
-}
-
 void
 StreamView::diskstream_changed ()
 {
@@ -333,7 +306,7 @@ StreamView::update_rec_box ()
        if (rec_active && rec_rects.size() > 0) {
                /* only update the last box */
                RecBoxInfo & rect = rec_rects.back();
-               jack_nframes_t at = _trackview.get_diskstream()->current_capture_end();
+               nframes_t at = _trackview.get_diskstream()->current_capture_end();
                double xstart;
                double xend;
                
@@ -398,7 +371,7 @@ StreamView::set_selected_regionviews (RegionSelection& regions)
 }
 
 void
-StreamView::get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable*>& results)
+StreamView::get_selectables (nframes_t start, nframes_t end, list<Selectable*>& results)
 {
        for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
                if ((*i)->region()->coverage(start, end) != OverlapNone) {