clap_sys/ext/draft/
undo.rs

1use crate::{cstr, host::*, id::*, plugin::*};
2
3use std::ffi::{c_char, c_void, CStr};
4
5pub const CLAP_EXT_UNDO: &CStr = cstr!("clap.undo/4");
6pub const CLAP_EXT_UNDO_CONTEXT: &CStr = cstr!("clap.undo_context/4");
7pub const CLAP_EXT_UNDO_DELTA: &CStr = cstr!("clap.undo_delta/4");
8
9#[repr(C)]
10#[derive(Debug, Copy, Clone)]
11pub struct clap_undo_delta_properties {
12    pub has_delta: bool,
13    pub are_deltas_persistent: bool,
14    pub format_version: clap_id,
15}
16
17#[repr(C)]
18#[derive(Debug, Copy, Clone)]
19pub struct clap_plugin_undo_delta {
20    pub get_delta_properties: Option<
21        unsafe extern "C" fn(
22            plugin: *const clap_plugin,
23            properties: *mut clap_undo_delta_properties,
24        ),
25    >,
26    pub can_use_delta_format_version:
27        Option<unsafe extern "C" fn(plugin: *const clap_plugin, format_version: clap_id) -> bool>,
28    pub undo: Option<
29        unsafe extern "C" fn(
30            plugin: *const clap_plugin,
31            format_version: clap_id,
32            delta: *const c_void,
33            delta_size: usize,
34        ) -> bool,
35    >,
36    pub redo: Option<
37        unsafe extern "C" fn(
38            plugin: *const clap_plugin,
39            format_version: clap_id,
40            delta: *const c_void,
41            delta_size: usize,
42        ) -> bool,
43    >,
44}
45
46#[repr(C)]
47#[derive(Debug, Copy, Clone)]
48pub struct clap_plugin_undo_context {
49    pub set_can_undo: Option<unsafe extern "C" fn(plugin: *const clap_plugin, can_undo: bool)>,
50    pub set_can_redo: Option<unsafe extern "C" fn(plugin: *const clap_plugin, can_redo: bool)>,
51    pub set_undo_name:
52        Option<unsafe extern "C" fn(plugin: *const clap_plugin, name: *const c_char)>,
53    pub set_redo_name:
54        Option<unsafe extern "C" fn(plugin: *const clap_plugin, name: *const c_char)>,
55}
56
57#[repr(C)]
58#[derive(Debug, Copy, Clone)]
59pub struct clap_host_undo {
60    pub begin_change: Option<unsafe extern "C" fn(host: *const clap_host)>,
61    pub cancel_change: Option<unsafe extern "C" fn(host: *const clap_host)>,
62    pub change_made: Option<
63        unsafe extern "C" fn(
64            host: *const clap_host,
65            name: *const c_char,
66            delta: *const c_void,
67            delta_size: usize,
68            delta_can_undo: bool,
69        ),
70    >,
71    pub request_undo: Option<unsafe extern "C" fn(host: *const clap_host)>,
72    pub request_redo: Option<unsafe extern "C" fn(host: *const clap_host)>,
73    pub set_wants_context_updates:
74        Option<unsafe extern "C" fn(host: *const clap_host, is_subscribed: bool)>,
75}