ltn/components/
left_panel.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use widgetry::{
    CornerRounding, EventCtx, HorizontalAlignment, Panel, PanelBuilder, PanelDims,
    VerticalAlignment, Widget,
};

use super::AppwidePanel;

pub struct LeftPanel;

impl LeftPanel {
    // No proposals panel
    pub fn builder(ctx: &EventCtx, top_panel: &Panel, contents: Widget) -> PanelBuilder {
        let top_height = top_panel.panel_dims().height;
        Panel::new_builder(contents.corner_rounding(CornerRounding::NoRounding))
            .aligned(
                HorizontalAlignment::Left,
                VerticalAlignment::Below(top_height),
            )
            .dims_height(PanelDims::ExactPixels(
                ctx.canvas.window_height - top_height,
            ))
    }

    pub fn right_of_proposals(
        ctx: &EventCtx,
        appwide_panel: &AppwidePanel,
        contents: Widget,
    ) -> PanelBuilder {
        let buffer = 5.0;
        let top_height = appwide_panel.top_panel.panel_dims().height;
        Panel::new_builder(contents)
            .aligned(
                HorizontalAlignment::RightOf(appwide_panel.left_panel.panel_dims().width + buffer),
                VerticalAlignment::Below(top_height),
            )
            .dims_height(PanelDims::ExactPixels(
                ctx.canvas.window_height - top_height,
            ))
    }
}

pub struct BottomPanel;

impl BottomPanel {
    pub fn new(ctx: &mut EventCtx, appwide_panel: &AppwidePanel, contents: Widget) -> Panel {
        let left_panel_width = appwide_panel.left_panel.panel_dims().width;
        Panel::new_builder(contents.corner_rounding(CornerRounding::NoRounding))
            .aligned(
                HorizontalAlignment::RightOf(left_panel_width),
                VerticalAlignment::Bottom,
            )
            .dims_width(PanelDims::ExactPixels(
                ctx.canvas.window_width - left_panel_width,
            ))
            .build(ctx)
    }
}