diff --git a/Cargo.lock b/Cargo.lock index 9215b18a4939d39e4b63b977cc652cfe6f5a0930..86278c3ec1285c1a07c0636e13e2c1bc91a934fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "aligned-vec" version = "0.5.0" @@ -804,7 +810,7 @@ version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.85", @@ -1935,6 +1941,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -2305,6 +2317,7 @@ dependencies = [ "iced_runtime", "num-traits", "once_cell", + "ouroboros", "rustc-hash 2.0.0", "thiserror", "unicode-segmentation", @@ -3486,6 +3499,31 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "ouroboros" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944fa20996a25aded6b4795c6d63f10014a7a83f8be9828a11860b08c5fc4a67" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" +dependencies = [ + "heck 0.4.1", + "itertools", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.85", +] + [[package]] name = "overload" version = "0.1.1" @@ -3777,6 +3815,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", + "version_check", + "yansi", +] + [[package]] name = "profiling" version = "1.0.15" @@ -4846,7 +4897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ "cfg-expr", - "heck", + "heck 0.5.0", "pkg-config", "toml", "version-compare", @@ -6458,6 +6509,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yazi" version = "0.1.6" diff --git a/gui/Cargo.toml b/gui/Cargo.toml index e03e7ded6f474a93b52fe9bb59098c1f11407b9c..c7dd5fe6c383a7cc80a4fec81531c1659db0acaf 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -8,7 +8,7 @@ repository.workspace = true license.workspace = true [dependencies] -iced = { version = "0.13.1", features = ["image", "svg", "tokio", "advanced"] } +iced = { version = "0.13.1", features = ["image", "svg", "tokio", "advanced", "lazy"] } rfd = { version = "0.15.0", default-features = false, features = ["xdg-portal", "tokio"] } bb-imager = { path = "../bb-imager", version = "0.0.3" } tracing-subscriber = "0.3.18" diff --git a/gui/src/constants.rs b/gui/src/constants.rs index 7404028ea4d4c62ce2aaa6f414d027bda49d8b8e..380654684427f38d486b93b4020f6a8b2b172fb3 100644 --- a/gui/src/constants.rs +++ b/gui/src/constants.rs @@ -21,3 +21,5 @@ pub const FONT_BOLD: iced::Font = { }; pub const FONT_REGULAR_BYTES: &[u8] = include_bytes!("../assets/fonts/Roboto-Regular.ttf"); pub const FONT_BOLD_BYTES: &[u8] = include_bytes!("../assets/fonts/Roboto-Bold.ttf"); + +pub const WINDOW_SIZE: iced::Size = iced::Size::new(850.0, 600.0); diff --git a/gui/src/main.rs b/gui/src/main.rs index 35bca73f9c6ee560f939d6680de8386e67e7310c..6cf2e614c1c6f950047b6e95d9ddb1b3f28c66dc 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -23,7 +23,8 @@ fn main() -> iced::Result { .expect("Failed to parse config"); let settings = iced::window::Settings { - min_size: Some(iced::Size::new(850.0, 720.0)), + min_size: Some(constants::WINDOW_SIZE), + size: constants::WINDOW_SIZE, ..Default::default() }; @@ -436,10 +437,9 @@ impl BBImager { .width(iced::Length::FillPortion(1)) .align_x(iced::Alignment::Center) ] - .padding(64) + .padding(48) .spacing(48) .width(iced::Length::Fill) - .height(iced::Length::Fill) .align_y(iced::Alignment::Center); let action_btn_row = widget::row![ @@ -447,16 +447,18 @@ impl BBImager { widget::horizontal_space().width(iced::Length::FillPortion(5)), next_btn.width(iced::Length::FillPortion(1)) ] - .padding(64) + .padding(48) .width(iced::Length::Fill) - .height(iced::Length::Fill) .align_y(iced::Alignment::Center); let bottom = widget::container( - widget::column![choice_btn_row, action_btn_row] - .width(iced::Length::Fill) - .height(iced::Length::Fill) - .align_x(iced::Alignment::Center), + widget::column![ + choice_btn_row.height(iced::Length::FillPortion(1)), + action_btn_row.height(iced::Length::FillPortion(1)) + ] + .width(iced::Length::Fill) + .height(iced::Length::Fill) + .align_x(iced::Alignment::Center), ) .style(|_| widget::container::background(iced::Color::parse("#aa5137").unwrap())); @@ -631,46 +633,47 @@ impl BBImager { } fn extra_config_view(&self) -> Element<BBImagerMessage> { - let action_btn_row = widget::row![ - home_btn("BACK", true, iced::Length::Fill) - .style(widget::button::secondary) - .width(iced::Length::FillPortion(1)) - .on_press(BBImagerMessage::SwitchScreen(Screen::Home)), - widget::horizontal_space().width(iced::Length::FillPortion(5)), - home_btn("WRITE", true, iced::Length::Fill) - .style(widget::button::secondary) - .width(iced::Length::FillPortion(1)) - .on_press(BBImagerMessage::StartFlashing) - ] - .padding(32) - .width(iced::Length::Fill); - - let form = match self.flashing_config.as_ref().unwrap() { - bb_imager::FlashingConfig::LinuxSd(x) => self.linux_sd_form(x), - bb_imager::FlashingConfig::Bcf(x) => widget::column![widget::toggler(!x.verify) - .label("Skip Verification") - .on_toggle(|y| { - BBImagerMessage::UpdateFlashConfig(bb_imager::FlashingConfig::Bcf( - x.clone().update_verify(!y), - )) - })], - bb_imager::FlashingConfig::Msp430 => widget::column([]), - } - .spacing(5) - .width(iced::Length::Fill); + widget::responsive(|size| { + let action_btn_row = widget::row![ + home_btn("BACK", true, iced::Length::Fill) + .style(widget::button::secondary) + .width(iced::Length::FillPortion(1)) + .on_press(BBImagerMessage::SwitchScreen(Screen::Home)), + widget::horizontal_space().width(iced::Length::FillPortion(5)), + home_btn("WRITE", true, iced::Length::Fill) + .style(widget::button::secondary) + .width(iced::Length::FillPortion(1)) + .on_press(BBImagerMessage::StartFlashing) + ] + .padding(32) + .width(iced::Length::Fill); - widget::column![ - text("Extra Configuration").size(28), - widget::horizontal_rule(2), - form, - widget::vertical_space(), - action_btn_row - ] - .spacing(10) - .padding(10) - .height(iced::Length::Fill) - .width(iced::Length::Fill) - .align_x(iced::Alignment::Center) + let form = match self.flashing_config.as_ref().unwrap() { + bb_imager::FlashingConfig::LinuxSd(x) => self.linux_sd_form(x), + bb_imager::FlashingConfig::Bcf(x) => widget::column![widget::toggler(!x.verify) + .label("Skip Verification") + .on_toggle(|y| { + BBImagerMessage::UpdateFlashConfig(bb_imager::FlashingConfig::Bcf( + x.clone().update_verify(!y), + )) + })], + bb_imager::FlashingConfig::Msp430 => widget::column([]), + } + .spacing(5); + + widget::column![ + text("Extra Configuration").size(28), + widget::horizontal_rule(2), + widget::scrollable(form).height(size.height - 210.0), + action_btn_row, + ] + .spacing(10) + .padding(10) + .height(iced::Length::Fill) + .width(iced::Length::Fill) + .align_x(iced::Alignment::Center) + .into() + }) .into() } @@ -802,33 +805,37 @@ impl FlashingScreen { } fn view(&self) -> Element<BBImagerMessage> { - let prog_bar = self.progress.bar(); + widget::responsive(|size| { + let prog_bar = self.progress.bar(); - let btn = if self.running { - home_btn("CANCEL", true, iced::Length::Shrink).on_press(BBImagerMessage::CancelFlashing) - } else { - home_btn("HOME", true, iced::Length::Shrink) - .on_press(BBImagerMessage::SwitchScreen(Screen::Home)) - }; + let btn = if self.running { + home_btn("CANCEL", true, iced::Length::Shrink) + .on_press(BBImagerMessage::CancelFlashing) + } else { + home_btn("HOME", true, iced::Length::Shrink) + .on_press(BBImagerMessage::SwitchScreen(Screen::Home)) + }; - let bottom = widget::container( - widget::column![self.about(), widget::vertical_space(), btn, prog_bar] + let bottom = widget::container( + widget::column![self.about().height(size.height - 410.0), btn, prog_bar] + .width(iced::Length::Fill) + .height(iced::Length::Fill) + .align_x(iced::Alignment::Center), + ) + .style(|_| widget::container::background(iced::Color::parse("#aa5137").unwrap())); + + widget::column![helpers::logo(), bottom] + .spacing(10) .width(iced::Length::Fill) .height(iced::Length::Fill) - .align_x(iced::Alignment::Center), - ) - .style(|_| widget::container::background(iced::Color::parse("#aa5137").unwrap())); - - widget::column![helpers::logo(), bottom] - .spacing(10) - .width(iced::Length::Fill) - .height(iced::Length::Fill) - .align_x(iced::Alignment::Center) - .into() + .align_x(iced::Alignment::Center) + .into() + }) + .into() } - fn about(&self) -> Element<'_, BBImagerMessage> { - widget::container(widget::rich_text![ + fn about(&self) -> widget::Container<'_, BBImagerMessage> { + widget::container(widget::scrollable(widget::rich_text![ widget::span(constants::BEAGLE_BOARD_ABOUT) .link(BBImagerMessage::OpenUrl( "https://www.beagleboard.org/about".into() @@ -838,9 +845,8 @@ impl FlashingScreen { widget::span("For more information, check out our documentation") .link(BBImagerMessage::OpenUrl(self.documentation.clone().into())) .color(iced::Color::WHITE) - ]) - .padding(30) - .into() + ])) + .padding(32) } }