change the implementation of lower_region_to_bottom() and raise_region_to_top() to...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 2 Nov 2009 21:24:24 +0000 (21:24 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 2 Nov 2009 21:24:24 +0000 (21:24 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6004 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/playlist.cc

index 9cc23b52b68738c319f07aac140970c608e2b796..b8dc905e84e170ac5e601c7a026873a39d589b3e 100644 (file)
@@ -2017,22 +2017,44 @@ void
 Playlist::raise_region_to_top (boost::shared_ptr<Region> region)
 {
        /* does nothing useful if layering mode is later=higher */
-       if ((Config->get_layer_model() == MoveAddHigher) ||
-           (Config->get_layer_model() == AddHigher)) {
-               timestamp_layer_op (region);
-               relayer ();
+       switch (Config->get_layer_model()) {
+       case LaterHigher:
+               return;
        }
+
+       RegionList::size_type sz = regions.size();
+
+       if (region->layer() >= (sz - 1)) {
+               /* already on the top */
+               return;
+       }
+
+       move_region_to_layer (sz, region, 1);
+       /* mark the region's last_layer_op as now, so that it remains on top when
+          doing future relayers (until something else takes over)
+        */
+       timestamp_layer_op (region);
 }
 
 void
 Playlist::lower_region_to_bottom (boost::shared_ptr<Region> region)
 {
        /* does nothing useful if layering mode is later=higher */
-       if ((Config->get_layer_model() == MoveAddHigher) ||
-           (Config->get_layer_model() == AddHigher)) {
-               region->set_last_layer_op (0);
-               relayer ();
+       switch (Config->get_layer_model()) {
+       case LaterHigher:
+               return;
+       }
+
+       if (region->layer() == 0) {
+               /* already on the bottom */
+               return;
        }
+
+       move_region_to_layer (0, region, -1);
+       /* force region's last layer op to zero so that it stays at the bottom
+          when doing future relayers
+       */
+       region->set_last_layer_op (0);
 }
 
 int
@@ -2213,8 +2235,6 @@ Playlist::set_frozen (bool yn)
 void
 Playlist::timestamp_layer_op (boost::shared_ptr<Region> region)
 {
-//     struct timeval tv;
-//     gettimeofday (&tv, 0);
        region->set_last_layer_op (++layer_op_counter);
 }