patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob d93c2354339ee36b6b4bb98acecdfd7ec1a2a823 2564 bytes (raw)
name: tools/spectrum-installer/src/pages/layout.rs 	 # note: path name is non-authoritative(*)

 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2025-2026 Johannes Süllner <johannes.suellner@mailbox.org>

use iced::{
    Element, Length,
    widget::{Button, Column, Row, button, column, container, row, text},
};
use iced_fonts::bootstrap as icons;

use crate::destination_device::DestinationDevice;

use super::Event;

#[macro_export]
macro_rules! center_horizontal_in_container {
    ($e:expr) => {
        iced::widget::container($e)
            .width(iced::Length::Fill)
            .center_x(iced::Length::Fill)
    };
}
#[macro_export]
macro_rules! center_in_container {
    ($e:expr) => {
        iced::widget::container($e)
            .height(iced::Length::Fill)
            .width(iced::Length::Fill)
            .center_x(iced::Length::Fill)
            .center_y(iced::Length::Fill)
    };
}

const BOTTOM_BUTTON_SPACE: f32 = 2.0;
const BOTTOM_BUTTON_ROW_HEIGHT: f32 = 50.0;
const DISK_ICON_SIZE: u32 = 50;

fn bottom_button<'a>(
    button_content: Element<'a, Event>,
    button_on_press: Option<Event>,
) -> Button<'a, Event> {
    button(
        center_in_container!(button_content)
            .height(Length::Fill)
            .center_y(Length::Fill),
    )
    .on_press_maybe(button_on_press)
    .width(Length::Fill)
    .height(Length::Fill)
}

pub fn bottom_buttons_layout<'a>(
    button_matrix: impl IntoIterator<
        Item = impl IntoIterator<Item = (Element<'a, Event>, Option<Event>)>,
    >,
    main_element: Element<'a, Event>,
) -> Element<'a, Event> {
    let mut bottom_height = 0.0;
    let mut bottom_element = Column::new().spacing(BOTTOM_BUTTON_SPACE);
    for input_row in button_matrix.into_iter() {
        let mut output_row = Row::new().spacing(BOTTOM_BUTTON_SPACE);
        for (button_content, button_on_press) in input_row.into_iter() {
            output_row = output_row.push(bottom_button(button_content, button_on_press));
        }
        bottom_element = bottom_element.push(output_row);
        bottom_height += BOTTOM_BUTTON_ROW_HEIGHT;
    }

    column![
        center_horizontal_in_container!(main_element).height(Length::Fill),
        container(bottom_element).height(bottom_height)
    ]
    .into()
}

pub fn disk_element(device: &DestinationDevice) -> Element<'static, Event> {
    let icon: Element<Event> = icons::hdd().size(DISK_ICON_SIZE).into();

    row![
        icon,
        text(format!(
            "{}\n{}\n{}",
            device.name,
            device.path,
            device.size_as_human_readable_string(),
        ))
    ]
    .spacing(8)
    .into()
}

debug log:

solving d93c235 ...
found d93c235 in https://inbox.spectrum-os.org/spectrum-devel/20260204175543.22164-3-johannes.suellner@mailbox.org/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260204175543.22164-3-johannes.suellner@mailbox.org/
diff --git a/tools/spectrum-installer/src/pages/layout.rs b/tools/spectrum-installer/src/pages/layout.rs
new file mode 100644
index 0000000..d93c235

Checking patch tools/spectrum-installer/src/pages/layout.rs...
Applied patch tools/spectrum-installer/src/pages/layout.rs cleanly.

index at:
100644 d93c2354339ee36b6b4bb98acecdfd7ec1a2a823	tools/spectrum-installer/src/pages/layout.rs

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).