13
0

change API of Editor::get_quantize_op() and fix flaky UX when using quantize-notes

This commit is contained in:
Paul Davis 2023-09-24 15:00:28 -06:00
parent 6db28ef08d
commit 61d8ceaa85
4 changed files with 35 additions and 45 deletions

View File

@ -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 ();

View File

@ -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)
{

View File

@ -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

View File

@ -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;