diff options
author | Carl Hetherington <carl@carlh.net> | 2007-05-18 13:55:25 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2007-05-18 13:55:25 +0000 |
commit | 452daa63710c9e13d8fb47573a2525c5e58ef9f5 (patch) | |
tree | 02562cf9e8ee6857e5ac83ccf19593ec2d566167 | |
parent | de9187f0edd3937e4f78262854a079a2fdba6643 (diff) |
Remove region raise() and lower(). Try to do region layering better.
git-svn-id: svn://localhost/ardour2/trunk@1881 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 19 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/region_view.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/region_view.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/region.h | 2 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 156 | ||||
-rw-r--r-- | libs/ardour/region.cc | 18 |
9 files changed, 42 insertions, 185 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 51403c2992..c9af6aa309 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -870,9 +870,7 @@ class Editor : public PublicEditor void set_region_lock (bool); void set_region_position_lock (bool); void set_region_opaque (bool); - void raise_region (); void raise_region_to_top (); - void lower_region (); void lower_region_to_bottom (); void split_region (); void split_region_at (nframes_t); diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 5247b596b6..4570228742 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1006,25 +1006,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case 2: switch (mouse_mode) { - case MouseObject: - switch (item_type) { - case RegionItem: - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) { - raise_region (); - } else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::Shift|Keyboard::Alt))) { - lower_region (); - } else { - // Button2 click is unused - } - return true; - - break; - - default: - break; - } - break; - case MouseRange: // x_style_paste (where, 1.0); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 64884c358b..4de38a34af 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1709,24 +1709,12 @@ Editor::loop_location (Location& location) } void -Editor::raise_region () -{ - selection->foreach_region (&Region::raise); -} - -void Editor::raise_region_to_top () { selection->foreach_region (&Region::raise_to_top); } void -Editor::lower_region () -{ - selection->foreach_region (&Region::lower); -} - -void Editor::lower_region_to_bottom () { selection->foreach_region (&Region::lower_to_bottom); diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 3923f7e79a..9ee64d27d7 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -272,24 +272,12 @@ RegionView::region_opacity () } void -RegionView::raise () -{ - _region->raise (); -} - -void RegionView::raise_to_top () { _region->raise_to_top (); } void -RegionView::lower () -{ - _region->lower (); -} - -void RegionView::lower_to_bottom () { _region->lower_to_bottom (); diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index d16d81e373..c444d19fdc 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -65,9 +65,7 @@ class RegionView : public TimeAxisViewItem void move (double xdelta, double ydelta); - void raise (); void raise_to_top (); - void lower (); void lower_to_bottom (); bool set_position(nframes_t pos, void* src, double* delta = 0); diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index b1612f39d5..9eb66f66b6 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -125,8 +125,6 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f void freeze (); void thaw (); - void raise_region (boost::shared_ptr<Region>); - void lower_region (boost::shared_ptr<Region>); void raise_region_to_top (boost::shared_ptr<Region>); void lower_region_to_bottom (boost::shared_ptr<Region>); @@ -265,8 +263,6 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f boost::shared_ptr<Playlist> cut (nframes_t start, nframes_t cnt, bool result_is_hidden); boost::shared_ptr<Playlist> copy (nframes_t start, nframes_t cnt, bool result_is_hidden); - - int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir); void relayer (); void unset_freeze_parent (Playlist*); diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 9a00498371..64d4ee1d83 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -155,8 +155,6 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro void trim_to (nframes_t position, nframes_t length, void *src); void set_layer (layer_t l); /* ONLY Playlist can call this */ - void raise (); - void lower (); void raise_to_top (); void lower_to_bottom (); diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index de6d58dbd7..306f933f26 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1585,33 +1585,61 @@ Playlist::set_edit_mode (EditMode mode) void Playlist::relayer () { - RegionList::iterator i; - uint32_t layer = 0; - /* don't send multiple Modified notifications when multiple regions are relayered. */ freeze (); - if (Config->get_layer_model() == MoveAddHigher || - Config->get_layer_model() == AddHigher) { + /* build up a new list of regions on each layer */ - RegionSortByLastLayerOp cmp; - RegionList copy = regions; + std::vector<RegionList> layers; + /* we want to go through regions from desired lowest to desired highest layer, + which depends on the layer model + */ + RegionList copy = regions; + if (Config->get_layer_model() == MoveAddHigher || Config->get_layer_model() == AddHigher) { + RegionSortByLastLayerOp cmp; copy.sort (cmp); + } + + for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) { + + /* find the lowest layer that this region can go on */ + size_t j = layers.size(); + while (j > 0) { + /* try layer j - 1; it can go on if it overlaps no other region + that is already on that layer + */ + RegionList::iterator k = layers[j - 1].begin(); + while (k != layers[j - 1].end()) { + if ((*k)->overlap_equivalent (*i)) { + break; + } + k++; + } - for (i = copy.begin(); i != copy.end(); ++i) { - (*i)->set_layer (layer++); + if (k != layers[j - 1].end()) { + /* no overlap, so we can use this layer */ + break; + } + + j--; } - } else { - - /* Session::LaterHigher model */ + if (j == layers.size()) { + /* we need a new layer for this region */ + layers.push_back (RegionList ()); + } - for (i = regions.begin(); i != regions.end(); ++i) { - (*i)->set_layer (layer++); + layers[j].push_back (*i); + } + + /* set up the layer numbers in the regions */ + for (size_t j = 0; j < layers.size(); ++j) { + for (RegionList::iterator i = layers[j].begin(); i != layers[j].end(); ++i) { + (*i)->set_layer (j); } } @@ -1631,33 +1659,6 @@ Playlist::relayer () /* XXX these layer functions are all deprecated */ void -Playlist::raise_region (boost::shared_ptr<Region> region) -{ - uint32_t rsz = regions.size(); - layer_t target = region->layer() + 1U; - - if (target >= rsz) { - /* its already at the effective top */ - return; - } - - move_region_to_layer (target, region, 1); -} - -void -Playlist::lower_region (boost::shared_ptr<Region> region) -{ - if (region->layer() == 0) { - /* its already at the bottom */ - return; - } - - layer_t target = region->layer() - 1U; - - move_region_to_layer (target, region, -1); -} - -void Playlist::raise_region_to_top (boost::shared_ptr<Region> region) { /* does nothing useful if layering mode is later=higher */ @@ -1679,79 +1680,6 @@ Playlist::lower_region_to_bottom (boost::shared_ptr<Region> region) } } -int -Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr<Region> region, int dir) -{ - RegionList::iterator i; - typedef pair<boost::shared_ptr<Region>,layer_t> LayerInfo; - list<LayerInfo> layerinfo; - layer_t dest; - - { - RegionLock rlock (const_cast<Playlist *> (this)); - - for (i = regions.begin(); i != regions.end(); ++i) { - - if (region == *i) { - continue; - } - - if (dir > 0) { - - /* region is moving up, move all regions on intermediate layers - down 1 - */ - - if ((*i)->layer() > region->layer() && (*i)->layer() <= target_layer) { - dest = (*i)->layer() - 1; - } else { - /* not affected */ - continue; - } - } else { - - /* region is moving down, move all regions on intermediate layers - up 1 - */ - - if ((*i)->layer() < region->layer() && (*i)->layer() >= target_layer) { - dest = (*i)->layer() + 1; - } else { - /* not affected */ - continue; - } - } - - LayerInfo newpair; - - newpair.first = *i; - newpair.second = dest; - - layerinfo.push_back (newpair); - } - } - - /* now reset the layers without holding the region lock */ - - for (list<LayerInfo>::iterator x = layerinfo.begin(); x != layerinfo.end(); ++x) { - x->first->set_layer (x->second); - } - - region->set_layer (target_layer); - -#if 0 - /* now check all dependents */ - - for (list<LayerInfo>::iterator x = layerinfo.begin(); x != layerinfo.end(); ++x) { - check_dependents (x->first, false); - } - - check_dependents (region, false); -#endif - - return 0; -} - void Playlist::nudge_after (nframes_t start, nframes_t distance, bool forwards) { diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index d8a98ecefe..4e4b1c91af 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -853,24 +853,6 @@ Region::sync_position() const void -Region::raise () -{ - boost::shared_ptr<Playlist> pl (playlist()); - if (pl) { - pl->raise_region (shared_from_this ()); - } -} - -void -Region::lower () -{ - boost::shared_ptr<Playlist> pl (playlist()); - if (pl) { - pl->lower_region (shared_from_this ()); - } -} - -void Region::raise_to_top () { boost::shared_ptr<Playlist> pl (playlist()); |