Skip to main content

euv_ui/component/segmented/view/
struct.rs

1use super::*;
2
3/// One entry of the [`euv_segmented`] control.
4///
5/// Carries the machine value written into the selection signal, the label
6/// the user reads, and whether the entry can be picked at all.
7#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
8pub struct EuvSegmentedOption {
9    /// The machine value written into the selection signal when picked.
10    #[get(type(copy))]
11    pub value: &'static str,
12    /// The display label shown on the segment.
13    #[get(type(copy))]
14    pub label: &'static str,
15    /// Whether the segment is disabled.
16    ///
17    /// A disabled segment is marked `disabled` and cannot be picked, so it
18    /// never writes into the selection signal.
19    #[get(type(copy))]
20    pub disabled: bool,
21}
22
23/// Props for the [`euv_segmented`] component.
24///
25/// The selection lives in a caller-owned `Signal<String>` so the control
26/// takes part in two-way binding with the rest of the page.
27#[derive(Clone, CustomDebug, Default)]
28pub struct EuvSegmentedProps {
29    /// The options rendered in the control, in display order.
30    pub options: Vec<EuvSegmentedOption>,
31    /// The signal holding the currently selected option value.
32    pub value: Signal<String>,
33    /// Optional callback receiving the value of the picked option.
34    #[debug(skip)]
35    pub on_change: Option<Rc<dyn Fn(&'static str)>>,
36}