Separate PluginWindowProxy into public class
This commit is contained in:
parent
f858316503
commit
598ff1cb9a
@ -42,6 +42,7 @@
|
||||
#include "mixer_ui.h"
|
||||
#include "plugin_selector.h"
|
||||
#include "plugin_ui.h"
|
||||
#include "plugin_window_proxy.h"
|
||||
#include "ui_config.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
@ -299,7 +300,7 @@ IOPluginWindow::IOPlugUI::IOPlugUI (std::shared_ptr<ARDOUR::IOPlug> iop)
|
||||
_window_proxy = dynamic_cast<PluginWindowProxy*> (iop->window_proxy ());
|
||||
assert (_window_proxy);
|
||||
} else {
|
||||
_window_proxy = new PluginWindowProxy (string_compose ("IOP-%1", _iop->id ()), _iop);
|
||||
_window_proxy = new PluginWindowProxy (string_compose ("IOP-%1", _iop->id ()), "I/O", _iop);
|
||||
|
||||
const XMLNode* ui_xml = _iop->session ().extra_xml (X_("UI"));
|
||||
if (ui_xml) {
|
||||
@ -373,113 +374,6 @@ IOPluginWindow::IOPlugUI::button_resized (Gtk::Allocation& alloc)
|
||||
_btn_ioplug.set_layout_ellipsize_width (alloc.get_width () * PANGO_SCALE);
|
||||
}
|
||||
|
||||
/* ****************************************************************************/
|
||||
|
||||
IOPluginWindow::PluginWindowProxy::PluginWindowProxy (std::string const& name, std::weak_ptr<PlugInsertBase> plugin)
|
||||
: WM::ProxyBase (name, std::string ())
|
||||
, _pib (plugin)
|
||||
, _is_custom (true)
|
||||
, _want_custom (true)
|
||||
{
|
||||
std::shared_ptr<PlugInsertBase> p = _pib.lock ();
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
p->DropReferences.connect (_going_away_connection, MISSING_INVALIDATOR, boost::bind (&IOPluginWindow::PluginWindowProxy::plugin_going_away, this), gui_context ());
|
||||
}
|
||||
|
||||
IOPluginWindow::PluginWindowProxy::~PluginWindowProxy ()
|
||||
{
|
||||
_window = 0;
|
||||
}
|
||||
|
||||
Gtk::Window*
|
||||
IOPluginWindow::PluginWindowProxy::get (bool create)
|
||||
{
|
||||
std::shared_ptr<PlugInsertBase> p = _pib.lock ();
|
||||
if (!p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_window && (_is_custom != _want_custom)) {
|
||||
set_state_mask (WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
|
||||
drop_window ();
|
||||
}
|
||||
|
||||
if (!_window) {
|
||||
if (!create) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_is_custom = _want_custom;
|
||||
_window = new PluginUIWindow (p, false, _is_custom);
|
||||
|
||||
if (_window) {
|
||||
std::shared_ptr<ARDOUR::IOPlug> iop = std::dynamic_pointer_cast<ARDOUR::IOPlug> (p);
|
||||
assert (iop);
|
||||
_window->set_title (iop->name ());
|
||||
setup ();
|
||||
_window->show_all ();
|
||||
}
|
||||
}
|
||||
return _window;
|
||||
}
|
||||
|
||||
void
|
||||
IOPluginWindow::PluginWindowProxy::show_the_right_window ()
|
||||
{
|
||||
if (_window && (_is_custom != _want_custom)) {
|
||||
set_state_mask (WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
|
||||
drop_window ();
|
||||
}
|
||||
|
||||
if (_window) {
|
||||
_window->unset_transient_for ();
|
||||
}
|
||||
toggle ();
|
||||
}
|
||||
|
||||
int
|
||||
IOPluginWindow::PluginWindowProxy::set_state (const XMLNode& node, int)
|
||||
{
|
||||
XMLNodeList children = node.children ();
|
||||
XMLNodeList::const_iterator i = children.begin ();
|
||||
while (i != children.end ()) {
|
||||
std::string name;
|
||||
if ((*i)->name () == X_("Window") && (*i)->get_property (X_("name"), name) && name == _name) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i != children.end ()) {
|
||||
(*i)->get_property (X_("custom-ui"), _want_custom);
|
||||
}
|
||||
|
||||
return ProxyBase::set_state (node, 0);
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
IOPluginWindow::PluginWindowProxy::get_state () const
|
||||
{
|
||||
XMLNode* node;
|
||||
node = &ProxyBase::get_state ();
|
||||
node->set_property (X_("custom-ui"), _is_custom);
|
||||
return *node;
|
||||
}
|
||||
|
||||
void
|
||||
IOPluginWindow::PluginWindowProxy::plugin_going_away ()
|
||||
{
|
||||
delete _window;
|
||||
_window = 0;
|
||||
WM::Manager::instance ().remove (this);
|
||||
_going_away_connection.disconnect ();
|
||||
delete this;
|
||||
}
|
||||
|
||||
/* ****************************************************************************/
|
||||
|
||||
IOPluginWindow::IOButton::IOButton (std::shared_ptr<ARDOUR::IO> io, bool pre)
|
||||
: _io (io)
|
||||
, _pre (pre)
|
||||
|
@ -35,11 +35,11 @@ namespace ARDOUR
|
||||
{
|
||||
class IO;
|
||||
class IOPlug;
|
||||
class PlugInsertBase;
|
||||
class Port;
|
||||
}
|
||||
|
||||
class IOSelectorWindow;
|
||||
class PluginWindowProxy;
|
||||
|
||||
class IOPluginWindow : public ArdourWindow
|
||||
{
|
||||
@ -48,39 +48,6 @@ public:
|
||||
|
||||
void set_session (ARDOUR::Session*);
|
||||
|
||||
class PluginWindowProxy : public WM::ProxyBase
|
||||
{
|
||||
public:
|
||||
PluginWindowProxy (std::string const&, std::weak_ptr<ARDOUR::PlugInsertBase>);
|
||||
~PluginWindowProxy ();
|
||||
Gtk::Window* get (bool create = false);
|
||||
|
||||
void show_the_right_window ();
|
||||
|
||||
ARDOUR::SessionHandlePtr* session_handle ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_custom_ui_mode (bool use_custom)
|
||||
{
|
||||
_want_custom = use_custom;
|
||||
}
|
||||
|
||||
int set_state (const XMLNode&, int);
|
||||
XMLNode& get_state () const;
|
||||
|
||||
private:
|
||||
void plugin_going_away ();
|
||||
|
||||
std::weak_ptr<ARDOUR::PlugInsertBase> _pib;
|
||||
|
||||
bool _is_custom;
|
||||
bool _want_custom;
|
||||
|
||||
PBD::ScopedConnection _going_away_connection;
|
||||
};
|
||||
|
||||
protected:
|
||||
void on_show ();
|
||||
void on_hide ();
|
||||
@ -147,7 +114,7 @@ private:
|
||||
IOButton _btn_output;
|
||||
ArdourWidgets::ArdourButton _btn_ioplug;
|
||||
PluginWindowProxy* _window_proxy;
|
||||
std::shared_ptr<ARDOUR::IOPlug> _iop;
|
||||
std::shared_ptr<ARDOUR::IOPlug> _iop;
|
||||
PBD::ScopedConnection _going_away_connection;
|
||||
};
|
||||
|
||||
|
154
gtk2_ardour/plugin_window_proxy.cc
Normal file
154
gtk2_ardour/plugin_window_proxy.cc
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "ardour/plug_insert_base.h"
|
||||
#include "ardour/plugin_manager.h"
|
||||
|
||||
#include "gui_thread.h"
|
||||
#include "plugin_ui.h"
|
||||
#include "plugin_window_proxy.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
using namespace Gtk;
|
||||
using namespace Gtkmm2ext;
|
||||
|
||||
PluginWindowProxy::PluginWindowProxy (std::string const& name, std::string const& title, std::weak_ptr<PlugInsertBase> plugin)
|
||||
: WM::ProxyBase (name, std::string ())
|
||||
, _pib (plugin)
|
||||
, _title (title)
|
||||
, _is_custom (true)
|
||||
, _want_custom (true)
|
||||
{
|
||||
std::shared_ptr<PlugInsertBase> p = _pib.lock ();
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
p->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&PluginWindowProxy::plugin_going_away, this), gui_context ());
|
||||
}
|
||||
|
||||
PluginWindowProxy::~PluginWindowProxy ()
|
||||
{
|
||||
_window = 0;
|
||||
}
|
||||
|
||||
Gtk::Window*
|
||||
PluginWindowProxy::get (bool create)
|
||||
{
|
||||
std::shared_ptr<PlugInsertBase> p = _pib.lock ();
|
||||
if (!p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_window && (_is_custom != _want_custom)) {
|
||||
set_state_mask (WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
|
||||
drop_window ();
|
||||
}
|
||||
|
||||
if (!_window) {
|
||||
if (!create) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_is_custom = _want_custom;
|
||||
_window = new PluginUIWindow (p, false, _is_custom);
|
||||
|
||||
if (_window) {
|
||||
_window->set_title (generate_processor_title (p));
|
||||
setup ();
|
||||
_window->show_all ();
|
||||
}
|
||||
}
|
||||
return _window;
|
||||
}
|
||||
|
||||
void
|
||||
PluginWindowProxy::show_the_right_window ()
|
||||
{
|
||||
if (_window && (_is_custom != _want_custom)) {
|
||||
set_state_mask (WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
|
||||
drop_window ();
|
||||
}
|
||||
|
||||
if (_window) {
|
||||
_window->unset_transient_for ();
|
||||
}
|
||||
toggle ();
|
||||
}
|
||||
|
||||
int
|
||||
PluginWindowProxy::set_state (const XMLNode& node, int)
|
||||
{
|
||||
XMLNodeList children = node.children ();
|
||||
XMLNodeList::const_iterator i = children.begin ();
|
||||
while (i != children.end ()) {
|
||||
std::string name;
|
||||
if ((*i)->name () == X_("Window") && (*i)->get_property (X_("name"), name) && name == _name) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i != children.end ()) {
|
||||
(*i)->get_property (X_("custom-ui"), _want_custom);
|
||||
}
|
||||
|
||||
return ProxyBase::set_state (node, 0);
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
PluginWindowProxy::get_state () const
|
||||
{
|
||||
XMLNode* node;
|
||||
node = &ProxyBase::get_state ();
|
||||
node->set_property (X_("custom-ui"), _is_custom);
|
||||
return *node;
|
||||
}
|
||||
|
||||
void
|
||||
PluginWindowProxy::plugin_going_away ()
|
||||
{
|
||||
delete _window;
|
||||
_window = 0;
|
||||
WM::Manager::instance ().remove (this);
|
||||
drop_connections ();
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::string
|
||||
PluginWindowProxy::generate_processor_title (std::shared_ptr<PlugInsertBase> p)
|
||||
{
|
||||
std::string maker = p->plugin()->maker() ? p->plugin()->maker() : "";
|
||||
std::string::size_type email_pos;
|
||||
|
||||
if ((email_pos = maker.find_first_of ('<')) != std::string::npos) {
|
||||
maker = maker.substr (0, email_pos - 1);
|
||||
}
|
||||
|
||||
if (maker.length() > 32) {
|
||||
maker = maker.substr (0, 32);
|
||||
maker += " ...";
|
||||
}
|
||||
|
||||
std::string type = PluginManager::plugin_type_name (p->type ());
|
||||
auto so = std::dynamic_pointer_cast<SessionObject> (p);
|
||||
assert (so);
|
||||
|
||||
return string_compose(_("%1: %2 (by %3) [%4]"), _title, so->name(), maker, type);
|
||||
}
|
72
gtk2_ardour/plugin_window_proxy.h
Normal file
72
gtk2_ardour/plugin_window_proxy.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2022,2024 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _gtkardour_plugin_window_proxy_h_
|
||||
#define _gtkardour_plugin_window_proxy_h_
|
||||
|
||||
#include "ardour_window.h"
|
||||
#include "window_manager.h"
|
||||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
namespace Gtk
|
||||
{
|
||||
class Window;
|
||||
}
|
||||
|
||||
namespace ARDOUR
|
||||
{
|
||||
class PlugInsertBase;
|
||||
}
|
||||
|
||||
class PluginWindowProxy : public WM::ProxyBase, public PBD::ScopedConnectionList
|
||||
{
|
||||
public:
|
||||
PluginWindowProxy (std::string const&, std::string const&, std::weak_ptr<ARDOUR::PlugInsertBase>);
|
||||
~PluginWindowProxy ();
|
||||
|
||||
Gtk::Window* get (bool create = false);
|
||||
|
||||
void show_the_right_window ();
|
||||
|
||||
ARDOUR::SessionHandlePtr* session_handle ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_custom_ui_mode (bool use_custom)
|
||||
{
|
||||
_want_custom = use_custom;
|
||||
}
|
||||
|
||||
int set_state (const XMLNode&, int);
|
||||
XMLNode& get_state () const;
|
||||
|
||||
std::string generate_processor_title (std::shared_ptr<ARDOUR::PlugInsertBase>);
|
||||
|
||||
private:
|
||||
void plugin_going_away ();
|
||||
|
||||
std::weak_ptr<ARDOUR::PlugInsertBase> _pib;
|
||||
|
||||
std::string _title;
|
||||
bool _is_custom;
|
||||
bool _want_custom;
|
||||
};
|
||||
|
||||
#endif
|
@ -219,6 +219,7 @@ gtk2_ardour_sources = [
|
||||
'plugin_ui.cc',
|
||||
'plugin_dspload_ui.cc',
|
||||
'plugin_dspload_window.cc',
|
||||
'plugin_window_proxy.cc',
|
||||
'port_group.cc',
|
||||
'port_insert_ui.cc',
|
||||
'port_matrix.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user