diff options
author | Hans Baier <hansfbaier@googlemail.com> | 2008-12-09 08:35:02 +0000 |
---|---|---|
committer | Hans Baier <hansfbaier@googlemail.com> | 2008-12-09 08:35:02 +0000 |
commit | f8480d6392e6d0e61aa39e564904ba67822f711e (patch) | |
tree | 043e60f68e059097c7b2782e6522f76202e4c08f /gtk2_ardour | |
parent | 457f06855e30ebdfeae0a5dfe39cb8f52422a912 (diff) |
* moved /midi_patch_manager.* to libs/ardour
* GUI improvement: do away with the midi channel expander
git-svn-id: svn://localhost/ardour2/branches/3.0@4305 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/SConscript | 1 | ||||
-rw-r--r-- | gtk2_ardour/midi_patch_manager.cc | 99 | ||||
-rw-r--r-- | gtk2_ardour/midi_patch_manager.h | 81 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 42 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.h | 4 |
5 files changed, 13 insertions, 214 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index 8bfccae2b4..89a5040400 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -201,7 +201,6 @@ midi_region_view.cc midi_scroomer.cc midi_streamview.cc midi_time_axis.cc -midi_patch_manager.cc mixer_strip.cc mixer_ui.cc new_session_dialog.cc diff --git a/gtk2_ardour/midi_patch_manager.cc b/gtk2_ardour/midi_patch_manager.cc deleted file mode 100644 index 18e1d5051e..0000000000 --- a/gtk2_ardour/midi_patch_manager.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2008 Hans Baier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#include <sigc++/sigc++.h> -#include <boost/shared_ptr.hpp> - -#include "midi_patch_manager.h" -#include "pbd/file_utils.h" -#include "ardour/session.h" -#include "ardour/session_directory.h" - -using namespace std; -using namespace sigc; -using namespace ARDOUR; -using namespace MIDI; -using namespace MIDI::Name; -using namespace PBD; -using namespace PBD::sys; - -MidiPatchManager* MidiPatchManager::_manager = 0; - -void -MidiPatchManager::set_session (Session& s) -{ - _session = &s; - _session->GoingAway.connect (mem_fun (*this, &MidiPatchManager::drop_session)); - - refresh(); -} - -void -MidiPatchManager::refresh() -{ - _documents.clear(); - - path path_to_patches = _session->session_directory().midi_patch_path(); - - cerr << "Path to patches: " << path_to_patches.to_string() << endl; - - if(!exists(path_to_patches)) { - return; - } - cerr << "Path to patches: " << path_to_patches.to_string() << " exists" << endl; - - assert(is_directory(path_to_patches)); - - Glib::PatternSpec pattern(Glib::ustring("*.midnam")); - vector<path> result; - - find_matching_files_in_directory(path_to_patches, pattern, result); - - cerr << "patchfiles result contains " << result.size() << " elements" << endl; - - for(vector<path>::iterator i = result.begin(); i != result.end(); ++i) { - cerr << "processing patchfile " << i->to_string() << endl; - - boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string())); - for(MIDINameDocument::MasterDeviceNamesList::const_iterator device = - document->master_device_names_by_model().begin(); - device != document->master_device_names_by_model().end(); - ++device) { - cerr << "got model " << device->first << endl; - // have access to the documents by model name - _documents[device->first] = document; - // build a list of all master devices from all documents - _master_devices_by_model[device->first] = device->second; - _all_models.push_back(device->first); - - // make sure there are no double model names - // TODO: handle this gracefully. - assert(_documents.count(device->first) == 1); - assert(_master_devices_by_model.count(device->first) == 1); - } - } -} - -void -MidiPatchManager::drop_session () -{ - _session = 0; - _documents.clear(); -} diff --git a/gtk2_ardour/midi_patch_manager.h b/gtk2_ardour/midi_patch_manager.h deleted file mode 100644 index f971663d4d..0000000000 --- a/gtk2_ardour/midi_patch_manager.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2008 Hans Baier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#ifndef MIDI_PATCH_MANAGER_H_ -#define MIDI_PATCH_MANAGER_H_ - -#include "midi++/midnam_patch.h" - -namespace ARDOUR { - class Session; -} - -namespace MIDI -{ - -namespace Name -{ - -class MidiPatchManager -{ - /// Singleton -private: - MidiPatchManager() {}; - MidiPatchManager( const MidiPatchManager& ); - MidiPatchManager& operator= (const MidiPatchManager&); - - static MidiPatchManager* _manager; - -public: - typedef std::map<std::string, boost::shared_ptr<MIDINameDocument> > MidiNameDocuments; - - virtual ~MidiPatchManager() { _manager = 0; } - - static MidiPatchManager& instance() { - if (_manager == 0) { - _manager = new MidiPatchManager(); - } - return *_manager; - } - - void set_session (ARDOUR::Session&); - - boost::shared_ptr<MIDINameDocument> document_by_model(std::string model_name) - { return _documents[model_name]; } - - boost::shared_ptr<MasterDeviceNames> master_device_by_model(std::string model_name) - { return _master_devices_by_model[model_name]; } - - const MasterDeviceNames::Models& all_models() const { return _all_models; } - -private: - void drop_session(); - void refresh(); - - ARDOUR::Session* _session; - MidiNameDocuments _documents; - MIDINameDocument::MasterDeviceNamesList _master_devices_by_model; - MasterDeviceNames::Models _all_models; -}; - -} // namespace Name - -} // namespace MIDI -#endif /* MIDI_PATCH_MANAGER_H_ */ diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 1c6ac5b5fe..1052b57912 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -37,6 +37,7 @@ #include <ardour/midi_playlist.h> #include <ardour/midi_diskstream.h> +#include <ardour/midi_patch_manager.h> #include <ardour/processor.h> #include <ardour/ladspa_plugin.h> #include <ardour/location.h> @@ -68,7 +69,6 @@ #include "midi_streamview.h" #include "utils.h" #include "midi_scroomer.h" -#include "midi_patch_manager.h" #include "piano_roll_header.h" #include "ghostregion.h" @@ -83,7 +83,7 @@ using namespace sigc; using namespace Editing; // Minimum height at which a control is displayed -static const uint32_t CHANNEL_MIN_HEIGHT = 80; +static const uint32_t MIDI_CONTROLS_BOX_MIN_HEIGHT = 162; static const uint32_t KEYBOARD_MIN_HEIGHT = 140; MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas) @@ -95,7 +95,6 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar , _note_mode(Sustained) , _note_mode_item(NULL) , _percussion_mode_item(NULL) - , _midi_expander("Channel") { subplugin_menu.set_name ("ArdourContextMenu"); @@ -142,14 +141,12 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar } // add channel selector expander - HBox* midi_expander_hbox = manage(new HBox()); - VBox* midi_expander_vbox = manage(new VBox()); + HBox* midi_controls_hbox = manage(new HBox()); // Instrument patch selector ComboBoxText* model_selector = manage(new ComboBoxText()); MIDI::Name::MidiPatchManager& patch_manager = MIDI::Name::MidiPatchManager::instance(); - patch_manager.set_session(session()); for (MIDI::Name::MasterDeviceNames::Models::const_iterator model = patch_manager.all_models().begin(); model != patch_manager.all_models().end(); @@ -159,13 +156,12 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar model_selector->set_active(0); - midi_expander_hbox->pack_start(_channel_selector, true, false); - midi_expander_vbox->pack_start(*model_selector, true, false); - midi_expander_vbox->pack_start(*midi_expander_hbox, true, true); - _midi_expander.add(*midi_expander_vbox); - _midi_expander.property_expanded().signal_changed().connect( - mem_fun(this, &MidiTimeAxisView::channel_selector_toggled)); - controls_vbox.pack_start(_midi_expander, false, false); + midi_controls_hbox->pack_start(_channel_selector, true, false); + _midi_controls_box.pack_start(*model_selector, true, false); + _midi_controls_box.pack_start(*midi_controls_hbox, true, true); + + controls_vbox.pack_start(_midi_controls_box, false, false); + boost::shared_ptr<MidiDiskstream> diskstream = midi_track()->midi_diskstream(); // restore channel selector settings @@ -214,10 +210,10 @@ MidiTimeAxisView::set_height (uint32_t h) { RouteTimeAxisView::set_height (h); - if (height >= CHANNEL_MIN_HEIGHT) { - _midi_expander.show(); + if (height >= MIDI_CONTROLS_BOX_MIN_HEIGHT) { + _midi_controls_box.show(); } else { - _midi_expander.hide(); + _midi_controls_box.hide(); } if (height >= KEYBOARD_MIN_HEIGHT) { @@ -462,20 +458,6 @@ MidiTimeAxisView::route_active_changed () } } -void -MidiTimeAxisView::channel_selector_toggled() -{ - static uint32_t previous_height; - - if (_midi_expander.property_expanded()) { - previous_height = current_height(); - if (previous_height < TimeAxisView::hLargest) { - set_height (TimeAxisView::hLarge); - } - } else { - set_height (previous_height); - } -} diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index 18dfedcaf0..a09cb5e5f1 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -93,8 +93,6 @@ class MidiTimeAxisView : public RouteTimeAxisView void add_insert_to_subplugin_menu (ARDOUR::Processor *); - void channel_selector_toggled(); - bool _ignore_signals; Gtk::Menu _subplugin_menu; MidiScroomer* _range_scroomer; @@ -102,7 +100,7 @@ class MidiTimeAxisView : public RouteTimeAxisView ARDOUR::NoteMode _note_mode; Gtk::RadioMenuItem* _note_mode_item; Gtk::RadioMenuItem* _percussion_mode_item; - Gtk::Expander _midi_expander; + Gtk::VBox _midi_controls_box; MidiMultipleChannelSelector _channel_selector; }; |