2020-08-09 19:25:10 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 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 <glibmm/main.h>
|
|
|
|
|
2022-04-04 14:48:56 -04:00
|
|
|
#include "ardour/plug_insert_base.h"
|
2022-02-04 17:05:58 -05:00
|
|
|
#include "ardour/session.h"
|
2020-08-09 19:25:10 -04:00
|
|
|
#include "ardour/vst3_plugin.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
|
|
|
|
|
|
|
#include "timers.h"
|
2020-10-05 21:12:17 -04:00
|
|
|
#include "ui_config.h"
|
2020-08-09 19:25:10 -04:00
|
|
|
#include "vst3_plugin_ui.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Steinberg;
|
|
|
|
|
2020-10-09 12:28:53 -04:00
|
|
|
#ifdef PLATFORM_WINDOWS
|
|
|
|
DEF_CLASS_IID (Presonus::IPlugInViewScaling)
|
|
|
|
#endif
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
VST3PluginUI::VST3PluginUI (std::shared_ptr<PlugInsertBase> pib, std::shared_ptr<VST3Plugin> vst3)
|
2022-04-04 14:48:56 -04:00
|
|
|
: PlugUIBase (pib)
|
2020-08-09 19:25:10 -04:00
|
|
|
, _vst3 (vst3)
|
|
|
|
, _req_width (0)
|
|
|
|
, _req_height (0)
|
2020-09-17 20:11:25 -04:00
|
|
|
, _resize_in_progress (false)
|
2020-11-19 17:11:01 -05:00
|
|
|
, _view_realized (false)
|
2020-08-09 19:25:10 -04:00
|
|
|
{
|
|
|
|
_ardour_buttons_box.set_spacing (6);
|
|
|
|
_ardour_buttons_box.set_border_width (6);
|
2022-02-04 17:05:58 -05:00
|
|
|
|
2022-04-04 14:48:56 -04:00
|
|
|
add_common_widgets (&_ardour_buttons_box);
|
2020-08-09 19:25:10 -04:00
|
|
|
|
2024-10-18 19:51:44 -04:00
|
|
|
_vst3->OnResizeView.connect (_resize_connection, invalidator (*this), std::bind (&VST3PluginUI::resize_callback, this, _1, _2), gui_context());
|
|
|
|
//pib->plugin()->PresetLoaded.connect (*this, invalidator (*this), std::bind (&VST3PluginUI::queue_port_update, this), gui_context ());
|
2020-08-09 19:25:10 -04:00
|
|
|
|
|
|
|
pack_start (_ardour_buttons_box, false, false);
|
|
|
|
_ardour_buttons_box.show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
VST3PluginUI::~VST3PluginUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
VST3PluginUI::get_preferred_height ()
|
|
|
|
{
|
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
ViewRect rect;
|
|
|
|
if (view && view->getSize (&rect) == kResultOk){
|
|
|
|
return rect.bottom - rect.top;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
VST3PluginUI::get_preferred_width ()
|
|
|
|
{
|
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
ViewRect rect;
|
|
|
|
if (view && view->getSize (&rect) == kResultOk){
|
|
|
|
return rect.right - rect.left;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VST3PluginUI::resizable ()
|
|
|
|
{
|
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
return view && view->canResize () == kResultTrue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VST3PluginUI::non_gtk_gui() const
|
|
|
|
{
|
2020-11-03 06:09:31 -05:00
|
|
|
/* return true to enable forward_key_event */
|
2020-08-09 19:25:10 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VST3PluginUI::package (Gtk::Window& win)
|
|
|
|
{
|
|
|
|
win.signal_map_event().connect (sigc::mem_fun(*this, &VST3PluginUI::start_updating));
|
|
|
|
win.signal_unmap_event().connect (sigc::mem_fun(*this, &VST3PluginUI::stop_updating));
|
2020-10-05 21:12:17 -04:00
|
|
|
|
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
FUnknownPtr<Presonus::IPlugInViewScaling> vs (view);
|
|
|
|
if (vs) {
|
|
|
|
vs->setContentScaleFactor (UIConfiguration::instance().get_ui_scale ());
|
|
|
|
}
|
|
|
|
|
2020-08-09 19:25:10 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VST3PluginUI::start_updating (GdkEventAny*)
|
|
|
|
{
|
|
|
|
_update_connection.disconnect();
|
|
|
|
_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &VST3PluginUI::parameter_update));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VST3PluginUI::stop_updating (GdkEventAny*)
|
|
|
|
{
|
|
|
|
_update_connection.disconnect();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VST3PluginUI::parameter_update ()
|
|
|
|
{
|
|
|
|
// XXX replicated plugins, too ?!
|
|
|
|
_vst3->update_contoller_param ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VST3PluginUI::forward_key_event (GdkEventKey* ev)
|
|
|
|
{
|
2020-11-03 06:09:31 -05:00
|
|
|
/* NB VST3NSViewPluginUI overrides this */
|
|
|
|
#if 0 // -> non_gtk_gui () -> true
|
|
|
|
// TODO: map key-events
|
2020-08-09 19:25:10 -04:00
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
switch (gdk_key->type) {
|
|
|
|
case GDK_KEY_PRESS:
|
2020-11-03 06:09:31 -05:00
|
|
|
/* onKeyDown (char16 key, int16 keyCode, int16 modifiers)
|
|
|
|
* key: unicode code of key
|
2020-08-09 19:25:10 -04:00
|
|
|
* keyCode: virtual keycode for non ascii keys - see VirtualKeyCodes in keycodes.h
|
|
|
|
* modifiers : any combination of modifiers - see KeyModifier in keycodes.h
|
|
|
|
*/
|
|
|
|
view->onKeyDown (ev->keyval, ev->hardware_keycode, ev->state);
|
|
|
|
break;
|
|
|
|
case GDK_KEY_RELEASE:
|
|
|
|
//view->onKeyUp (key, keyCode, modifiers);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VST3PluginUI::forward_scroll_event (GdkEventScroll* ev)
|
|
|
|
{
|
|
|
|
IPlugView* view = _vst3->view ();
|
|
|
|
switch (ev->direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
return view->onWheel (-1) == kResultTrue;
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
return view->onWheel (-1) == kResultTrue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|