summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-05-16 14:50:10 +0000
committerCarl Hetherington <carl@carlh.net>2009-05-16 14:50:10 +0000
commit73a6b8ef25bb90ad6c66b25b17da5962a38291d2 (patch)
tree1ab7718cd8eaaf5cdcab8e7ecd8d0cb0f83628d6
parentdab9b3aa8cae8c82c9c81f1bd0628c5bb179b4c5 (diff)
Move control surface options into RC prefs editor. Remove Options menu.
git-svn-id: svn://localhost/ardour2/branches/3.0@5088 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/ardour.menus.in2
-rw-r--r--gtk2_ardour/ardour_ui.h4
-rw-r--r--gtk2_ardour/ardour_ui_ed.cc122
-rw-r--r--gtk2_ardour/rc_option_editor.cc129
4 files changed, 116 insertions, 141 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 72dff39e3e..117cb8004b 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -432,8 +432,6 @@
<menuitem action='toggle-midi-connection-manager'/>
<separator/>
</menu>
- <menu name='Options' action='Options'>
- </menu>
<menu name='Help' action='Help'>
<menuitem action='About'/>
</menu>
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 64d7ce04a1..89646dc3d3 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -494,7 +494,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void use_menubar_as_top_menubar ();
void build_menu_bar ();
- void build_control_surface_menu ();
Gtk::Label wall_clock_label;
Gtk::EventBox wall_clock_box;
@@ -685,9 +684,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void mtc_port_changed ();
void parameter_changed (std::string);
- void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
- void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
-
bool first_idle ();
void no_memory_warning ();
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc
index 61bb5d6ef7..8d70f725f2 100644
--- a/gtk2_ardour/ardour_ui_ed.cc
+++ b/gtk2_ardour/ardour_ui_ed.cc
@@ -91,7 +91,6 @@ ARDOUR_UI::install_actions ()
ActionManager::register_action (main_actions, X_("Files"), _("Import/Export"));
ActionManager::register_action (main_actions, X_("Cleanup"), _("Cleanup"));
ActionManager::register_action (main_actions, X_("Sync"), _("Sync"));
- ActionManager::register_action (main_actions, X_("Options"), _("Options"));
ActionManager::register_action (main_actions, X_("TransportOptions"), _("Options"));
ActionManager::register_action (main_actions, X_("Help"), _("Help"));
ActionManager::register_action (main_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
@@ -451,52 +450,6 @@ ARDOUR_UI::install_actions ()
}
void
-ARDOUR_UI::toggle_control_protocol (ControlProtocolInfo* cpi)
-{
- if (!session) {
- /* this happens when we build the menu bar when control protocol support
- has been used in the past for some given protocol - the item needs
- to be made active, but there is no session yet.
- */
- return;
- }
-
- if (cpi->protocol == 0) {
- ControlProtocolManager::instance().instantiate (*cpi);
- } else {
- ControlProtocolManager::instance().teardown (*cpi);
- }
-}
-
-void
-ARDOUR_UI::toggle_control_protocol_feedback (ControlProtocolInfo* cpi, const char* group, string action)
-{
- if (!session) {
- /* this happens when we build the menu bar when control protocol support
- has been used in the past for some given protocol - the item needs
- to be made active, but there is no session yet.
- */
- return;
- }
-
- if (cpi->protocol) {
- Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (group, action.c_str());
-
- if (act) {
- Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-
- if (tact) {
- bool x = tact->get_active();
-
- if (x != cpi->protocol->get_feedback()) {
- cpi->protocol->set_feedback (x);
- }
- }
- }
- }
-}
-
-void
ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
{
Glib::RefPtr<Action> action;
@@ -548,83 +501,8 @@ ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
}
void
-ARDOUR_UI::build_control_surface_menu ()
-{
- list<ControlProtocolInfo*>::iterator i;
- bool with_feedback;
-
- /* !!! this has to match the top level entry from ardour.menus */
-
- string ui = "<menubar name='Main' action='MainMenu'>\n"
- "<menu name='Options' action='Options'>\n"
- "<menu action='ControlSurfaces'><separator/>\n";
-
- for (i = ControlProtocolManager::instance().control_protocol_info.begin();
- i != ControlProtocolManager::instance().control_protocol_info.end(); ++i) {
-
- if (!(*i)->mandatory) {
-
- // Enable surface
-
- string action_name = "Toggle";
- action_name += legalize_for_path ((*i)->name);
- action_name += "Surface";
-
- string action_label = (*i)->name;
-
- Glib::RefPtr<Action> act = ActionManager::register_toggle_action (
- editor->editor_actions, action_name.c_str(), action_label.c_str(), (bind (
- mem_fun (*this, &ARDOUR_UI::toggle_control_protocol),
- *i)));
-
- Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-
- with_feedback = false;
-
- if ((*i)->protocol || (*i)->requested) {
- tact->set_active ();
- }
-
- ui += "<menuitem action='";
- ui += action_name;
- ui += "'/>\n";
-
- // Enable feedback
-
- if ((*i)->supports_feedback) {
-
- action_name += "Feedback";
- string feedback_label = action_label + " " + _("Feedback");
-
- Glib::RefPtr<Action> act = ActionManager::register_toggle_action (
- editor->editor_actions, action_name.c_str(), feedback_label.c_str(), (bind (
- mem_fun (*this, &ARDOUR_UI::toggle_control_protocol_feedback),
- *i, "Editor", action_name)));
-
- ui += "<menuitem action='";
- ui += action_name;
- ui += "'/>\n";
-
- if ((*i)->protocol) {
- Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
- tact->set_active ((*i)->protocol->get_feedback ());
- }
- }
- }
- }
-
- ui += "</menu>\n</menu>\n</menubar>\n";
-
- ActionManager::ui_manager->add_ui_from_string (ui);
-}
-
-void
ARDOUR_UI::build_menu_bar ()
{
- if (!Profile->get_sae()) {
- build_control_surface_menu ();
- }
-
menu_bar = dynamic_cast<MenuBar*> (ActionManager::get_widget (X_("/Main")));
menu_bar->set_name ("MainMenuBar");
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index 1bd437ab8a..c1a5897265 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -6,6 +6,8 @@
#include "midi++/manager.h"
#include "midi++/factory.h"
#include "ardour/rc_configuration.h"
+#include "ardour/control_protocol_manager.h"
+#include "control_protocol/control_protocol.h"
#include "rc_option_editor.h"
#include "utils.h"
#include "midi_port_dialog.h"
@@ -30,6 +32,8 @@ public:
_store = ListStore::create (_model);
_view.set_model (_store);
_view.append_column (_("Name"), _model.name);
+ _view.get_column(0)->set_resizable (true);
+ _view.get_column(0)->set_expand (true);
_view.append_column_editable (_("Online"), _model.online);
_view.append_column_editable (_("Trace input"), _model.trace_input);
_view.append_column_editable (_("Trace output"), _model.trace_output);
@@ -689,6 +693,101 @@ private:
HScale _dpi_slider;
};
+
+class ControlSurfacesOptions : public OptionEditorBox
+{
+public:
+ ControlSurfacesOptions ()
+ {
+ _store = ListStore::create (_model);
+ _view.set_model (_store);
+ _view.append_column (_("Name"), _model.name);
+ _view.get_column(0)->set_resizable (true);
+ _view.get_column(0)->set_expand (true);
+ _view.append_column_editable (_("Enabled"), _model.enabled);
+ _view.append_column_editable (_("Feedback"), _model.feedback);
+
+ _box->pack_start (_view, false, false);
+
+ _store->signal_row_changed().connect (mem_fun (*this, &ControlSurfacesOptions::model_changed));
+ }
+
+ void parameter_changed (std::string const &)
+ {
+
+ }
+
+ void set_state_from_config ()
+ {
+ _store->clear ();
+
+ ControlProtocolManager& m = ControlProtocolManager::instance ();
+ for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
+
+ if (!(*i)->mandatory) {
+ TreeModel::Row r = *_store->append ();
+ r[_model.name] = (*i)->name;
+ r[_model.enabled] = ((*i)->protocol || (*i)->requested);
+ r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
+ r[_model.protocol_info] = *i;
+ }
+ }
+ }
+
+private:
+
+ void model_changed (TreeModel::Path const & p, TreeModel::iterator const & i)
+ {
+ TreeModel::Row r = *i;
+
+ ControlProtocolInfo* cpi = r[_model.protocol_info];
+ if (!cpi) {
+ return;
+ }
+
+ bool const was_enabled = (cpi->protocol != 0);
+ bool const is_enabled = r[_model.enabled];
+
+ if (was_enabled != is_enabled) {
+ if (!was_enabled) {
+ ControlProtocolManager::instance().instantiate (*cpi);
+ } else {
+ ControlProtocolManager::instance().teardown (*cpi);
+ }
+ }
+
+ bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
+ bool const is_feedback = r[_model.feedback];
+
+ if (was_feedback != is_feedback && cpi->protocol) {
+ cpi->protocol->set_feedback (is_feedback);
+ }
+ }
+
+ class ControlSurfacesModelColumns : public TreeModelColumnRecord
+ {
+ public:
+
+ ControlSurfacesModelColumns ()
+ {
+ add (name);
+ add (enabled);
+ add (feedback);
+ add (protocol_info);
+ }
+
+ TreeModelColumn<string> name;
+ TreeModelColumn<bool> enabled;
+ TreeModelColumn<bool> feedback;
+ TreeModelColumn<ControlProtocolInfo*> protocol_info;
+ };
+
+ Glib::RefPtr<ListStore> _store;
+ ControlSurfacesModelColumns _model;
+ TreeView _view;
+};
+
+
RCOptionEditor::RCOptionEditor ()
: OptionEditor (Config, _("Ardour Preferences")),
_rc_config (Config)
@@ -734,19 +833,6 @@ RCOptionEditor::RCOptionEditor ()
add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
- ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
- "remote-model",
- _("Control surface remote ID"),
- mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
- mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
- );
-
- rm->add (UserOrdered, _("assigned by user"));
- rm->add (MixerOrdered, _("follows order of mixer"));
- rm->add (EditorOrdered, _("follows order of editor"));
-
- add_option (_("Misc"), rm);
-
#ifndef GTKOSX
/* font scaling does nothing with GDK/Quartz */
add_option (_("Misc"), new FontScalingOptions (_rc_config));
@@ -1082,6 +1168,23 @@ RCOptionEditor::RCOptionEditor ()
-1, 65536, 1, 10
));
+ /* CONTROL SURFACES */
+
+ add_option (_("Control surfaces"), new ControlSurfacesOptions);
+
+ ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
+ "remote-model",
+ _("Control surface remote ID"),
+ mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
+ mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
+ );
+
+ rm->add (UserOrdered, _("assigned by user"));
+ rm->add (MixerOrdered, _("follows order of mixer"));
+ rm->add (EditorOrdered, _("follows order of editor"));
+
+ add_option (_("Control surfaces"), rm);
+
/* CLICK */
add_option (_("Click"), new ClickOptions (_rc_config, this));