Skip to main content

lichtung_plot/text/
roles.rs

1//! Deliberate owner-level defaults; authored requests replace these whole values.
2
3use crate::text::TextLayout;
4
5/// An actual guide text role, independent of its shared Theme appearance.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum GuideTextRole {
8    /// Section titles.
9    Title,
10    /// Discrete entries and named guide keys.
11    Entry,
12    /// Continuous numeric labels and their explanation.
13    Number,
14}
15impl GuideTextRole {
16    pub(crate) const fn index(self) -> usize {
17        match self {
18            Self::Title => 0,
19            Self::Entry => 1,
20            Self::Number => 2,
21        }
22    }
23}
24
25#[derive(Debug, Clone, Default, PartialEq, Eq)]
26pub(crate) struct TextRoles(std::sync::Arc<RoleInstructions>);
27
28impl std::ops::Deref for TextRoles {
29    type Target = RoleInstructions;
30    fn deref(&self) -> &Self::Target {
31        &self.0
32    }
33}
34
35impl std::ops::DerefMut for TextRoles {
36    fn deref_mut(&mut self) -> &mut Self::Target {
37        std::sync::Arc::make_mut(&mut self.0)
38    }
39}
40
41#[derive(Debug, Clone, Default, PartialEq, Eq)]
42pub(crate) struct RoleInstructions {
43    pub(crate) ticks: [Option<TextLayout>; 2],
44    pub(crate) facet: [Option<TextLayout>; 2],
45    pub(crate) matrix: [Option<TextLayout>; 2],
46    pub(crate) guide: [Option<TextLayout>; 3],
47    pub(crate) value: Option<TextLayout>,
48    pub(crate) null_row: Option<TextLayout>,
49    pub(crate) estimate: Option<TextLayout>,
50    pub(crate) total: Option<TextLayout>,
51    pub(crate) significance: Option<TextLayout>,
52}