clap_sys/ext/
context_menu.rs1use crate::{cstr, host::*, id::*, plugin::*};
2
3use std::ffi::{c_char, c_void, CStr};
4
5pub const CLAP_EXT_CONTEXT_MENU: &CStr = cstr!("clap.context-menu/1");
6pub const CLAP_EXT_CONTEXT_MENU_COMPAT: &CStr = cstr!("clap.context-menu.draft/0");
7
8pub const CLAP_CONTEXT_MENU_TARGET_KIND_GLOBAL: u32 = 0;
9pub const CLAP_CONTEXT_MENU_TARGET_KIND_PARAM: u32 = 1;
10
11#[repr(C)]
12#[derive(Debug, Copy, Clone)]
13pub struct clap_context_menu_target {
14 pub kind: u32,
15 pub id: clap_id,
16}
17
18pub const CLAP_CONTEXT_MENU_ITEM_ENTRY: clap_context_menu_item_kind = 0;
19pub const CLAP_CONTEXT_MENU_ITEM_CHECK_ENTRY: clap_context_menu_item_kind = 1;
20pub const CLAP_CONTEXT_MENU_ITEM_SEPARATOR: clap_context_menu_item_kind = 2;
21pub const CLAP_CONTEXT_MENU_ITEM_BEGIN_SUBMENU: clap_context_menu_item_kind = 3;
22pub const CLAP_CONTEXT_MENU_ITEM_END_SUBMENU: clap_context_menu_item_kind = 4;
23pub const CLAP_CONTEXT_MENU_ITEM_TITLE: clap_context_menu_item_kind = 5;
24pub type clap_context_menu_item_kind = u32;
25
26#[repr(C)]
27#[derive(Debug, Copy, Clone)]
28pub struct clap_context_menu_entry {
29 pub label: *const c_char,
30 pub is_enabled: bool,
31 pub action_id: clap_id,
32}
33
34unsafe impl Send for clap_context_menu_entry {}
35unsafe impl Sync for clap_context_menu_entry {}
36
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct clap_context_menu_check_entry {
40 pub label: *const c_char,
41 pub is_enabled: bool,
42 pub is_checked: bool,
43 pub action_id: clap_id,
44}
45
46unsafe impl Send for clap_context_menu_check_entry {}
47unsafe impl Sync for clap_context_menu_check_entry {}
48
49#[repr(C)]
50#[derive(Debug, Copy, Clone)]
51pub struct clap_context_menu_item_title {
52 pub title: *const c_char,
53 pub is_enabled: bool,
54}
55
56unsafe impl Send for clap_context_menu_item_title {}
57unsafe impl Sync for clap_context_menu_item_title {}
58
59#[repr(C)]
60#[derive(Debug, Copy, Clone)]
61pub struct clap_context_menu_submenu {
62 pub label: *const c_char,
63 pub is_enabled: bool,
64}
65
66unsafe impl Send for clap_context_menu_submenu {}
67unsafe impl Sync for clap_context_menu_submenu {}
68
69#[repr(C)]
70#[derive(Debug, Copy, Clone)]
71pub struct clap_context_menu_builder {
72 pub ctx: *mut c_void,
73 pub add_item: Option<
74 unsafe extern "C" fn(
75 builder: *const clap_context_menu_builder,
76 item_kind: clap_context_menu_item_kind,
77 item_data: *const c_void,
78 ) -> bool,
79 >,
80 pub supports: Option<
81 unsafe extern "C" fn(
82 builder: *const clap_context_menu_builder,
83 item_kind: clap_context_menu_item_kind,
84 ) -> bool,
85 >,
86}
87
88unsafe impl Send for clap_context_menu_builder {}
89unsafe impl Sync for clap_context_menu_builder {}
90
91#[repr(C)]
92#[derive(Debug, Copy, Clone)]
93pub struct clap_plugin_context_menu {
94 pub populate: Option<
95 unsafe extern "C" fn(
96 plugin: *const clap_plugin,
97 target: *const clap_context_menu_target,
98 builder: *const clap_context_menu_builder,
99 ) -> bool,
100 >,
101 pub perform: Option<
102 unsafe extern "C" fn(
103 plugin: *const clap_plugin,
104 target: *const clap_context_menu_target,
105 action_id: clap_id,
106 ) -> bool,
107 >,
108}
109
110#[repr(C)]
111#[derive(Debug, Copy, Clone)]
112pub struct clap_host_context_menu {
113 pub populate: Option<
114 unsafe extern "C" fn(
115 host: *const clap_host,
116 target: *const clap_context_menu_target,
117 builder: *const clap_context_menu_builder,
118 ) -> bool,
119 >,
120 pub perform: Option<
121 unsafe extern "C" fn(
122 host: *const clap_host,
123 target: *const clap_context_menu_target,
124 action_id: clap_id,
125 ) -> bool,
126 >,
127 pub can_popup: Option<unsafe extern "C" fn(host: *const clap_host) -> bool>,
128 pub popup: Option<
129 unsafe extern "C" fn(
130 host: *const clap_host,
131 target: *const clap_context_menu_target,
132 screen_index: i32,
133 x: i32,
134 y: i32,
135 ) -> bool,
136 >,
137}