correct the logic used when building a compound region to include a whole-file (whole...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 May 2011 12:19:24 +0000 (12:19 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 May 2011 12:19:24 +0000 (12:19 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9584 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/route_time_axis.cc
libs/ardour/ardour/playlist.h
libs/ardour/ardour/region_factory.h
libs/ardour/playlist.cc
libs/ardour/region_factory.cc

index bbdc369ede0c5e5a9c5c5010a1e598a701d786ba..f1e00978e98b39b2940d24116069ec835ce7e4db 100644 (file)
@@ -2480,10 +2480,9 @@ RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param,
 }
 
 static
-void add_region_to_list (RegionView* rv, Playlist::RegionList* l, uint32_t* max_level)
+void add_region_to_list (RegionView* rv, Playlist::RegionList* l)
 {
        l->push_back (rv->region());
-       *max_level = max (*max_level, rv->region()->max_source_level());
 }
 
 RegionView*
@@ -2497,14 +2496,11 @@ RouteTimeAxisView::combine_regions ()
 
        Playlist::RegionList selected_regions;
        boost::shared_ptr<Playlist> playlist = track()->playlist();
-       uint32_t max_level = 0;
 
-       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
+       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions));
        
-       string name = RegionFactory::compound_region_name (playlist->name(), playlist->combine_ops(), max_level);
-
        playlist->clear_changes ();
-       boost::shared_ptr<Region> compound_region = playlist->combine (selected_regions, name);
+       boost::shared_ptr<Region> compound_region = playlist->combine (selected_regions);
 
        _session->add_command (new StatefulDiffCommand (playlist));
        /* make the new region be selected */
@@ -2523,13 +2519,12 @@ RouteTimeAxisView::uncombine_regions ()
 
        Playlist::RegionList selected_regions;
        boost::shared_ptr<Playlist> playlist = track()->playlist();
-       uint32_t max_level = 0;
 
        /* have to grab selected regions first because the uncombine is going
         * to change that in the middle of the list traverse
         */
 
-       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
+       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions));
 
        playlist->clear_changes ();
 
index 5eaf10273dcccf7653a36804613cdcdf14f66b62..5406886faa24bd40a48c6facb7f6d5e14f4fdb5b 100644 (file)
@@ -139,7 +139,7 @@ public:
        void partition (framepos_t start, framepos_t end, bool cut = false);
        void duplicate (boost::shared_ptr<Region>, framepos_t position, float times);
        void nudge_after (framepos_t start, framecnt_t distance, bool forwards);
-       boost::shared_ptr<Region> combine (const RegionList&, const std::string&);
+       boost::shared_ptr<Region> combine (const RegionList&);
        void uncombine (boost::shared_ptr<Region>);
 
        void shuffle (boost::shared_ptr<Region>, int dir);
index 7feca254955e8ba48d90fe7db6b715811ef84abe..90716f8718acf0b0d00e5cd0d49283a7535fc691 100644 (file)
@@ -91,7 +91,7 @@ public:
 
        static int region_name (std::string &, std::string, bool new_level = false);
        static std::string new_region_name (std::string);
-       static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth);
+       static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source);
   
        /* when we make a compound region, for every region involved there
         * are two "instances" - the original, which is removed from this
index 4157ab4459dd2e955885e58e2cd1bf96bf663991..4a5405841ff2dc01fbfb0c72aea93301547ee2f0 100644 (file)
@@ -3153,15 +3153,27 @@ Playlist::find_next_top_layer_position (framepos_t t) const
 }
 
 boost::shared_ptr<Region>
-Playlist::combine (const RegionList& r, const std::string& name)
+Playlist::combine (const RegionList& r)
 {
        PropertyList plist; 
        uint32_t channels = 0;
        uint32_t layer = 0;
        framepos_t earliest_position = max_framepos;
        vector<TwoRegions> old_and_new_regions;
+       string parent_name;
+       string child_name;
+       uint32_t max_level = 0;
 
-       boost::shared_ptr<Playlist> pl = PlaylistFactory::create (_type, _session, name, true);
+       /* find the maximum depth of all the regions we're combining */
+
+       for (RegionList::const_iterator i = r.begin(); i != r.end(); ++i) {
+               max_level = max (max_level, (*i)->max_source_level());
+       }
+
+       parent_name = RegionFactory::compound_region_name (name(), combine_ops(), max_level, true);
+       child_name = RegionFactory::compound_region_name (name(), combine_ops(), max_level, false);
+
+       boost::shared_ptr<Playlist> pl = PlaylistFactory::create (_type, _session, parent_name, true);
 
        for (RegionList::const_iterator i = r.begin(); i != r.end(); ++i) {
                earliest_position = min (earliest_position, (*i)->position());
@@ -3205,17 +3217,29 @@ Playlist::combine (const RegionList& r, const std::string& name)
        pair<framepos_t,framepos_t> extent = pl->get_extent();
        
        for (uint32_t chn = 0; chn < channels; ++chn) {
-               sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, name, chn, 0, extent.second, false, false));
+               sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, parent_name, chn, 0, extent.second, false, false));
        }
        
-       /* now a new region using the list of sources */
+       /* now a new whole-file region using the list of sources */
 
        plist.add (Properties::start, 0);
        plist.add (Properties::length, extent.second);
-       plist.add (Properties::name, name);
+       plist.add (Properties::name, parent_name);
+       plist.add (Properties::whole_file, true);
+
+       boost::shared_ptr<Region> parent_region = RegionFactory::create (sources, plist, true);
+
+       /* now the non-whole-file region that we will actually use in the
+        * playlist 
+        */
+
+       plist.clear ();
+       plist.add (Properties::start, 0);
+       plist.add (Properties::length, extent.second);
+       plist.add (Properties::name, child_name);
        plist.add (Properties::layer, layer+1);
-       
-       boost::shared_ptr<Region> compound_region = RegionFactory::create (sources, plist, true);
+
+       boost::shared_ptr<Region> compound_region = RegionFactory::create (parent_region, plist, true);
 
        /* add any dependent regions to the new playlist */
 
@@ -3256,8 +3280,8 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
 
        pl = pls->playlist();
 
-       framepos_t adjusted_start;
-       framepos_t adjusted_end;
+       framepos_t adjusted_start = 0; // gcc isn't smart enough
+       framepos_t adjusted_end = 0;   // gcc isn't smart enough
 
        /* the leftmost (earliest) edge of the compound region
           starts at zero in its source, or larger if it
index 9dbd0ded3710cdb085c8ff6af95db982ded310af..f4fd209fea964e1fd3b02dda9b660f3414d7d3f9 100644 (file)
@@ -488,9 +488,13 @@ RegionFactory::region_name (string& result, string base, bool newlevel)
 }
 
 string
-RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth)
+RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source)
 {
-       return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
+       if (whole_source) {
+               return string_compose (_("%1 compound-%2 (%3)"), playlist, compound_ops+1, depth+1);
+       } else {
+               return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
+       }
 }
 
 string