Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
vst3_plug_view.hpp
Go to the documentation of this file.
1#pragma once
2
3// VST3 IPlugView implementation for Pulp
4// Creates an AutoUi-based editor view that embeds in the host's window.
5// Uses PluginViewHost for platform-native rendering (CoreGraphics or GPU).
6//
7// Built from VST3 SDK (MIT license) CPluginView base class.
8
10#include <pulp/state/store.hpp>
11
12#ifdef PULP_VST3_GUI
13
16
17#include <memory>
18
19// VST3 SDK
20#include <public.sdk/source/common/pluginview.h>
21
22namespace pulp::format::vst3 {
23
24// IPlugView implementation that owns a ViewBridge. The bridge builds the
25// view tree (custom create_view() or scripted/AutoUi fallback), dispatches
26// lifecycle callbacks on the Processor, and tracks secondary views.
27class PulpPlugView : public Steinberg::CPluginView {
28public:
29 PulpPlugView(Processor& processor, state::StateStore& store,
30 runtime::AliveToken::Handle owner_alive = {});
31 ~PulpPlugView() override;
32
33 // IPlugView overrides
34 Steinberg::tresult PLUGIN_API isPlatformTypeSupported(Steinberg::FIDString type) override;
35 Steinberg::tresult PLUGIN_API attached(void* parent, Steinberg::FIDString type) override;
36 Steinberg::tresult PLUGIN_API removed() override;
37 Steinberg::tresult PLUGIN_API setFrame(Steinberg::IPlugFrame* frame) override;
38 Steinberg::tresult PLUGIN_API getSize(Steinberg::ViewRect* size) override;
39 Steinberg::tresult PLUGIN_API onSize(Steinberg::ViewRect* newSize) override;
40 // Resize negotiation (proportional + aspect-locked). The host calls
41 // checkSizeConstraint() during a user drag to snap the candidate
42 // rect to the editor's design aspect; onSize() then applies it. The
43 // PluginViewHost scales content to fit via its design viewport.
44 Steinberg::tresult PLUGIN_API canResize() override;
45 Steinberg::tresult PLUGIN_API checkSizeConstraint(Steinberg::ViewRect* rect) override;
46 // Space-to-focused-text-field via the IPlugView key pipeline. REAPER (with
47 // "send all keyboard input to plug-in" OFF — its default) offers keys to the
48 // view through onKeyDown BEFORE its own accelerator table; returning
49 // kResultFalse is what lets Space fall through to transport, so the NSView
50 // key path never sees it at all (host_quirks: reaper_keyboard_only_space —
51 // Space is also the only key REAPER delivers well-formed here). Consumed
52 // only when a text field inside THIS editor's tree holds focus.
53 Steinberg::tresult PLUGIN_API onKeyDown(Steinberg::char16 key, Steinberg::int16 keyCode,
54 Steinberg::int16 modifiers) override;
55
56 private:
57#if defined(__linux__)
58 class LinuxFrameTimer;
59 friend class LinuxFrameTimer;
60 void register_linux_frame_timer();
61 void unregister_linux_frame_timer();
62 void on_linux_frame_timer();
63 std::unique_ptr<LinuxFrameTimer> linux_frame_timer_;
64 Steinberg::Linux::IRunLoop* linux_run_loop_ = nullptr;
65 bool linux_timer_registered_ = false;
66#else
67 void register_linux_frame_timer() {}
68 void unregister_linux_frame_timer() {}
69#endif
70 friend struct PulpPlugViewTestAccess;
71 Processor& processor_;
72 state::StateStore& store_;
73 ViewBridge bridge_;
74 std::unique_ptr<view::PluginViewHost> editor_host_;
75 // Forwards the host's GPU-surface transitions into the scripted UI session.
76 // Declared AFTER editor_host_ so destruction order alone already drops it
77 // before the host; removed() resets it explicitly because bridge_ (which
78 // owns the session the observer writes into) outlives both.
79 view::PluginViewHost::GpuSurfaceSubscription gpu_surface_binding_;
80};
81
82} // namespace pulp::format::vst3
83
84#endif // PULP_VST3_GUI
Definition vst3_adapter.hpp:61
@ Processor
Definition graph_runtime_plan.hpp:15
@ removed
Definition udev_monitor.hpp:26