1
0
Fork 0

Add a context for defining remote control pages

This commit is contained in:
Robbert van der Helm 2023-04-22 15:53:04 +02:00
parent 2dbd835778
commit a7e4e8b31e
4 changed files with 56 additions and 1 deletions

View file

@ -6,6 +6,9 @@ pub mod gui;
pub mod init;
pub mod process;
// Contexts for more plugin-API specific features
pub mod remote_controls;
/// The currently active plugin API. This may be useful to display in an about screen in the
/// plugin's GUI for debugging purposes.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

View file

@ -0,0 +1,42 @@
//! A context for defining plugin-specific [remote
//! pages](https://github.com/free-audio/clap/blob/main/include/clap/ext/draft/remote-controls.h)
//! for CLAP plugins.
use crate::prelude::Param;
/// A context for defining plugin-specific [remote
/// pages](https://github.com/free-audio/clap/blob/main/include/clap/ext/draft/remote-controls.h)
/// for CLAP plugins.
///
/// These pages can contain references to up to eight parameters, but if the plugin defines more
/// parameters for a page then the pages are automatically split.
pub trait RemoteControlsContext {
type Section: RemoteControlsSection;
/// Define a section containing one or more remote control pages. This can be used to group
/// remote control pages together. For instance, because an oscillator has so many parameters
/// that it needs to span multiple pages, or to group the parameters for both filters into a
/// single section.
fn add_section(&mut self, name: impl Into<String>, f: impl FnOnce(&mut Self::Section));
}
/// A section or group of parameter pages. Empty sections will not be visible when using the plugin.
pub trait RemoteControlsSection {
type Page: RemoteControlsPage;
/// Add a named parameter page to the section. See the documentation of [`RemoteControlsPage`]
/// for more information.
fn add_page(&mut self, name: impl Into<String>, f: impl FnOnce(&mut Self::Page));
}
/// A page containing references to up to eight parameters. If the number of slots used exceeds
/// eight, then the page is split automatically. In that case the split page will have indices
/// appended to it. For example, the `Lengty Params Page` defining 16 parameters will become `Lengty
/// Params Page 1` and `Lengthy Params Page 2`.
pub trait RemoteControlsPage {
// Add a reference to one of the plugin's parameters to the page.
fn add_param(&mut self, param: &impl Param);
//
fn add_spacer(&mut self);
}

View file

@ -1,7 +1,8 @@
use super::Plugin;
use crate::prelude::ClapFeature;
use crate::prelude::{ClapFeature, RemoteControlsContext};
/// Provides auxiliary metadata needed for a CLAP plugin.
#[allow(unused_variables)]
pub trait ClapPlugin: Plugin {
/// A unique ID that identifies this particular plugin. This is usually in reverse domain name
/// notation, e.g. `com.manufacturer.plugin-name`.
@ -18,6 +19,12 @@ pub trait ClapPlugin: Plugin {
/// If set, this informs the host about the plugin's capabilities for polyphonic modulation.
const CLAP_POLY_MODULATION_CONFIG: Option<PolyModulationConfig> = None;
/// This function can be implemented to define plugin-specific [remote control
/// pages](https://github.com/free-audio/clap/blob/main/include/clap/ext/draft/remote-controls.h)
/// that the host can use to provide better hardware mapping for a plugin. See the linked
/// extension for more information.
fn remote_controls(&self, context: &mut impl RemoteControlsContext) {}
}
/// Configuration for the plugin's polyphonic modulation options, if it supports .

View file

@ -20,6 +20,9 @@ pub use crate::buffer::Buffer;
pub use crate::context::gui::{AsyncExecutor, GuiContext, ParamSetter};
pub use crate::context::init::InitContext;
pub use crate::context::process::{ProcessContext, Transport};
pub use crate::context::remote_controls::{
RemoteControlsContext, RemoteControlsPage, RemoteControlsSection,
};
pub use crate::context::PluginApi;
// This also includes the derive macro
pub use crate::editor::{Editor, ParentWindowHandle};