nice_plug_core/context/remote_controls.rs
1//! A context for defining plugin-specific [remote
2//! pages](https://github.com/free-audio/clap/blob/main/include/clap/ext/draft/remote-controls.h)
3//! for CLAP plugins.
4
5use crate::params::Param;
6
7/// A context for defining plugin-specific [remote
8/// pages](https://github.com/free-audio/clap/blob/main/include/clap/ext/draft/remote-controls.h)
9/// for CLAP plugins.
10///
11/// These pages can contain references to up to eight parameters, but if the plugin defines more
12/// parameters for a page then the pages are automatically split.
13pub trait RemoteControlsContext {
14 type Section: RemoteControlsSection;
15
16 /// Define a section containing one or more remote control pages. This can be used to group
17 /// remote control pages together. For instance, because an oscillator has so many parameters
18 /// that it needs to span multiple pages, or to group the parameters for both filters into a
19 /// single section.
20 fn add_section(&mut self, name: impl Into<String>, f: impl FnOnce(&mut Self::Section));
21}
22
23/// A section or group of parameter pages. Empty sections will not be visible when using the plugin.
24pub trait RemoteControlsSection {
25 type Page: RemoteControlsPage;
26
27 /// Add a named parameter page to the section. See the documentation of [`RemoteControlsPage`]
28 /// for more information.
29 fn add_page(&mut self, name: impl Into<String>, f: impl FnOnce(&mut Self::Page));
30}
31
32/// A page containing references to up to eight parameters. If the number of slots used exceeds
33/// eight, then the page is split automatically. In that case the split page will have indices
34/// appended to it. For example, the `Lengty Params Page` defining 16 parameters will become `Lengty
35/// Params Page 1` and `Lengthy Params Page 2`.
36pub trait RemoteControlsPage {
37 // Add a reference to one of the plugin's parameters to the page.
38 fn add_param(&mut self, param: &impl Param);
39
40 // Add an empty space on the page. Can be useful for grouping and aligning parameters within a
41 // page.
42 fn add_spacer(&mut self);
43}