From f5a82152394fde4d8f740f664ab7737b82861618 Mon Sep 17 00:00:00 2001 From: cashmere Date: Tue, 28 Jul 2026 19:41:16 +0200 Subject: feat: GPUI desktop port foundation - scene crate: full project/scene/element model, serde round-trip proven against the web SerializedProject shape - transfer crate: .ocp zip container, cross-compat with web fflate archives proven in both directions - storage crate: filesystem project store replacing IndexedDB, .ocp import/export - media crate: ffmpeg-next 8 decoder (frames, audio, thumbnails, waveform summaries) - playback crate: wall-clock anchored, frame-rounded playback clock - gpu crate: native texture readback; compositor renders headless offscreen on Vulkan (spike test) - flake devshell: rust toolchain, GPUI native deps, ffmpeg dev, bindgen clang args; GPUI hello-world builds - port plan in notes/gpui-port.md --- rust/crates/effect-defs/src/params.rs | 165 ++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 rust/crates/effect-defs/src/params.rs (limited to 'rust/crates/effect-defs/src/params.rs') diff --git a/rust/crates/effect-defs/src/params.rs b/rust/crates/effect-defs/src/params.rs new file mode 100644 index 00000000..cc7c43dc --- /dev/null +++ b/rust/crates/effect-defs/src/params.rs @@ -0,0 +1,165 @@ +use scene::params::{ParamValue, ParamValues}; + +#[derive(Clone, Debug, PartialEq)] +pub struct ParamDependency { + pub param: String, + pub equals: ParamValue, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct SelectOption { + pub value: String, + pub label: String, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct NumberParamDefinition { + pub key: String, + pub label: String, + pub default_value: f64, + pub min: f64, + pub max: Option, + pub step: f64, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, + pub display_multiplier: Option, + pub unit: Option, + pub short_label: Option, +} + +impl NumberParamDefinition { + pub fn new( + key: &str, + label: &str, + default_value: f64, + min: f64, + max: Option, + step: f64, + ) -> Self { + Self { + key: key.to_string(), + label: label.to_string(), + default_value, + min, + max, + step, + group: None, + keyframable: None, + dependencies: Vec::new(), + display_multiplier: None, + unit: None, + short_label: None, + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct BooleanParamDefinition { + pub key: String, + pub label: String, + pub default_value: bool, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ColorParamDefinition { + pub key: String, + pub label: String, + pub default_value: String, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct SelectParamDefinition { + pub key: String, + pub label: String, + pub default_value: String, + pub options: Vec, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct TextParamDefinition { + pub key: String, + pub label: String, + pub default_value: String, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct FontParamDefinition { + pub key: String, + pub label: String, + pub default_value: String, + pub group: Option, + pub keyframable: Option, + pub dependencies: Vec, +} + +#[derive(Clone, Debug, PartialEq)] +pub enum ParamDefinition { + Number(NumberParamDefinition), + Boolean(BooleanParamDefinition), + Color(ColorParamDefinition), + Select(SelectParamDefinition), + Text(TextParamDefinition), + Font(FontParamDefinition), +} + +impl ParamDefinition { + pub fn key(&self) -> &str { + match self { + Self::Number(param) => ¶m.key, + Self::Boolean(param) => ¶m.key, + Self::Color(param) => ¶m.key, + Self::Select(param) => ¶m.key, + Self::Text(param) => ¶m.key, + Self::Font(param) => ¶m.key, + } + } + + pub fn label(&self) -> &str { + match self { + Self::Number(param) => ¶m.label, + Self::Boolean(param) => ¶m.label, + Self::Color(param) => ¶m.label, + Self::Select(param) => ¶m.label, + Self::Text(param) => ¶m.label, + Self::Font(param) => ¶m.label, + } + } + + pub fn default_value(&self) -> ParamValue { + match self { + Self::Number(param) => ParamValue::Number(param.default_value), + Self::Boolean(param) => ParamValue::Bool(param.default_value), + Self::Color(param) => ParamValue::String(param.default_value.clone()), + Self::Select(param) => ParamValue::String(param.default_value.clone()), + Self::Text(param) => ParamValue::String(param.default_value.clone()), + Self::Font(param) => ParamValue::String(param.default_value.clone()), + } + } + + pub fn numeric_range(&self) -> Option<(f64, Option, f64)> { + match self { + Self::Number(param) => Some((param.min, param.max, param.step)), + _ => None, + } + } +} + +pub fn build_default_param_values(params: &[ParamDefinition]) -> ParamValues { + params + .iter() + .map(|param| (param.key().to_string(), param.default_value())) + .collect() +} -- cgit v1.3.1