diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index d1c8d1e171..1f216b6fbc 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1391,7 +1391,7 @@ private: void normalize_region (); void adjust_region_gain (bool up); void reset_region_gain (); - ARDOUR::Quantize get_quantize_op (bool force_dialog, bool& did_show_dialog); + ARDOUR::Quantize* get_quantize_op (); void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs); void set_tempo_curve_range (double& max, double& min) const; void quantize_region (); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 199b9cbb4d..9b35fdec22 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6220,51 +6220,44 @@ Editor::quantize_regions (const RegionSelection& rs) } bool ignored; - Quantize quant = get_quantize_op (true, ignored); + Quantize* quant = get_quantize_op (); - if (!quant.empty()) { - apply_midi_note_edit_op (quant, rs); + if (!quant) { + return; } + + if (!quant->empty()) { + apply_midi_note_edit_op (*quant, rs); + } + + delete quant; } -Quantize -Editor::get_quantize_op (bool force_dialog, bool& did_show_dialog) +Quantize* +Editor::get_quantize_op () { - did_show_dialog = false; - if (!quantize_dialog) { quantize_dialog = new QuantizeDialog (*this); - force_dialog = true; } - if (quantize_dialog->get_mapped()) { - /* in progress already */ - return Quantize (false, false, Temporal::Beats(), Temporal::Beats(), 0., 0., Temporal::Beats()); + quantize_dialog->present (); + int r = quantize_dialog->run (); + quantize_dialog->hide (); + + + if (r != Gtk::RESPONSE_OK) { + return nullptr; } - int r = Gtk::RESPONSE_OK; - - if (force_dialog) { - quantize_dialog->present (); - r = quantize_dialog->run (); - quantize_dialog->hide (); - did_show_dialog = true; - } - - if (r == Gtk::RESPONSE_OK) { - return Quantize (quantize_dialog->snap_start(), - quantize_dialog->snap_end(), - quantize_dialog->start_grid_size(), - quantize_dialog->end_grid_size(), - quantize_dialog->strength(), - quantize_dialog->swing(), - quantize_dialog->threshold()); - } - - return Quantize (false, false, Temporal::Beats(), Temporal::Beats(), 0., 0., Temporal::Beats()); + return new Quantize (quantize_dialog->snap_start(), + quantize_dialog->snap_end(), + quantize_dialog->start_grid_size(), + quantize_dialog->end_grid_size(), + quantize_dialog->strength(), + quantize_dialog->swing(), + quantize_dialog->threshold()); } - void Editor::legatize_region (bool shrink_only) { diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 01608a67d6..8a10b95ec7 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -4737,23 +4737,20 @@ MidiRegionView::note_to_y(uint8_t note) const void MidiRegionView::quantize_selected_notes () { + std::cerr << "QSN!\n"; + RegionSelection rs; rs.push_back (this); - bool did_show_dialog; - Quantize quant = trackview.editor().get_quantize_op (false, did_show_dialog); - bool success; + Quantize* quant = trackview.editor().get_quantize_op (); - if (!did_show_dialog) { - /* use global grid */ - quant.set_start_grid (trackview.editor().get_grid_type_as_beats (success, midi_region()->source_position())); - if (!success) { - return; - } - quant.set_end_grid (quant.start_grid()); + if (!quant) { + return; } - trackview.editor().apply_midi_note_edit_op (quant, rs); + trackview.editor().apply_midi_note_edit_op (*quant, rs); + + delete quant; } void diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 958f815e1b..2898b375c0 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -579,7 +579,7 @@ public: virtual void queue_redisplay_track_views () = 0; - virtual ARDOUR::Quantize get_quantize_op (bool force_dialog, bool& did_show_dialog) = 0; + virtual ARDOUR::Quantize* get_quantize_op () = 0; virtual void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs) = 0; virtual void set_tempo_curve_range (double& max, double& min) const = 0;