Flip stacked regions order so that the highest layer is at the top of the pile. ...
authorCarl Hetherington <carl@carlh.net>
Wed, 31 Dec 2008 18:44:32 +0000 (18:44 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 31 Dec 2008 18:44:32 +0000 (18:44 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4363 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/region_view.cc
gtk2_ardour/region_view.h
gtk2_ardour/streamview.cc
gtk2_ardour/streamview.h
libs/ardour/audio_playlist.cc

index 419ee9b606ccf2bed016f18cae64e42cb3c65cde..fc0253a27239fec64d48eef342461e192841b402 100644 (file)
@@ -179,6 +179,10 @@ RegionView::~RegionView ()
                delete *g;
        }
 
+       for (std::list<ArdourCanvas::SimpleRect*>::iterator i = _coverage_frames.begin (); i != _coverage_frames.end (); ++i) {
+               delete *i;
+       }
+
        delete editor;
 }
 
@@ -598,3 +602,72 @@ RegionView::set_height (double h)
        }
 }
 
+/** Remove old coverage frames and make new ones, if we're in a LayerDisplay mode
+ *  which uses them. */
+void
+RegionView::update_coverage_frames (LayerDisplay d)
+{
+       /* remove old coverage frames */
+       for (std::list<ArdourCanvas::SimpleRect*>::iterator i = _coverage_frames.begin (); i != _coverage_frames.end (); ++i) {
+               delete *i;
+       }
+
+       _coverage_frames.clear ();
+
+       if (d != Stacked) {
+               /* don't do coverage frames unless we're in stacked mode */
+               return;
+       }
+
+       boost::shared_ptr<Playlist> pl (_region->playlist ());
+       if (!pl) {
+               return;
+       }
+
+       nframes_t const position = _region->first_frame ();
+       nframes_t t = position;
+       nframes_t const end = _region->last_frame ();
+
+       ArdourCanvas::SimpleRect* cr = 0;
+       bool me = false;
+
+       uint32_t const color = frame->property_fill_color_rgba ();
+       uint32_t const base_alpha = UINT_RGBA_A (color);
+       
+       while (t < end) {
+
+               t++;
+
+               /* is this region is on top at time t? */
+               bool const new_me = (pl->top_region_at (t) == _region);
+
+               /* finish off any old rect, if required */
+               if (cr && me != new_me) {
+                       cr->property_x2() = trackview.editor.frame_to_pixel (t - position);
+               }
+
+               /* start off any new rect, if required */
+               if (cr == 0 || me != new_me) {
+                       cr = new ArdourCanvas::SimpleRect (*group);
+                       _coverage_frames.push_back (cr);
+                       cr->property_x1() = trackview.editor.frame_to_pixel (t - position);
+                       cr->property_y1() = 1;
+                       cr->property_y2() = _height + 1;
+                       cr->property_outline_pixels() = 0;
+                       /* areas that will be played get a lower alpha */
+                       uint32_t alpha = base_alpha;
+                       if (new_me) {
+                               alpha /= 2;
+                       }
+                       cr->property_fill_color_rgba () = UINT_RGBA_CHANGE_A (color, alpha);
+               }
+
+               t = pl->find_next_region_boundary (t, 1);
+               me = new_me;
+       }
+
+       if (cr) {
+               /* finish off the last rectangle */
+               cr->property_x2() = trackview.editor.frame_to_pixel (end - position);
+       }
+}
index b9258396d93e17c03c07e3ff729fdaf2a627f6c2..11c6c7e556a929dc222be67636e5101b1e5032ea 100644 (file)
@@ -87,6 +87,7 @@ class RegionView : public TimeAxisViewItem
        virtual void exited () {}
 
        void enable_display(bool yn) { _enable_display = yn; }
+       void update_coverage_frames (LayerDisplay);
        
        static sigc::signal<void,RegionView*> RegionViewGoingAway;
        
@@ -143,6 +144,12 @@ class RegionView : public TimeAxisViewItem
     sigc::connection data_ready_connection;
     
     std::vector<GhostRegion*> ghosts;
+
+       /** a list of rectangles which are used in stacked display mode to colour
+           different bits of regions according to whether or not they are the one
+           that will be played at any given time.
+       */
+       std::list<ArdourCanvas::SimpleRect*> _coverage_frames;
        
        typedef std::map<const Evoral::Parameter, boost::shared_ptr<AutomationRegionView> > AutomationChildren;
        AutomationChildren _automation_children;
index 1875fb2e92e1a4fa0ebbc29c8fba46650a4d7191..0d868ac645a0e187b7c6850d329d76a05d220379 100644 (file)
@@ -233,6 +233,7 @@ StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
        if (ds->playlist()) {
                layers = ds->playlist()->top_layer() + 1;
                update_contents_height ();
+               update_coverage_frames ();
                redisplay_diskstream ();
        }
 }
@@ -255,6 +256,8 @@ StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
        /* update layers count and the y positions and heights of our regions */
        layers = ds->playlist()->top_layer() + 1;
        update_contents_height ();
+
+       update_coverage_frames ();
        
        /* draw it */
        redisplay_diskstream ();
@@ -435,7 +438,7 @@ StreamView::update_contents_height ()
                        (*i)->set_height (height);
                        break;
                case Stacked:
-                       (*i)->set_y ((*i)->region()->layer() * lh);
+                       (*i)->set_y (height - ((*i)->region()->layer() + 1) * lh);
                        (*i)->set_height (lh);
                        break;
                }
@@ -451,4 +454,13 @@ StreamView::set_layer_display (LayerDisplay d)
 {
        layer_display = d;
        update_contents_height ();
+       update_coverage_frames ();
+}
+
+void
+StreamView::update_coverage_frames ()
+{
+       for (RegionViewList::iterator i = region_views.begin (); i != region_views.end (); ++i) {
+               (*i)->update_coverage_frames (layer_display);
+       }
 }
index fa330dafaee092d96ae97e641745b8558852f97b..10bbe8da36794905a2ad0c5b7aada46f5562d09b 100644 (file)
@@ -157,6 +157,10 @@ protected:
 
        list<sigc::connection> rec_data_ready_connections;
        jack_nframes_t         last_rec_data_frame;
+
+private:
+
+       void update_coverage_frames ();
 };
 
 #endif /* __ardour_streamview_h__ */
index 1506d204f15f6400d49e6db7f5811780ce051455..a17ab1036f24ca1f00a3ff00df887f046114243c 100644 (file)
@@ -676,7 +676,7 @@ AudioPlaylist::destroy_region (boost::shared_ptr<Region> region)
                return false;
        }
 
-       { 
+       {
                RegionLock rlock (this);
 
                for (RegionList::iterator i = regions.begin(); i != regions.end(); ) {