Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
aax_native_view.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6// Native-view helpers for the AAX editor shell. AAX hands the plug-in a host
7// owned parent view (NSView* on macOS) and sizes it from GetViewSize; the
8// plug-in's child view has to be placed inside that parent explicitly. These
9// helpers keep that placement, and the frame diagnostics that prove what the
10// host actually did, out of the shared PluginViewHost so no other format's
11// attach path changes. Every function is a no-op on platforms without a
12// native AAX parent, so the adapter can call them unconditionally.
13
14namespace pulp::format::aax {
15
18 float x = 0.0f;
19 float y = 0.0f;
20 float width = 0.0f;
21 float height = 0.0f;
22};
23
36
42constexpr float aax_child_top_left_y(float parent_height, float child_height, bool parent_flipped) {
43 if (parent_flipped)
44 return 0.0f;
45 const float y = parent_height - child_height;
46 return y > 0.0f ? y : 0.0f;
47}
48
52#if defined(__APPLE__)
53float aax_display_scale(void* native_parent) noexcept;
54#else
55inline float aax_display_scale(void*) noexcept {
56 return 1.0f;
57}
58#endif
59
60#if defined(__APPLE__)
63AaxNativeGeometry aax_native_geometry(void* native_parent, void* native_child) noexcept;
64
68void aax_place_child_top_left(void* native_parent, void* native_child) noexcept;
69
74void aax_fill_parent(void* native_parent, void* native_child) noexcept;
75
83void aax_set_child_tracks_parent(void* native_child, bool tracks) noexcept;
84#else
85inline AaxNativeGeometry aax_native_geometry(void*, void*) noexcept {
86 return {};
87}
88inline void aax_place_child_top_left(void*, void*) noexcept {}
89inline void aax_fill_parent(void*, void*) noexcept {}
90inline void aax_set_child_tracks_parent(void*, bool) noexcept {}
91#endif
92
94inline std::string aax_describe_geometry(const AaxNativeGeometry& g) {
95 auto rect = [](const AaxNativeRect& r) {
96 return std::to_string(static_cast<int>(r.width)) + "x" +
97 std::to_string(static_cast<int>(r.height)) + "@" +
98 std::to_string(static_cast<int>(r.x)) + "," + std::to_string(static_cast<int>(r.y));
99 };
100 if (!g.valid)
101 return "invalid";
102 return "parent=" + rect(g.parent_frame) + " parent_bounds=" + rect(g.parent_bounds) +
103 " child=" + rect(g.child_frame) +
104 " window=" + (g.has_window ? rect(g.window_frame) : std::string("none")) +
105 " scale=" + std::to_string(g.backing_scale) + (g.parent_flipped ? " flipped" : "");
106}
107
108} // namespace pulp::format::aax
Definition aax_editor.hpp:31
float aax_display_scale(void *native_parent) noexcept
Return the backing scale for the native AAX parent (NSView* on macOS).
std::string aax_describe_geometry(const AaxNativeGeometry &g)
One-line rendering of a geometry read for the host receipt.
Definition aax_native_view.hpp:94
constexpr float aax_child_top_left_y(float parent_height, float child_height, bool parent_flipped)
The y origin that puts a child of child_height at the TOP of a parent of parent_height.
Definition aax_native_view.hpp:42
void aax_place_child_top_left(void *native_parent, void *native_child) noexcept
Move the child to the parent's top-left corner, keeping the child's size.
void aax_fill_parent(void *native_parent, void *native_child) noexcept
Resize the child to the parent's bounds.
void aax_set_child_tracks_parent(void *native_child, bool tracks) noexcept
Whether the child follows the parent's size changes (its flexible autoresizing mask).
AaxNativeGeometry aax_native_geometry(void *native_parent, void *native_child) noexcept
Read the parent/child/window frames.
Everything the host-frame receipt needs in one read: the parent the host handed down,...
Definition aax_native_view.hpp:26
AaxNativeRect child_frame
child frame inside the parent
Definition aax_native_view.hpp:32
AaxNativeRect parent_frame
parent frame in its superview
Definition aax_native_view.hpp:30
AaxNativeRect parent_bounds
parent's own coordinate space
Definition aax_native_view.hpp:31
bool has_window
parent sits in a window
Definition aax_native_view.hpp:28
float backing_scale
window (or main screen) backing scale
Definition aax_native_view.hpp:34
bool parent_flipped
parent's y axis grows downward
Definition aax_native_view.hpp:29
bool valid
both views were non-null
Definition aax_native_view.hpp:27
AaxNativeRect window_frame
window frame on screen (logical points)
Definition aax_native_view.hpp:33
A native rectangle in the parent's own (logical point) coordinate space.
Definition aax_native_view.hpp:17
float width
Definition aax_native_view.hpp:20
float y
Definition aax_native_view.hpp:19
float height
Definition aax_native_view.hpp:21
float x
Definition aax_native_view.hpp:18