perspective_viewer/components/style_controls/number_string_format/
misc_section.rs1use yew::html;
14
15use super::CustomNumberFormat;
16use crate::components::style_controls::{CustomNumberFormatMsg, NotationName};
17use crate::config::*;
18use crate::ui::SelectEnumField;
19
20impl CustomNumberFormat {
21 pub fn misc_section(&self, ctx: &yew::prelude::Context<Self>) -> yew::prelude::Html {
22 let compact_display_checkbox = if let Some(Notation::Compact(val)) = self.config._notation {
23 let cb = ctx.link().callback(CustomNumberFormatMsg::CompactDisplay);
24 Some(html! {
25 <SelectEnumField<CompactDisplay>
26 label="compact-display"
27 on_change={cb}
28 current_value={val}
29 />
30 })
31 } else {
32 None
33 };
34
35 let defaults = &ctx.props().defaults;
36 html! {
37 <>
38 <SelectEnumField<NotationName>
39 label="notation"
40 on_change={ctx.link().callback(CustomNumberFormatMsg::NotationChanged)}
41 current_value={self.notation.unwrap_or_default()}
42 default_value={NotationName::from(&defaults.notation)}
43 />
44 { compact_display_checkbox }
45 <SelectEnumField<UseGrouping>
46 label="use-grouping"
47 on_change={ctx.link().callback(CustomNumberFormatMsg::UseGrouping)}
48 current_value={self.config.use_grouping.unwrap_or(defaults.use_grouping)}
49 default_value={defaults.use_grouping}
50 />
51 <SelectEnumField<SignDisplay>
52 label="sign-display"
53 on_change={ctx.link().callback(CustomNumberFormatMsg::SignDisplay)}
54 current_value={self.config.sign_display.unwrap_or(defaults.sign_display)}
55 default_value={defaults.sign_display}
56 />
57 </>
58 }
59 }
60}