1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! Host-side editor (GUI) hosting interface.
//!
//! Plugins that ship a custom editor expose it through their
//! format's GUI API: `clap.gui`, `kAudioUnitProperty_CocoaUI`,
//! `IEditController::createView`, LV2 `ui:UI`. truce-rack-core wraps
//! these behind a single [`PluginEditor`] trait so a host doesn't
//! care which format produced the editor — it only needs a
//! native parent window handle and a place to put the resulting
//! view.
//!
//! # Threading
//!
//! Editor methods run on the **main (UI) thread**. Audio
//! processing (the `Plugin::process` path) runs on the audio
//! thread. The host application is responsible for serialising
//! the two — never invoke editor methods while the audio thread
//! holds a `&mut PluginCore`. Rust's borrow rules enforce this
//! because [`crate::PluginCore::editor`] borrows `&mut self`.
//!
//! # Platform handles
//!
//! Editors attach to a native parent window via a
//! [`WindowHandle`]. The variant tells the wrapper which API to
//! use:
//!
//! - macOS: [`WindowHandle::NSView`] — pointer to an `NSView*`.
//! - Windows: [`WindowHandle::HWND`] — `HWND`.
//! - Linux X11: [`WindowHandle::X11`] — the X11 window ID.
//!
//! Wayland support is currently unwired; CLAP also defines
//! a Wayland API but few hosts implement it.
use crateResult;
use c_void;
/// Native parent window the plugin's editor view attaches to.
///
/// The host opens its own window, picks the appropriate variant
/// for the platform, and hands it to [`PluginEditor::open`]. The
/// plugin embeds its view inside that parent — the host stays in
/// charge of the outer window's lifecycle.
/// Editor-side view of a hosted plugin's UI.
///
/// Created by [`crate::PluginCore::editor`] when a plugin reports a
/// custom editor (its format-specific GUI extension is present
/// and `is_api_supported` returns true for the platform's API).
/// Methods correspond to the union of `clap.gui`, AU's
/// `kAudioUnitProperty_CocoaUI`, and VST3's `IPlugView`.
///
/// All methods run on the main (UI) thread; see the module
/// docs.