Skip to main content

perspective_viewer/components/style_controls/number_string_format/
misc_section.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
5// ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors.                              ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13use yew::html;
14
15use super::CustomNumberFormat;
16use crate::components::form::select_enum_field::SelectEnumField;
17use crate::components::style_controls::{CustomNumberFormatMsg, NotationName};
18use crate::config::*;
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}