Audacity 3.2.0
x11/PlugFrame.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file PlugFrame.cpp
6
7 @author Vitaly Sverchinsky
8
9 @brief Part of Audacity VST3 module
10
11**********************************************************************/
12
13#include "PlugFrame.h"
14#include <wx/wupdlock.h>
15
16using namespace internal::x11;
17
18IMPLEMENT_REFCOUNT(PlugFrame)
19
20Steinberg::tresult PlugFrame::queryInterface (const ::Steinberg::TUID _iid, void** obj)
21{
22 QUERY_INTERFACE (_iid, obj, Steinberg::FUnknown::iid, Steinberg::IPlugFrame);
23 QUERY_INTERFACE (_iid, obj, Steinberg::IPlugFrame::iid, Steinberg::IPlugFrame);
24 //As VST3 documentation states, IPlugFrame also has to provide
25 //reference to the Steinberg::Linux::IRunLoop implementation.
26 if (mRunLoop && Steinberg::FUnknownPrivate::iidEqual (_iid, Steinberg::Linux::IRunLoop::iid))
27 {
28 mRunLoop->addRef();
29 *obj = static_cast<Steinberg::Linux::IRunLoop*>(mRunLoop.get());
30 return ::Steinberg::kResultOk;
31 }
32 *obj = nullptr;
33 return ::Steinberg::kNoInterface;
34}
35
36PlugFrame::PlugFrame(Steinberg::Linux::IRunLoop* runLoop, wxWindow* window)
37 : mWindow(window), mRunLoop(runLoop)
38{
39 FUNKNOWN_CTOR;
40}
42{
43 FUNKNOWN_DTOR;
44}
45
46void PlugFrame::init(Steinberg::IPlugView* view, Steinberg::ViewRect* size)
47{
48 if(!mInitialized)
49 resizeView(view, size);
50}
51
52Steinberg::tresult PlugFrame::resizeView(Steinberg::IPlugView* view, Steinberg::ViewRect* viewRect)
53{
54 if(auto window = mWindow.get())
55 {
56 auto size = wxSize(viewRect->getWidth(), viewRect->getHeight());
57
58 auto topWindow = wxGetTopLevelParent(window);
59 wxWindowUpdateLocker windowUpdateLocker(topWindow);
60
61 window->SetInitialSize(size);
62 //Wrapper (x11::SocketWindow) geometry needs to be updated too
63 window->GetChildren()[0]->SetInitialSize(size);
64
65 topWindow->SetMinSize(wxDefaultSize);
66 topWindow->Fit();
67 topWindow->SetMinSize(topWindow->GetSize());
68
69 if(!mInitialized)
70 {
71 topWindow->Center();
72 mInitialized = true;
73 }
74
75 return view->onSize(viewRect);
76 }
77 return Steinberg::kResultFalse;
78}
void init(Steinberg::IPlugView *view, Steinberg::ViewRect *size)
Steinberg::IPtr< Steinberg::Linux::IRunLoop > mRunLoop
Definition: x11/PlugFrame.h:29
PlugFrame(Steinberg::Linux::IRunLoop *runLoop, wxWindow *window)
Steinberg::tresult PLUGIN_API resizeView(Steinberg::IPlugView *view, Steinberg::ViewRect *newSize) override
wxWeakRef< wxWindow > mWindow
Definition: x11/PlugFrame.h:26