change appearance of panner data popup slightly (fixed width font so it doesn't bounc...
[ardour.git] / gtk2_ardour / rhythm_ferret.cc
index 956a012697c1b7cb58d0041e821e61edbef92ac1..0eb9e9640654fd2e4000dfe600a6befc91e9d985 100644 (file)
@@ -48,8 +48,8 @@ static const gchar * _onset_function_strings[] = {
 
 static const gchar * _operation_strings[] = {
        N_("Split region"),
-       N_("Set tempo map"),
-       N_("Conform region"),
+       N_("Snap regions"),
+       N_("Conform regions"),
        0
 };
 
@@ -168,7 +168,7 @@ RhythmFerret::Action
 RhythmFerret::get_action () const
 {
        if (operation_selector.get_active_row_number() == 1) {
-               return DefineTempoMap;
+               return SnapRegionsToGrid;
        } else if (operation_selector.get_active_row_number() == 2) {
                return ConformRegion;
        }
@@ -183,15 +183,17 @@ RhythmFerret::run_analysis ()
                return;
        }
 
-       RegionSelection& regions (editor.get_selection().regions);
+       clear_transients ();
+
+       regions_with_transients = editor.get_selection().regions;
 
        current_results.clear ();
 
-       if (regions.empty()) {
+       if (regions_with_transients.empty()) {
                return;
        }
 
-       for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
+       for (RegionSelection::iterator i = regions_with_transients.begin(); i != regions_with_transients.end(); ++i) {
 
                boost::shared_ptr<Readable> rd = boost::static_pointer_cast<AudioRegion> ((*i)->region());
 
@@ -212,7 +214,7 @@ RhythmFerret::run_analysis ()
 }
 
 int
-RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t /*offset*/, AnalysisFeatureList& results)
+RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
 {
        TransientDetector t (_session->frame_rate());
 
@@ -265,7 +267,7 @@ RhythmFerret::get_note_onset_function ()
 }
 
 int
-RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t /*offset*/, AnalysisFeatureList& results)
+RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
 {
        try {
                OnsetDetector t (_session->frame_rate());
@@ -319,6 +321,9 @@ RhythmFerret::do_action ()
        case SplitRegion:
                do_split_action ();
                break;
+       case SnapRegionsToGrid:
+               editor.snap_regions_to_grid();
+               break;
        case ConformRegion:
                editor.close_region_gaps();
                break;
@@ -330,12 +335,12 @@ RhythmFerret::do_action ()
 void
 RhythmFerret::do_split_action ()
 {
-       /* this can/will change the current selection, so work with a copy */
-
-       //RegionSelection& regions (editor.get_selection().regions);
-       RegionSelection regions;
-       editor.get_regions_for_action(regions);
-
+       /* XXX: this is quite a special-case; (currently) the only operation which is
+          performed on the selection only (without entered_regionview or the edit point
+          being considered)
+       */
+       RegionSelection regions = editor.get_regions_from_selection();
+       
        if (regions.empty()) {
                return;
        }
@@ -350,7 +355,7 @@ RhythmFerret::do_split_action ()
                AnalysisFeatureList features;
                features = (*i)->region()->transients();
                
-               merged_features.insert (merged_features.end(), features.begin(), features.end());               
+               merged_features.insert (merged_features.end(), features.begin(), features.end());
        }
        
        merged_features.sort();
@@ -365,7 +370,7 @@ RhythmFerret::do_split_action ()
 
                AnalysisFeatureList features;
                features = (*i)->region()->transients();
-               editor.split_region_at_points ((*i)->region(), merged_features, false);
+               editor.split_region_at_points ((*i)->region(), merged_features, false, true);
 
                /* i is invalid at this point */
 
@@ -386,5 +391,17 @@ void
 RhythmFerret::on_hide ()
 {
        ArdourDialog::on_hide ();
+       clear_transients ();
+}
+
+/* Clear any transients that we have added */
+void
+RhythmFerret::clear_transients ()
+{
+       current_results.clear ();
+       for (RegionSelection::iterator i = regions_with_transients.begin(); i != regions_with_transients.end(); ++i) {
+               (*i)->region()->set_transients (current_results);
+       }
+       regions_with_transients.clear ();
 }