From d3272a6400c2d1d7bf400f2b961d9ed26926b476 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 12 Nov 2024 08:51:29 -0700 Subject: [PATCH] midi cue editor: don't allocate space for automation till asked to do so --- gtk2_ardour/midi_cue_editor.cc | 10 +++++----- gtk2_ardour/midi_cue_view.cc | 21 +++++++++++++++------ gtk2_ardour/midi_cue_view.h | 2 ++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 143adcaecf..d7d751841e 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -141,11 +141,11 @@ MidiCueEditor::build_lower_toolbar () button_bar.pack_start (*pressure_button, false, false); button_bar.pack_start (*modulation_button, false, false); - velocity_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiVelocityAutomation, 0), false); - pressure_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiChannelPressureAutomation, 0), false); - bender_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiPitchBenderAutomation, 0), false); - modulation_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_MODWHEEL), false); - expression_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_EXPRESSION), false); + velocity_button->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiVelocityAutomation, 0), false); + pressure_button->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiChannelPressureAutomation, 0), false); + bender_button->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiPitchBenderAutomation, 0), false); + modulation_button->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_MODWHEEL), false); + expression_button->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_EXPRESSION), false); _toolbox.pack_start (button_bar, false, false); } diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index b67df523fb..8b8285b8dd 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -56,6 +56,7 @@ MidiCueView::MidiCueView (std::shared_ptr mt, , active_automation (nullptr) , velocity_display (nullptr) , _slot_index (slot_index) + , _height (0.) { CANVAS_DEBUG_NAME (_note_group, X_("note group for MIDI cue")); @@ -80,10 +81,6 @@ MidiCueView::MidiCueView (std::shared_ptr mt, set_extensible (true); - - /* show velocity by default */ - - update_automation_display (Evoral::Parameter (MidiVelocityAutomation, 0, 0), SelectionSet); } MidiCueView::~MidiCueView () @@ -94,8 +91,18 @@ MidiCueView::~MidiCueView () void MidiCueView::set_height (double h) { - double note_area_height = ceil (h / 2.); - double automation_height = ceil (h - note_area_height); + _height = h; + + double note_area_height; + double automation_height; + + if (automation_map.empty()) { + note_area_height = h; + automation_height = 0.; + } else { + note_area_height = ceil (h / 2.); + automation_height = ceil (h - note_area_height); + } event_rect->set (ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, note_area_height)); midi_context().set_size (midi_context().width(), note_area_height); @@ -350,6 +357,8 @@ MidiCueView::update_automation_display (Evoral::Parameter const & param, Selecti /* undefined in this context */ break; } + + set_height (_height); } std::list diff --git a/gtk2_ardour/midi_cue_view.h b/gtk2_ardour/midi_cue_view.h index f74fd2288a..4ba97040e8 100644 --- a/gtk2_ardour/midi_cue_view.h +++ b/gtk2_ardour/midi_cue_view.h @@ -115,4 +115,6 @@ class MidiCueView : public MidiView void update_sustained (Note *); void update_hit (Hit *); + + double _height; };