summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-09-13 16:59:02 +0200
committerRobin Gareus <robin@gareus.org>2014-09-13 16:59:02 +0200
commitd8e64103a6c2f9d357f3b693907962e9daf0f25b (patch)
tree853baf8b5a380287190eaeeb8f8268b23767f19c
parent009ced96409d1aa7e8999f4c13e7cf60fe2040e2 (diff)
fix CPI window handling:
Move control-surface editor-window management to the control surface. The Preferences-Dialog is not aware of session specific or surface specific actions and cannot properly manage the window.
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc12
-rw-r--r--gtk2_ardour/rc_option_editor.cc60
-rw-r--r--libs/surfaces/generic_midi/gmcp_gui.cc9
-rw-r--r--libs/surfaces/mackie/gui.cc10
4 files changed, 57 insertions, 34 deletions
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc
index 0dc7104f8c..8cd65ef378 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -25,8 +25,10 @@
#include "ardour/audioengine.h"
#include "ardour/automation_watch.h"
+#include "ardour/control_protocol_manager.h"
#include "ardour/profile.h"
#include "ardour/session.h"
+#include "control_protocol/control_protocol.h"
#include "actions.h"
#include "add_route_dialog.h"
@@ -262,6 +264,16 @@ ARDOUR_UI::unload_session (bool hide_stuff)
}
}
+ {
+ // tear down session specific CPI (owned by rc_config_editor which can remain)
+ ControlProtocolManager& m = ControlProtocolManager::instance ();
+ for (std::list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
+ if (*i && (*i)->protocol && (*i)->protocol->has_editor ()) {
+ (*i)->protocol->tear_down_gui ();
+ }
+ }
+ }
+
if (hide_stuff) {
editor->hide ();
mixer->hide ();
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index ced64a9d6e..a4d2b5dee2 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -795,17 +795,7 @@ private:
if (!was_enabled) {
ControlProtocolManager::instance().activate (*cpi);
} else {
- Gtk::Window* win = r[_model.editor];
- if (win) {
- win->hide ();
- }
-
ControlProtocolManager::instance().deactivate (*cpi);
-
- if (win) {
- delete win;
- r[_model.editor] = 0;
- }
}
}
@@ -817,8 +807,8 @@ private:
}
}
- void edit_clicked (GdkEventButton* ev)
- {
+ void edit_clicked (GdkEventButton* ev)
+ {
if (ev->type != GDK_2BUTTON_PRESS) {
return;
}
@@ -828,26 +818,32 @@ private:
TreeModel::Row row;
row = *(_view.get_selection()->get_selected());
-
- Window* win = row[_model.editor];
- if (win && !win->is_visible()) {
- win->present ();
- } else {
- cpi = row[_model.protocol_info];
-
- if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
- Box* box = (Box*) cpi->protocol->get_gui ();
- if (box) {
- string title = row[_model.name];
- ArdourWindow* win = new ArdourWindow (_parent, title);
- win->set_title ("Control Protocol Options");
- win->add (*box);
- box->show ();
- win->present ();
- row[_model.editor] = win;
- }
- }
+ if (!row[_model.enabled]) {
+ return;
+ }
+ cpi = row[_model.protocol_info];
+ if (!cpi || !cpi->protocol || !cpi->protocol->has_editor ()) {
+ return;
+ }
+ Box* box = (Box*) cpi->protocol->get_gui ();
+ if (!box) {
+ return;
+ }
+ if (box->get_parent()) {
+ static_cast<ArdourWindow*>(box->get_parent())->present();
+ return;
}
+ string title = row[_model.name];
+ /* once created, the window is managed by the surface itself (as ->get_parent())
+ * Surface's tear_down_gui() is called on session close, when de-activating
+ * or re-initializing a surface.
+ * tear_down_gui() hides an deletes the Window if it exists.
+ */
+ ArdourWindow* win = new ArdourWindow (_parent, title);
+ win->set_title ("Control Protocol Options");
+ win->add (*box);
+ box->show ();
+ win->present ();
}
class ControlSurfacesModelColumns : public TreeModelColumnRecord
@@ -860,14 +856,12 @@ private:
add (enabled);
add (feedback);
add (protocol_info);
- add (editor);
}
TreeModelColumn<string> name;
TreeModelColumn<bool> enabled;
TreeModelColumn<bool> feedback;
TreeModelColumn<ControlProtocolInfo*> protocol_info;
- TreeModelColumn<Gtk::Window*> editor;
};
Glib::RefPtr<ListStore> _store;
diff --git a/libs/surfaces/generic_midi/gmcp_gui.cc b/libs/surfaces/generic_midi/gmcp_gui.cc
index 6c1ee1ba3d..379f7c822c 100644
--- a/libs/surfaces/generic_midi/gmcp_gui.cc
+++ b/libs/surfaces/generic_midi/gmcp_gui.cc
@@ -68,13 +68,22 @@ GenericMidiControlProtocol::get_gui () const
if (!gui) {
const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
}
+ static_cast<Gtk::VBox*>(gui)->show_all();
return gui;
}
void
GenericMidiControlProtocol::tear_down_gui ()
{
+ if (gui) {
+ Gtk::Widget *w = static_cast<Gtk::VBox*>(gui)->get_parent();
+ if (w) {
+ w->hide();
+ delete w;
+ }
+ }
delete (GMCPGUI*) gui;
+ gui = 0;
}
void
diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc
index 7425b38826..6753f0a97c 100644
--- a/libs/surfaces/mackie/gui.cc
+++ b/libs/surfaces/mackie/gui.cc
@@ -51,14 +51,22 @@ MackieControlProtocol::get_gui () const
if (!_gui) {
const_cast<MackieControlProtocol*>(this)->build_gui ();
}
-
+ static_cast<Gtk::Notebook*>(_gui)->show_all();
return _gui;
}
void
MackieControlProtocol::tear_down_gui ()
{
+ if (_gui) {
+ Gtk::Widget *w = static_cast<Gtk::Widget*>(_gui)->get_parent();
+ if (w) {
+ w->hide();
+ delete w;
+ }
+ }
delete (MackieControlProtocolGUI*) _gui;
+ _gui = 0;
}
void