Skip to main content

day_spec/controls/
stepper.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4pub const KIND: &str = "day.piece.stepper";
5
6/// The tag every in-process native arm reports a value under. Across a native boundary the
7/// tag arrives empty and only the payload matters (§8.2); the front-end reads the text
8/// either way.
9pub const VALUE_TAG: &str = "stepper:value";
10
11/// Full props (realize) for the native leaf. Everything but `value` is set once at build.
12#[derive(Clone, Debug, PartialEq)]
13pub struct StepperProps {
14    pub value: f64,
15    pub min: f64,
16    pub max: f64,
17    pub step: f64,
18    /// Fraction digits the field shows (and the native widget's display precision).
19    pub decimals: u32,
20}
21
22impl Default for StepperProps {
23    fn default() -> Self {
24        StepperProps {
25            value: 0.0,
26            min: 0.0,
27            max: 100.0,
28            step: 1.0,
29            decimals: 0,
30        }
31    }
32}
33
34/// The single imperative update: show `value` in the field.
35#[derive(Clone, Copy, Debug, PartialEq)]
36pub enum StepperPatch {
37    SetValue(f64),
38}