First part of consolidating ::roll(), ::no_roll()
[ardour.git] / libs / ardour / region_factory.cc
index 33c714cd1d80c8d3bb337e9f448cf5a7b528865a..9ecc6e10dab54c779c95e1ddfbaa9844cec5cc74 100644 (file)
@@ -30,7 +30,7 @@
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
@@ -46,7 +46,7 @@ std::map<std::string, PBD::ID>                RegionFactory::region_name_map;
 RegionFactory::CompoundAssociations           RegionFactory::_compound_associations;
 
 boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
+RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bool fork)
 {
        boost::shared_ptr<Region> ret;
        boost::shared_ptr<const AudioRegion> ar;
@@ -54,11 +54,11 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
 
        if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
 
-               ret = boost::shared_ptr<Region> (new AudioRegion (ar, 0));
+               ret = boost::shared_ptr<Region> (new AudioRegion (ar, MusicSample (0, 0)));
 
        } else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
 
-               if (mr->session().config.get_midi_copy_is_fork()) {
+               if (mr->session().config.get_midi_copy_is_fork() || fork) {
                        /* What we really want to do here is what Editor::fork_region()
                           does via Session::create_midi_source_by_stealing_name(), but we
                           don't have a Track.  We'll just live with the skipped number,
@@ -71,7 +71,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
                        source->set_ancestor_name(mr->sources().front()->name());
                        ret = mr->clone(source);
                } else {
-                       ret = boost::shared_ptr<Region> (new MidiRegion (mr, 0));
+                       ret = boost::shared_ptr<Region> (new MidiRegion (mr, MusicSample (0, 0)));
                }
 
        } else {
@@ -82,9 +82,8 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
 
        if (ret) {
                ret->set_name (new_region_name(ret->name()));
-               ret->set_position (region->position());
 
-               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
                        ret->set_position_lock_style (MusicTime);
                }
 
@@ -126,7 +125,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
        if (ret) {
                ret->apply_changes (plist);
 
-               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
                        ret->set_position_lock_style (MusicTime);
                }
 
@@ -143,7 +142,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
 }
 
 boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, const PropertyList& plist, bool announce)
+RegionFactory::create (boost::shared_ptr<Region> region, MusicSample offset, const PropertyList& plist, bool announce)
 {
        boost::shared_ptr<Region> ret;
        boost::shared_ptr<const AudioRegion> other_a;
@@ -167,7 +166,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, c
        if (ret) {
                ret->apply_changes (plist);
 
-               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
                        ret->set_position_lock_style (MusicTime);
                }
 
@@ -208,7 +207,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
        if (ret) {
                ret->apply_changes (plist);
 
-               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
                        ret->set_position_lock_style (MusicTime);
                }
 
@@ -252,7 +251,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
        if (ret) {
                ret->apply_changes (plist);
 
-               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
                        ret->set_position_lock_style (MusicTime);
                }
 
@@ -635,7 +634,7 @@ RegionFactory::get_regions_using_source (boost::shared_ptr<Source> s, std::set<b
 {
        Glib::Threads::Mutex::Lock lm (region_map_lock);
 
-       for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+       for (RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
                if (i->second->uses_source (s)) {
                        r.insert (i->second);
                }