Add option to glue new regions to bars and beats (#4202).
authorCarl Hetherington <carl@carlh.net>
Thu, 24 Nov 2011 19:33:13 +0000 (19:33 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 24 Nov 2011 19:33:13 +0000 (19:33 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10821 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/session_option_editor.cc
libs/ardour/ardour/session_configuration_vars.h
libs/ardour/audio_region_importer.cc
libs/ardour/region.cc
libs/ardour/region_factory.cc

index ce461436b80f2a1b3fb2f0f5823786bc4941fcfe..98ca09bb691f00a2c25da1d70a6946e302751320 100644 (file)
@@ -326,6 +326,13 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
                            sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
                            sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
                            ));
+
+       add_option (_("Misc"), new BoolOption (
+                           "glue-new-regions-to-bars-and-beats",
+                           _("Glue new regions to bars and beats"),
+                           sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
+                           sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
+                           ));
 }
 
 void
index 6a9d4a81e647bcb64ecf652a4ea9265f9a7b7f40..9d854ab2f84c94f30d7162bc47506d88090a5458 100644 (file)
@@ -63,3 +63,4 @@ CONFIG_VARIABLE (framecnt_t, timecode_offset, "timecode-offset", 0)
 CONFIG_VARIABLE (bool, timecode_offset_negative, "timecode-offset-negative", true)
 CONFIG_VARIABLE (bool, glue_new_markers_to_bars_and_beats, "glue-new-markers-to-bars-and-beats", false)
 CONFIG_VARIABLE (bool, midi_copy_is_fork, "midi-copy-is-fork", false)
+CONFIG_VARIABLE (bool, glue_new_regions_to_bars_and_beats, "glue-new-regions-to-bars-and-beats", false)
index 775bd0119f1eca90009965704a16085d71fdfe51..6f6bd8250136b12db62632f5aa31dea555b1e43c 100644 (file)
@@ -317,7 +317,11 @@ AudioRegionImporter::prepare_region ()
        }
 
        // create region and update XML
-       region.push_back (RegionFactory::create (source_list, xml_region));
+       boost::shared_ptr<Region> r = RegionFactory::create (source_list, xml_region);
+       if (session.config.get_glue_new_regions_to_bars_and_beats ()) {
+               r->set_position_lock_style (MusicTime);
+       }
+       region.push_back (r);
        if (*region.begin()) {
                xml_region = (*region.begin())->get_state();
        } else {
index 5f5988a8bb011047c9454ac8677e699981bcf6ae..71aca0cce6d08d2e8ad364f982b1e5bcbe8632fa 100644 (file)
@@ -548,10 +548,6 @@ Region::set_position_lock_style (PositionLockStyle ps)
 
                boost::shared_ptr<Playlist> pl (playlist());
 
-               if (!pl) {
-                       return;
-               }
-
                _position_lock_style = ps;
 
                if (_position_lock_style == MusicTime) {
@@ -559,7 +555,6 @@ Region::set_position_lock_style (PositionLockStyle ps)
                }
 
                send_change (Properties::position_lock_style);
-
        }
 }
 
index fba60fe0a01b5f356e36de2ec16c5856d03c3982..4243d44cb7660a44701c17bf87f0940de8a22b05 100644 (file)
@@ -73,6 +73,11 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
 
        if (ret) {
                ret->set_name (new_region_name(ret->name()));
+
+               if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
+                       ret->set_position_lock_style (MusicTime);
+               }
+               
                map_add (ret);
 
                /* pure copy constructor - no property list */
@@ -111,6 +116,11 @@ 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 ()) {
+                       ret->set_position_lock_style (MusicTime);
+               }
+               
                map_add (ret);
 
                if (announce) {
@@ -148,6 +158,11 @@ 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 ()) {
+                       ret->set_position_lock_style (MusicTime);
+               }
+
                map_add (ret);
 
                if (announce) {
@@ -185,6 +200,11 @@ 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 ()) {
+                       ret->set_position_lock_style (MusicTime);
+               }
+
                map_add (ret);
 
                if (announce) {
@@ -225,6 +245,11 @@ 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 ()) {
+                       ret->set_position_lock_style (MusicTime);
+               }
+               
                map_add (ret);
 
                if (announce) {
@@ -268,6 +293,11 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
                        ret.reset ();
                } else {
                        map_add (ret);
+
+                       /* Don't fiddle with position_lock_style here as the region
+                          description is coming from XML.
+                       */
+                       
                        CheckNewRegion (ret);
                }
        }