Skip to main content

waft_material/compose/
pane_scaffold_role.rs

1//! The roles a pane scaffold's three panes can have.
2
3/// The role of one pane in a three-pane scaffold.
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5pub enum ThreePaneScaffoldRole {
6    /// The most important pane, such as a list-detail view's detail.
7    Primary,
8    /// The pane that supplements the primary one, such as a list-detail view's list.
9    Secondary,
10    /// The pane for additional content, shown on a wide window.
11    Tertiary,
12}
13
14impl ThreePaneScaffoldRole {
15    /// The three roles, in priority order.
16    pub(crate) const ALL: [ThreePaneScaffoldRole; 3] = [
17        ThreePaneScaffoldRole::Primary,
18        ThreePaneScaffoldRole::Secondary,
19        ThreePaneScaffoldRole::Tertiary,
20    ];
21
22    /// The role's place in [`ALL`](Self::ALL), for arrays indexed by role.
23    pub(crate) fn index(self) -> usize {
24        match self {
25            ThreePaneScaffoldRole::Primary => 0,
26            ThreePaneScaffoldRole::Secondary => 1,
27            ThreePaneScaffoldRole::Tertiary => 2,
28        }
29    }
30}
31
32/// [`ThreePaneScaffoldRole`]'s names in a list-detail scaffold.
33pub struct ListDetailPaneScaffoldRole;
34
35impl ListDetailPaneScaffoldRole {
36    /// The list.
37    pub const LIST: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Secondary;
38    /// The selected item's detail.
39    pub const DETAIL: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Primary;
40    /// The third pane.
41    pub const EXTRA: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Tertiary;
42}
43
44/// [`ThreePaneScaffoldRole`]'s names in a supporting-pane scaffold.
45pub struct SupportingPaneScaffoldRole;
46
47impl SupportingPaneScaffoldRole {
48    /// The main content.
49    pub const MAIN: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Primary;
50    /// The supporting content, below the main content on a phone.
51    pub const SUPPORTING: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Secondary;
52    /// The third pane.
53    pub const EXTRA: ThreePaneScaffoldRole = ThreePaneScaffoldRole::Tertiary;
54}