Skip to main content

vst_audio_protocol/
editor.rs

1//! Framework-independent native editor operations. Unsupported native features
2//! return RequestError; no operation falls back to loading code in the parent.
3/// A native window of the application that an editor may live inside.
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub enum ParentWindow {
6    /// An HWND of another process.
7    Win32 { hwnd: u64 },
8    /// An X11 window ID on the worker's display.
9    X11 { window: u64 },
10}
11
12#[derive(Clone, Debug, PartialEq)]
13pub enum EditorAction {
14    Show,
15    Hide,
16    Focus,
17    Resize { width: u32, height: u32 },
18    Scale(f32),
19    Inspect,
20    Capture,
21}
22/// The backend actually hosting the editor, independent of the requested policy.
23#[derive(Clone, Copy, Debug, Eq, PartialEq)]
24#[repr(u8)]
25#[non_exhaustive]
26pub enum EditorPlatform {
27    Win32 = 0,
28    Cocoa = 1,
29    X11 = 2,
30    Wayland = 3,
31}
32#[derive(Clone, Debug, PartialEq)]
33pub struct EditorStatus {
34    pub platform: EditorPlatform,
35    pub visible: bool,
36    pub embedded: bool,
37    pub width: u32,
38    pub height: u32,
39    pub scale: f32,
40    pub resize_supported: bool,
41    pub scale_supported: bool,
42}
43#[derive(Clone, Debug, Eq, PartialEq)]
44pub struct EditorImage {
45    pub width: u32,
46    pub height: u32,
47    pub rgba: Vec<u8>,
48}
49impl EditorImage {
50    pub fn valid(&self) -> bool {
51        self.width > 0
52            && self.height > 0
53            && self.width <= 2048
54            && self.height <= 2048
55            && self.rgba.len() == self.width as usize * self.height as usize * 4
56    }
57}
58#[derive(Debug)]
59pub enum EditorReply {
60    Status(EditorStatus),
61    Image(EditorImage),
62}