Set MIDI device mode to the first by default if unset.

Give up trying to hide mode selector when it's useless.
Fix display of program names for default mode.
Abstract out (non-crashy) MidiTimeAxisView::get_device_names().


git-svn-id: svn://localhost/ardour2/branches/3.0@13903 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2013-01-19 20:15:15 +00:00
parent 2d9a15087b
commit 444d89b669
4 changed files with 30 additions and 19 deletions

View File

@ -1232,7 +1232,7 @@ MidiRegionView::display_patch_changes_on_channel (uint8_t channel, bool active_c
continue;
}
string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel);
const string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel);
add_canvas_patch_change (*i, patch_name, active_channel);
}
}

View File

@ -231,6 +231,15 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
set_gui_property (X_("midnam-model-name"), "Generic");
}
if (gui_property (X_("midnam-custom-device-mode")).empty()) {
boost::shared_ptr<MIDI::Name::MasterDeviceNames> device_names = get_device_names(
gui_property (X_("midnam-model-name")));
if (device_names) {
set_gui_property (X_("midnam-custom-device-mode"),
*device_names->custom_device_mode_names().begin());
}
}
_midnam_model_selector.set_active_text (gui_property (X_("midnam-model-name")));
_midnam_custom_device_mode_selector.set_active_text (gui_property (X_("midnam-custom-device-mode")));
@ -373,14 +382,9 @@ MidiTimeAxisView::model_changed()
_midnam_custom_device_mode_selector.clear_items();
if (device_modes.size() < 2) {
_midnam_custom_device_mode_selector.hide();
} else {
_midnam_custom_device_mode_selector.show();
for (std::list<std::string>::const_iterator i = device_modes.begin();
i != device_modes.end(); ++i) {
_midnam_custom_device_mode_selector.append_text(*i);
}
for (std::list<std::string>::const_iterator i = device_modes.begin();
i != device_modes.end(); ++i) {
_midnam_custom_device_mode_selector.append_text(*i);
}
_midnam_custom_device_mode_selector.set_active(0);
@ -756,6 +760,19 @@ MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_
dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true);
}
boost::shared_ptr<MIDI::Name::MasterDeviceNames>
MidiTimeAxisView::get_device_names(const std::string& model)
{
using namespace MIDI::Name;
boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance()
.document_by_model(model);
if (midnam) {
return midnam->master_device_names(model);
} else {
return boost::shared_ptr<MasterDeviceNames>();
}
}
void
MidiTimeAxisView::build_controller_menu ()
{
@ -790,15 +807,9 @@ MidiTimeAxisView::build_controller_menu ()
}
using namespace MIDI::Name;
const Glib::ustring model = _midnam_model_selector.get_active_text();
boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance()
.document_by_model(model);
boost::shared_ptr<MasterDeviceNames> device_names;
boost::shared_ptr<MasterDeviceNames> device_names = get_device_names(
_midnam_model_selector.get_active_text());
if (midnam) {
device_names = midnam->master_device_names(model);
}
if (device_names && !device_names->controls().empty()) {
/* Controllers names available in midnam file, generate fancy menu */
unsigned n_items = 0;

View File

@ -111,6 +111,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
void build_automation_action_menu (bool);
Gtk::Menu* build_note_mode_menu();
Gtk::Menu* build_color_mode_menu();
boost::shared_ptr<MIDI::Name::MasterDeviceNames> get_device_names(const std::string& model);
void set_note_mode (ARDOUR::NoteMode mode, bool apply_to_selection = false);
void set_color_mode (ARDOUR::ColorMode, bool force = false, bool redisplay = true, bool apply_to_selection = false);

View File

@ -453,8 +453,6 @@ CustomDeviceMode::get_state(void)
boost::shared_ptr<CustomDeviceMode>
MasterDeviceNames::custom_device_mode_by_name(std::string mode_name)
{
// can't assert this, since in many of the patch files the mode name is empty
//assert(mode_name != "");
return _custom_device_modes[mode_name];
}