move MIDNAM related widgets into their own window

Currently, the device mode selector never seems to show up, but this may have
been a pre-existing error, since the code that controls this has not changed.
This commit is contained in:
Paul Davis
2025-11-01 18:51:35 -06:00
parent 32b2bf9a13
commit 876ed98dbe
2 changed files with 22 additions and 25 deletions

View File

@@ -131,6 +131,7 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanva
, _channel_color_mode_item(nullptr)
, _track_color_mode_item(0)
, _channel_selector (nullptr)
, midnam_selector (nullptr)
, _step_edit_item (nullptr)
, controller_menu (nullptr)
, _step_editor (nullptr)
@@ -287,8 +288,6 @@ MidiTimeAxisView::set_route (std::shared_ptr<Route> rt)
/* this directly calls use_midnam_info() if there are midnam's already */
MIDI::Name::MidiPatchManager::instance().maybe_use (*this, invalidator (*this), std::bind (&MidiTimeAxisView::use_midnam_info, this), gui_context());
controls_vbox.pack_start(_midi_controls_box, false, false);
const string color_mode = gui_property ("color-mode");
if (!color_mode.empty()) {
_color_mode = ColorMode (string_2_enum(color_mode, _color_mode));
@@ -364,6 +363,9 @@ MidiTimeAxisView::~MidiTimeAxisView ()
delete _view;
_view = nullptr;
delete midnam_selector;
midnam_selector = nullptr;
delete _channel_selector;
_channel_selector = nullptr;
@@ -662,30 +664,9 @@ MidiTimeAxisView::midi_view()
return dynamic_cast<MidiStreamView*>(_view);
}
void
MidiTimeAxisView::update_midi_controls_visibility (uint32_t h)
{
if (_route && !_route->active ()) {
h = 0;
}
if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
_midi_controls_box.show ();
} else {
_midi_controls_box.hide();
}
}
void
MidiTimeAxisView::set_height (uint32_t h, TrackHeightMode m, bool from_idle)
{
update_midi_controls_visibility (h);
if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
_midi_controls_box.show ();
} else {
_midi_controls_box.hide();
}
update_scroomer_visbility (h, layer_display ());
/* We need to do this after changing visibility of our stuff, as it will
@@ -757,6 +738,9 @@ MidiTimeAxisView::append_extra_display_menu_items ()
items.push_back (MenuElem (_("Note Range"), *range_menu));
items.push_back (MenuElem (_("Note Mode"), *build_note_mode_menu()));
items.push_back (MenuElem (_("MIDNAM Selector..."),
sigc::mem_fun(*this, &MidiTimeAxisView::toggle_midnam_selector)));
items.push_back (MenuElem (_("Channel Selector..."),
sigc::mem_fun(*this, &MidiTimeAxisView::toggle_channel_selector)));
@@ -797,6 +781,18 @@ MidiTimeAxisView::toggle_channel_selector ()
}
}
void
MidiTimeAxisView::toggle_midnam_selector ()
{
if (!midnam_selector) {
midnam_selector = new ArdourWindow (string_compose (_("MIDNAM Selector for %1"), track()->name()));
midnam_selector->add (_midi_controls_box);
midnam_selector->show_all ();
} else {
midnam_selector->cycle_visibility ();
}
}
void
MidiTimeAxisView::build_automation_action_menu (bool for_selection)
{
@@ -1407,7 +1403,6 @@ MidiTimeAxisView::route_active_changed ()
{
RouteTimeAxisView::route_active_changed ();
update_control_names();
update_midi_controls_visibility (height);
if (!_route->active()) {
controls_table.hide();

View File

@@ -147,7 +147,6 @@ private:
void update_scroomer_visbility (uint32_t, LayerDisplay);
void update_control_names ();
void update_midi_controls_visibility (uint32_t);
bool _ignore_signals;
bool _asked_all_automation;
@@ -162,9 +161,11 @@ private:
Gtk::RadioMenuItem* _track_color_mode_item;
Gtk::VBox _midi_controls_box;
MidiChannelSelectorWindow* _channel_selector;
ArdourWidgets::ArdourDropdown _midnam_model_selector;
ArdourWidgets::ArdourDropdown _midnam_custom_device_mode_selector;
ArdourWidgets::ArdourDropdown _midnam_channel_selector;
ArdourWindow* midnam_selector;
Gtk::CheckMenuItem* _step_edit_item;
Gtk::Menu* default_channel_menu;
@@ -180,6 +181,7 @@ private:
void build_controller_menu ();
void toggle_restore_pgm_on_load ();
void toggle_channel_selector ();
void toggle_midnam_selector ();
void channel_selector_hidden ();
void set_channel_mode (ARDOUR::ChannelMode, uint16_t);