Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
hosted_editor_container.hpp
Go to the documentation of this file.
1#pragma once
2
3// Host-owned container view for an embedded plugin editor.
4//
5// CLAP `set_parent` and VST3 `IPlugView::attached` both CONSUME a parent view:
6// the plugin inserts its own native view into what the host hands it, and never
7// hands a view back. PluginSlot::HostedEditor is the other way round — the slot
8// returns a `native_handle` that the host embeds. A host-owned container
9// reconciles the two: the slot creates a container, gives it to the plugin as
10// the parent, and returns the container as its HostedEditor::native_handle.
11//
12// AU v2's CocoaUI factory does return an NSView, so it does not need the
13// container to bridge anything — it wraps its view in one anyway so that
14// resize and teardown are uniform across formats.
15//
16// The container is created already inserted into `parent_window`'s content
17// view. That ordering is deliberate: EditorAttachment::create() calls
18// create_hosted_editor() BEFORE attach_native_child_view(), so a container that
19// deferred insertion would have the plugin run set_parent()/attached() against
20// a view with no window. Editors that bring up Metal/OpenGL layers on attach
21// misbehave in that state. The later attach_native_child_view() re-parents the
22// container within the same window, which is a cheap addSubview: move.
23//
24// Platforms without a native-window seam compile a stub whose create returns
25// nullptr; create_hosted_editor() then returns nullptr and EditorAttachment
26// already treats that as "no editor".
27
28#include <cstdint>
29
30namespace pulp::host {
31
36void* create_editor_container(void* parent_window, uint32_t width, uint32_t height);
37
43bool editor_container_adopt_view(void* container, void* native_view,
44 uint32_t width, uint32_t height);
45
47void resize_editor_container(void* container, uint32_t width, uint32_t height);
48
50void destroy_editor_container(void* container);
51
54double editor_container_scale(void* parent_window);
55
56} // namespace pulp::host
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
double editor_container_scale(void *parent_window)
Backing scale factor of parent_window (2.0 on Retina), for the plugin's scale negotiation.
bool editor_container_adopt_view(void *container, void *native_view, uint32_t width, uint32_t height)
Insert an already-created native child view into container, sized to fill it and set to track the con...
void destroy_editor_container(void *container)
Remove the container from its superview and release it. No-op when null.
void resize_editor_container(void *container, uint32_t width, uint32_t height)
Resize an existing container. No-op when container is null.
void * create_editor_container(void *parent_window, uint32_t width, uint32_t height)
Create a container view sized (width, height), inserted into parent_window's content view.