euv_ui/component/anchor/view/struct.rs
1use super::*;
2
3/// One entry of the [`euv_anchor`] list.
4///
5/// Carries the machine value the anchor points at and the label the
6/// reader sees.
7#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
8pub struct EuvAnchorItem {
9 /// The machine value of the anchor target.
10 #[get(type(copy))]
11 pub value: &'static str,
12 /// The display label of the anchor entry.
13 #[get(type(copy))]
14 pub label: &'static str,
15}
16
17/// Props for the [`euv_anchor`] component.
18///
19/// Defines the strongly-typed interface for an anchor list: the entries
20/// it holds and the entry that is currently the active one.
21#[derive(Clone, CustomDebug, Default)]
22pub struct EuvAnchorProps {
23 /// The anchor entries, in display order.
24 pub items: Vec<EuvAnchorItem>,
25 /// The heading above the entries (skipped when empty).
26 pub title: &'static str,
27 /// The value of the entry that is currently active.
28 pub active: Signal<String>,
29 /// The callback fired when an entry is taken.
30 #[debug(skip)]
31 pub on_select: Option<Rc<dyn Fn(&'static str)>>,
32}