gfx/native_editor.h
The native editor as a plugin format sees it: one object with a window in it, opened into whatever handle the host passes down.
#include <sonore/gfx/native_editor.h>- 3types
- 2other declarations
- Guides: The native editor
On this page
Design notes
What this adds over GenericEditor
GenericEditor is a Component. It has no window, no timer and no font, which is exactly why it can be tested by rendering into a Bitmap. This file is the part that cannot be tested that way: finding a typeface, making a real OS window, and keeping the two alive together for as long as the host wants an editor open.
Keeping them apart means the untestable part is small and dull. Everything with a rule in it -- which curve, which gesture, which pixel -- is on the other side of the line.
When there is no window backend
Win32, X11 and Cocoa each have one. Where none can run -- no display on Linux, an unsupported platform -- isAvailable() says so and unavailableReason() says why, so a wrapper can fall back to the webview and the fallback names its reason instead of the editor silently being a blank rectangle.
On Linux, "available" is decided TWICE: once at compile time, because <X11/Xlib.h> may not have been installed when the plugin was built, and once at runtime, because libX11.so.6 may not be on the machine that loads it. Both are real -- a build container is usually minimal and a Wayland-only session genuinely has no Xlib -- and both name themselves differently.
Types 3
A popup menu with a window under it.
Holds all three things a live menu is -- the item list, the component that draws it, and the window it lives in -- because all three have to die together and at a moment nobody is on the stack of. A menu that outlives its items draws freed strings; a window that outlives its grab locks the desktop.
The caller keeps this object alive and calls closeIfDone() from its own tick. There is no modal loop: a plugin runs inside a host's UI thread, and spinning one there is how a plugin freezes a DAW.
A small window that shows a component and takes no input at all.
A tooltip is not a menu. A menu grabs the pointer because it has to hear the click that dismisses it; a tooltip that grabbed would stop the user reaching the very control it is describing, and on macOS taking key focus would pull it off the host every time one appeared.
So it is the same platform window with the grab turned off, and it exists as a separate class rather than a flag on PopupWindow because the two have nothing else in common -- no dismissal, no choice, no callback.
A GenericEditor with a window around it.
Owns the content, the attachments and the OS window. Non-copyable by construction: the window procedure holds a pointer to this object.
Aliases 1
- using
using PlatformWindow = NativeWindowThis platform's window peer: NativeWindow on Windows, NativeWindowCocoa on macOS, NativeWindowX11 on Linux with the X11 headers. Not declared where there is no backend.gfx::PlatformWindow · native_editor.h:73