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.
This commit is contained in:
parent
009ced9640
commit
d8e64103a6
@ -25,8 +25,10 @@
|
|||||||
|
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
#include "ardour/automation_watch.h"
|
#include "ardour/automation_watch.h"
|
||||||
|
#include "ardour/control_protocol_manager.h"
|
||||||
#include "ardour/profile.h"
|
#include "ardour/profile.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
|
#include "control_protocol/control_protocol.h"
|
||||||
|
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "add_route_dialog.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) {
|
if (hide_stuff) {
|
||||||
editor->hide ();
|
editor->hide ();
|
||||||
mixer->hide ();
|
mixer->hide ();
|
||||||
|
@ -795,17 +795,7 @@ private:
|
|||||||
if (!was_enabled) {
|
if (!was_enabled) {
|
||||||
ControlProtocolManager::instance().activate (*cpi);
|
ControlProtocolManager::instance().activate (*cpi);
|
||||||
} else {
|
} else {
|
||||||
Gtk::Window* win = r[_model.editor];
|
|
||||||
if (win) {
|
|
||||||
win->hide ();
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlProtocolManager::instance().deactivate (*cpi);
|
ControlProtocolManager::instance().deactivate (*cpi);
|
||||||
|
|
||||||
if (win) {
|
|
||||||
delete win;
|
|
||||||
r[_model.editor] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,26 +818,32 @@ private:
|
|||||||
TreeModel::Row row;
|
TreeModel::Row row;
|
||||||
|
|
||||||
row = *(_view.get_selection()->get_selected());
|
row = *(_view.get_selection()->get_selected());
|
||||||
|
if (!row[_model.enabled]) {
|
||||||
Window* win = row[_model.editor];
|
return;
|
||||||
if (win && !win->is_visible()) {
|
}
|
||||||
win->present ();
|
|
||||||
} else {
|
|
||||||
cpi = row[_model.protocol_info];
|
cpi = row[_model.protocol_info];
|
||||||
|
if (!cpi || !cpi->protocol || !cpi->protocol->has_editor ()) {
|
||||||
if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
|
return;
|
||||||
|
}
|
||||||
Box* box = (Box*) cpi->protocol->get_gui ();
|
Box* box = (Box*) cpi->protocol->get_gui ();
|
||||||
if (box) {
|
if (!box) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (box->get_parent()) {
|
||||||
|
static_cast<ArdourWindow*>(box->get_parent())->present();
|
||||||
|
return;
|
||||||
|
}
|
||||||
string title = row[_model.name];
|
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);
|
ArdourWindow* win = new ArdourWindow (_parent, title);
|
||||||
win->set_title ("Control Protocol Options");
|
win->set_title ("Control Protocol Options");
|
||||||
win->add (*box);
|
win->add (*box);
|
||||||
box->show ();
|
box->show ();
|
||||||
win->present ();
|
win->present ();
|
||||||
row[_model.editor] = win;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ControlSurfacesModelColumns : public TreeModelColumnRecord
|
class ControlSurfacesModelColumns : public TreeModelColumnRecord
|
||||||
@ -860,14 +856,12 @@ private:
|
|||||||
add (enabled);
|
add (enabled);
|
||||||
add (feedback);
|
add (feedback);
|
||||||
add (protocol_info);
|
add (protocol_info);
|
||||||
add (editor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeModelColumn<string> name;
|
TreeModelColumn<string> name;
|
||||||
TreeModelColumn<bool> enabled;
|
TreeModelColumn<bool> enabled;
|
||||||
TreeModelColumn<bool> feedback;
|
TreeModelColumn<bool> feedback;
|
||||||
TreeModelColumn<ControlProtocolInfo*> protocol_info;
|
TreeModelColumn<ControlProtocolInfo*> protocol_info;
|
||||||
TreeModelColumn<Gtk::Window*> editor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Glib::RefPtr<ListStore> _store;
|
Glib::RefPtr<ListStore> _store;
|
||||||
|
@ -68,13 +68,22 @@ GenericMidiControlProtocol::get_gui () const
|
|||||||
if (!gui) {
|
if (!gui) {
|
||||||
const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
|
const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
|
||||||
}
|
}
|
||||||
|
static_cast<Gtk::VBox*>(gui)->show_all();
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GenericMidiControlProtocol::tear_down_gui ()
|
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;
|
delete (GMCPGUI*) gui;
|
||||||
|
gui = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -51,14 +51,22 @@ MackieControlProtocol::get_gui () const
|
|||||||
if (!_gui) {
|
if (!_gui) {
|
||||||
const_cast<MackieControlProtocol*>(this)->build_gui ();
|
const_cast<MackieControlProtocol*>(this)->build_gui ();
|
||||||
}
|
}
|
||||||
|
static_cast<Gtk::Notebook*>(_gui)->show_all();
|
||||||
return _gui;
|
return _gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MackieControlProtocol::tear_down_gui ()
|
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;
|
delete (MackieControlProtocolGUI*) _gui;
|
||||||
|
_gui = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user