add sampo's synthesize_sources perl script to tools; add scroll-playhead-{forward...
[ardour.git] / gtk2_ardour / streamview.cc
index 13d07f6cb1622ff3c1fbc0bd22e8e0021fc971e2..04b5269ab0179905179ed7140ca2533ae03ba631 100644 (file)
@@ -62,7 +62,7 @@ StreamView::StreamView (RouteTimeAxisView& tv)
        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)
@@ -158,18 +158,24 @@ StreamView::set_samples_per_unit (gdouble spp)
 }
 
 void
-StreamView::add_region_view (Region *r)
+StreamView::add_region_view (boost::shared_ptr<Region> r)
 {
        add_region_view_internal (r, true);
 }
 
 void
-StreamView::remove_region_view (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) {
+               if (((*i)->region()) == r) {
                        delete *i;
                        region_views.erase (i);
                        break;
@@ -177,24 +183,6 @@ StreamView::remove_region_view (Region *r)
        }
 }
 
-void
-StreamView::remove_rec_region (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<Region *>::iterator i = rec_regions.begin(); i != rec_regions.end(); ++i) {
-               if (*i == r) {
-                       rec_regions.erase (i);
-                       break;
-               }
-       }
-}
-
 void
 StreamView::undisplay_diskstream ()
 {
@@ -206,7 +194,7 @@ StreamView::undisplay_diskstream ()
 }
 
 void
-StreamView::display_diskstream (Diskstream *ds)
+StreamView::display_diskstream (boost::shared_ptr<Diskstream> ds)
 {
        playlist_change_connection.disconnect();
        playlist_changed (ds);
@@ -218,13 +206,11 @@ 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
-StreamView::playlist_changed (Diskstream *ds)
+StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 {
        ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_changed), ds));
 
@@ -243,29 +229,16 @@ StreamView::playlist_changed (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 ()
 {
        Track *t;
 
        if ((t = _trackview.track()) != 0) {
-               Diskstream& ds = t->diskstream();
-               /* XXX grrr: when will SigC++ allow me to bind references? */
-               Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun (*this, &StreamView::display_diskstream), &ds));
+               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));
        }
@@ -302,7 +275,10 @@ StreamView::region_layered (RegionView* rv)
           get events - the  parent group does instead ...
        */
        
-       rv->get_canvas_group()->raise (rv->region().layer() + 1);
+       /* this used to be + 1, but regions to the left ended up below
+         ..something.. and couldn't receive events.  why?  good question.
+       */
+       rv->get_canvas_group()->raise (rv->region()->layer() + 2);
 }
 
 void
@@ -329,7 +305,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;
                
@@ -353,11 +329,11 @@ StreamView::update_rec_box ()
 }
        
 RegionView*
-StreamView::find_view (const Region& region)
+StreamView::find_view (boost::shared_ptr<const Region> region)
 {
        for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
 
-               if (&(*i)->region() == &region) {
+               if ((*i)->region() == region) {
                        return *i;
                }
        }
@@ -394,10 +370,10 @@ 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) {
+               if ((*i)->region()->coverage(start, end) != OverlapNone) {
                        results.push_back (*i);
                }
        }