+/** Add a single menu item for a controller on one channel. */
+void
+MidiTimeAxisView::add_single_channel_controller_item(Menu_Helpers::MenuList& ctl_items,
+ int ctl,
+ const std::string& name)
+{
+ using namespace Menu_Helpers;
+
+ const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
+ for (uint8_t chn = 0; chn < 16; chn++) {
+ if (selected_channels & (0x0001 << chn)) {
+
+ Evoral::Parameter fully_qualified_param (MidiCCAutomation, chn, ctl);
+ ctl_items.push_back (
+ CheckMenuElem (
+ string_compose ("<b>%1</b>: %2 [%3]", ctl, name, int (chn + 1)),
+ sigc::bind (
+ sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
+ fully_qualified_param)));
+ dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true);
+
+ boost::shared_ptr<AutomationTimeAxisView> track = automation_child (
+ fully_qualified_param);
+
+ bool visible = false;
+ if (track) {
+ if (track->marked_for_display()) {
+ visible = true;
+ }
+ }
+
+ Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&ctl_items.back());
+ _controller_menu_map[fully_qualified_param] = cmi;
+ cmi->set_active (visible);
+
+ /* one channel only */
+ break;
+ }
+ }
+}
+
+/** Add a submenu with 1 item per channel for a controller on many channels. */
+void
+MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_items,
+ int ctl,
+ const std::string& name)
+{
+ using namespace Menu_Helpers;
+
+ const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
+
+ Menu* chn_menu = manage (new Menu);
+ MenuList& chn_items (chn_menu->items());
+
+ /* add a couple of items to hide/show this controller on all channels */
+
+ Evoral::Parameter param_without_channel (MidiCCAutomation, 0, ctl);
+ chn_items.push_back (
+ MenuElem (_("Hide all channels"),
+ sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
+ false, param_without_channel)));
+ chn_items.push_back (
+ MenuElem (_("Show all channels"),
+ sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
+ true, param_without_channel)));
+
+ for (uint8_t chn = 0; chn < 16; chn++) {
+ if (selected_channels & (0x0001 << chn)) {
+
+ /* for each selected channel, add a menu item for this controller */
+
+ Evoral::Parameter fully_qualified_param (MidiCCAutomation, chn, ctl);
+ chn_items.push_back (
+ CheckMenuElem (string_compose (_("Channel %1"), chn+1),
+ sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
+ fully_qualified_param)));
+
+ boost::shared_ptr<AutomationTimeAxisView> track = automation_child (
+ fully_qualified_param);
+ bool visible = false;
+
+ if (track) {
+ if (track->marked_for_display()) {
+ visible = true;
+ }
+ }
+
+ Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&chn_items.back());
+ _controller_menu_map[fully_qualified_param] = cmi;
+ cmi->set_active (visible);
+ }
+ }
+
+ /* add the per-channel menu to the list of controllers, with the name of the controller */
+ ctl_items.push_back (MenuElem (string_compose ("<b>%1</b>: %2", ctl, name),
+ *chn_menu));
+ dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true);
+}
+
+boost::shared_ptr<MIDI::Name::CustomDeviceMode>
+MidiTimeAxisView::get_device_mode()
+{
+ using namespace MIDI::Name;
+
+ boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
+ if (!device_names) {
+ return boost::shared_ptr<MIDI::Name::CustomDeviceMode>();
+ }
+
+ return device_names->custom_device_mode_by_name(
+ gui_property (X_("midnam-custom-device-mode")));
+}
+
+boost::shared_ptr<MIDI::Name::MasterDeviceNames>
+MidiTimeAxisView::get_device_names()
+{
+ using namespace MIDI::Name;
+
+ const std::string model = gui_property (X_("midnam-model-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>();
+ }
+}
+