Implement new Enclosed region equivalence mode
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Thu, 13 Sep 2018 18:05:47 +0000 (14:05 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 13 Sep 2018 18:05:47 +0000 (14:05 -0400)
gtk2_ardour/rc_option_editor.cc
libs/ardour/ardour/rc_configuration_vars.h
libs/ardour/ardour/region.h
libs/ardour/ardour/types.h
libs/ardour/ardour/types_convert.h
libs/ardour/enums.cc
libs/ardour/playlist.cc
libs/ardour/region.cc

index e086363a237812d84ba055d5e0848db2ab11c9f0..8cca0227f84c62e02607e091903ec4d889d1b4ea 100644 (file)
@@ -2138,7 +2138,6 @@ RCOptionEditor::RCOptionEditor ()
 
        uint32_t hwcpus = hardware_concurrency ();
        BoolOption* bo;
-       BoolComboOption* bco;
 
        if (hwcpus > 1) {
                add_option (_("General"), new OptionEditorHeading (_("DSP CPU Utilization")));
@@ -2444,16 +2443,18 @@ RCOptionEditor::RCOptionEditor ()
 
        add_option (_("Editor"), fadeshape);
 
-       bco = new BoolComboOption (
-                    "use-overlap-equivalency",
-                    _("Regions in edit groups are edited together"),
-                    _("whenever they overlap in time"),
-                    _("only if they have identical length and position"),
-                    sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
-                    sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
+       ComboOption<RegionEquivalence> *eqv = new ComboOption<RegionEquivalence> (
+                    "region-equivalence",
+                    _("Regions in active edit groups are edited together"),
+                    sigc::mem_fun (*_rc_config, &RCConfiguration::get_region_equivalence),
+                    sigc::mem_fun (*_rc_config, &RCConfiguration::set_region_equivalence)
                     );
 
-       add_option (_("Editor"), bco);
+       eqv->add (Overlap, _("whenever they overlap in time"));
+       eqv->add (Enclosed, _("if either encloses the other"));
+       eqv->add (Exact, _("only if they have identical length, position and origin"));
+
+       add_option (_("Editor"), eqv);
 
        ComboOption<LayerModel>* lm = new ComboOption<LayerModel> (
                "layer-model",
index 681c51a32c6f29234d0875eec5fc8a17bbd04918..b7ee95e9e5a145175bca20b4bc051de760cfd6b2 100644 (file)
@@ -212,7 +212,7 @@ CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture",
 CONFIG_VARIABLE (bool, save_history, "save-history", true)
 CONFIG_VARIABLE (int32_t, saved_history_depth, "save-history-depth", 20)
 CONFIG_VARIABLE (int32_t, history_depth, "history-depth", 20)
-CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", false)
+CONFIG_VARIABLE (RegionEquivalence, region_equivalence, "region-equivalence", Enclosed)
 CONFIG_VARIABLE (bool, periodic_safety_backups, "periodic-safety-backups", true)
 CONFIG_VARIABLE (uint32_t, periodic_safety_backup_interval, "periodic-safety-backup-interval", 120)
 CONFIG_VARIABLE (float, automation_interval_msecs, "automation-interval-msecs", 30)
index b536aa16a9381ca4e3dbc9202253b56c209e4900..5d0413beb8baed9179e3c0694fb43f54a4c41357 100644 (file)
@@ -201,9 +201,10 @@ public:
                return Evoral::coverage (first_sample(), last_sample(), start, end);
        }
 
-       bool equivalent (boost::shared_ptr<const Region>) const;
+       bool exact_equivalent (boost::shared_ptr<const Region>) const;
        bool size_equivalent (boost::shared_ptr<const Region>) const;
        bool overlap_equivalent (boost::shared_ptr<const Region>) const;
+       bool enclosed_equivalent (boost::shared_ptr<const Region>) const;
        bool region_list_equivalent (boost::shared_ptr<const Region>) const;
        bool source_equivalent (boost::shared_ptr<const Region>) const;
        bool any_source_equivalent (boost::shared_ptr<const Region>) const;
index f835a5ff0764332750ffe0eadf1e78fc44653464..366e3031862dcb4efa5c50dc6f7516adcc79fcd6 100644 (file)
@@ -605,6 +605,12 @@ namespace ARDOUR {
        class Bundle;
        typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
 
+       enum RegionEquivalence {
+               Exact,
+               Enclosed,
+               Overlap
+       };
+
        enum WaveformScale {
                Linear,
                Logarithmic
index 83176149893288ea212500b5fa8c181c6d43d9e4..dcdc49fae3033e230ee44a9e4c420d4d1ee44495 100644 (file)
@@ -68,6 +68,7 @@ DEFINE_ENUM_CONVERT(ARDOUR::PluginType)
 DEFINE_ENUM_CONVERT(ARDOUR::AlignStyle)
 DEFINE_ENUM_CONVERT(ARDOUR::AlignChoice)
 
+DEFINE_ENUM_CONVERT(ARDOUR::RegionEquivalence)
 DEFINE_ENUM_CONVERT(ARDOUR::WaveformScale)
 DEFINE_ENUM_CONVERT(ARDOUR::WaveformShape)
 DEFINE_ENUM_CONVERT(ARDOUR::VUMeterStandard)
index 74e445a379da6e6170e690e5b9b95adc656a3e59..1173a99b076cebdd3861eb6b8a7ead013630b9e8 100644 (file)
@@ -127,6 +127,7 @@ setup_enum_writer ()
        MidiModel::NoteDiffCommand::Property _MidiModel_NoteDiffCommand_Property;
        MidiModel::SysExDiffCommand::Property _MidiModel_SysExDiffCommand_Property;
        MidiModel::PatchChangeDiffCommand::Property _MidiModel_PatchChangeDiffCommand_Property;
+       RegionEquivalence _RegionEquivalence;
        WaveformScale _WaveformScale;
        WaveformShape _WaveformShape;
        Session::PostTransportWork _Session_PostTransportWork;
@@ -685,6 +686,11 @@ setup_enum_writer ()
        REGISTER_ENUM(MidiPortSelection);
        REGISTER_BITS(_MidiPortFlags);
 
+       REGISTER_ENUM(Exact);
+       REGISTER_ENUM(Enclosed);
+       REGISTER_ENUM(Overlap);
+       REGISTER(_RegionEquivalence);
+
        REGISTER_ENUM(Linear);
        REGISTER_ENUM(Logarithmic);
        REGISTER(_WaveformScale);
index c3b91f3f45ffd12deb7668654e93832b0906234a..c992c1057906a1029dc55674d5130b6a52f68a0a 100644 (file)
@@ -839,18 +839,28 @@ Playlist::remove_region_internal (boost::shared_ptr<Region> region)
 void
 Playlist::get_equivalent_regions (boost::shared_ptr<Region> other, vector<boost::shared_ptr<Region> >& results)
 {
-       if (Config->get_use_overlap_equivalency()) {
-               for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
-                       if ((*i)->overlap_equivalent (other)) {
-                               results.push_back (*i);
-                       }
-               }
-       } else {
-               for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
-                       if ((*i)->equivalent (other)) {
-                               results.push_back (*i);
-                       }
-               }
+       switch (Config->get_region_equivalence()) {
+                case Exact:
+                        for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+                                if ((*i)->exact_equivalent (other)) {
+                                        results.push_back (*i);
+                                }
+                        }
+                        break;
+                case Enclosed:
+                        for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+                                if ((*i)->enclosed_equivalent (other)) {
+                                        results.push_back (*i);
+                                }
+                        }
+                        break;
+                case Overlap:
+                        for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+                                if ((*i)->overlap_equivalent (other)) {
+                                        results.push_back (*i);
+                                }
+                        }
+                        break;
        }
 }
 
index cad32cd4d7aa8cbe7893fa821a2599cccbaf1044..d4afb7d9c404729690d98021ac89f22c10d6f4a1 100644 (file)
@@ -1478,7 +1478,14 @@ Region::overlap_equivalent (boost::shared_ptr<const Region> other) const
 }
 
 bool
-Region::equivalent (boost::shared_ptr<const Region> other) const
+Region::enclosed_equivalent (boost::shared_ptr<const Region> other) const
+{
+       return (first_sample() >= other->first_sample() && last_sample() <= other->last_sample()) ||
+              (first_sample() <= other->first_sample() && last_sample() >= other->last_sample()) ;
+}
+
+bool
+Region::exact_equivalent (boost::shared_ptr<const Region> other) const
 {
        return _start == other->_start &&
                _position == other->_position &&