From cc677d5c87265d6af7adc73d386a74511fee28cb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 31 Dec 2008 18:44:32 +0000 Subject: Flip stacked regions order so that the highest layer is at the top of the pile. Colour areas of stacked regions according to what will be played. git-svn-id: svn://localhost/ardour2/branches/3.0@4363 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/region_view.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'gtk2_ardour/region_view.cc') diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 419ee9b606..fc0253a272 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -179,6 +179,10 @@ RegionView::~RegionView () delete *g; } + for (std::list::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::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 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); + } +} -- cgit v1.2.3