mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Structure MIDI device selector by manufacturer.
Unfortunately we store the state of models as simply model, so if there's ever duplicate model names, we're somewhat screwed, but this makes the (previously unmanageably huge) menu usable, while retaining the "model name as global identifier" state unmodified.
This commit is contained in:
parent
17a58ecd4b
commit
ee38c44109
7 changed files with 44 additions and 12 deletions
|
|
@ -27,11 +27,12 @@
|
|||
|
||||
#include <sigc++/signal.h>
|
||||
|
||||
#include "midi++/midnam_patch.h"
|
||||
|
||||
#include "pbd/memento_command.h"
|
||||
#include "pbd/stateful_diff_command.h"
|
||||
|
||||
#include "ardour/midi_model.h"
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
#include "ardour/midi_region.h"
|
||||
#include "ardour/midi_source.h"
|
||||
#include "ardour/midi_track.h"
|
||||
|
|
|
|||
|
|
@ -266,14 +266,28 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
|||
}
|
||||
}
|
||||
|
||||
MIDI::Name::MidiPatchManager& patch_manager = MIDI::Name::MidiPatchManager::instance();
|
||||
typedef MIDI::Name::MidiPatchManager PatchManager;
|
||||
|
||||
MIDI::Name::MasterDeviceNames::Models::const_iterator m = patch_manager.all_models().begin();
|
||||
for (; m != patch_manager.all_models().end(); ++m) {
|
||||
_midnam_model_selector.AddMenuElem(
|
||||
Gtk::Menu_Helpers::MenuElem(m->c_str(),
|
||||
sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::model_changed),
|
||||
m->c_str())));
|
||||
PatchManager& patch_manager = PatchManager::instance();
|
||||
|
||||
for (PatchManager::DeviceNamesByMaker::const_iterator m = patch_manager.devices_by_manufacturer().begin();
|
||||
m != patch_manager.devices_by_manufacturer().end(); ++m) {
|
||||
Menu* menu = Gtk::manage(new Menu);
|
||||
Menu_Helpers::MenuList& items = menu->items();
|
||||
|
||||
// Build manufacturer submenu
|
||||
for (MIDI::Name::MIDINameDocument::MasterDeviceNamesList::const_iterator n = m->second.begin();
|
||||
n != m->second.end(); ++n) {
|
||||
Menu_Helpers::MenuElem elem = Gtk::Menu_Helpers::MenuElem(
|
||||
n->first.c_str(),
|
||||
sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::model_changed),
|
||||
n->first.c_str()));
|
||||
|
||||
items.push_back(elem);
|
||||
}
|
||||
|
||||
// Add manufacturer submenu to selector
|
||||
_midnam_model_selector.AddMenuElem(Menu_Helpers::MenuElem(m->first, *menu));
|
||||
}
|
||||
|
||||
if (gui_property (X_("midnam-model-name")).empty()) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "gtkmm2ext/keyboard.h"
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
#include "midi++/midnam_patch.h"
|
||||
|
||||
#include "canvas/debug.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "midi++/midnam_patch.h"
|
||||
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
#include "ardour/beats_frames_converter.h"
|
||||
#include "ardour/instrument_info.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ private:
|
|||
static MidiPatchManager* _manager;
|
||||
|
||||
public:
|
||||
typedef std::map<std::string, boost::shared_ptr<MIDINameDocument> > MidiNameDocuments;
|
||||
typedef std::map<std::string, boost::shared_ptr<MIDINameDocument> > MidiNameDocuments;
|
||||
typedef std::map<std::string, MIDINameDocument::MasterDeviceNamesList> DeviceNamesByMaker;
|
||||
|
||||
virtual ~MidiPatchManager() { _manager = 0; }
|
||||
|
||||
|
|
@ -133,6 +134,8 @@ public:
|
|||
|
||||
const MasterDeviceNames::Models& all_models() const { return _all_models; }
|
||||
|
||||
const DeviceNamesByMaker& devices_by_manufacturer() const { return _devices_by_manufacturer; }
|
||||
|
||||
private:
|
||||
void session_going_away();
|
||||
void refresh();
|
||||
|
|
@ -140,6 +143,7 @@ private:
|
|||
|
||||
MidiNameDocuments _documents;
|
||||
MIDINameDocument::MasterDeviceNamesList _master_devices_by_model;
|
||||
DeviceNamesByMaker _devices_by_manufacturer;
|
||||
MasterDeviceNames::Models _all_models;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ MidiPatchManager::add_session_patches ()
|
|||
// build a list of all master devices from all documents
|
||||
_master_devices_by_model[device->first] = device->second;
|
||||
_all_models.insert(device->first);
|
||||
const std::string& manufacturer = device->second->manufacturer();
|
||||
if (_devices_by_manufacturer.find(manufacturer) == _devices_by_manufacturer.end()) {
|
||||
MIDINameDocument::MasterDeviceNamesList empty;
|
||||
_devices_by_manufacturer.insert(std::make_pair(manufacturer, empty));
|
||||
}
|
||||
_devices_by_manufacturer[manufacturer].insert(std::make_pair(device->first, device->second));
|
||||
|
||||
// make sure there are no double model names
|
||||
// TODO: handle this gracefully.
|
||||
|
|
@ -102,6 +108,7 @@ MidiPatchManager::refresh()
|
|||
_documents.clear();
|
||||
_master_devices_by_model.clear();
|
||||
_all_models.clear();
|
||||
_devices_by_manufacturer.clear();
|
||||
|
||||
Searchpath search_path = midi_patch_search_path ();
|
||||
vector<std::string> result;
|
||||
|
|
@ -133,6 +140,12 @@ MidiPatchManager::refresh()
|
|||
_master_devices_by_model[device->first] = device->second;
|
||||
|
||||
_all_models.insert(device->first);
|
||||
const std::string& manufacturer = device->second->manufacturer();
|
||||
if (_devices_by_manufacturer.find(manufacturer) == _devices_by_manufacturer.end()) {
|
||||
MIDINameDocument::MasterDeviceNamesList empty;
|
||||
_devices_by_manufacturer.insert(std::make_pair(manufacturer, empty));
|
||||
}
|
||||
_devices_by_manufacturer[manufacturer].insert(std::make_pair(device->first, device->second));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,4 +161,5 @@ MidiPatchManager::session_going_away ()
|
|||
_documents.clear();
|
||||
_master_devices_by_model.clear();
|
||||
_all_models.clear();
|
||||
_devices_by_manufacturer.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<MIDINameDocument>
|
||||
<Author>CherryPicker</Author>
|
||||
<MasterDeviceNames>
|
||||
<Manufacturer>Korg inc.</Manufacturer>
|
||||
<Manufacturer>Korg</Manufacturer>
|
||||
<Model>RADIAS</Model>
|
||||
<CustomDeviceMode Name="CPMode 1">
|
||||
<ChannelNameSetAssignments>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue