VectorCraft: An open-source, vector art tool written by scratch in pure Rust
fix(ui): keep All Tools drawer compact on wide screens (#1018)
Nigel Ihza Firdausy63026402a135
diff --git a/crates/ui-egui/src/dialogs/all_tools.rs b/crates/ui-egui/src/dialogs/all_tools.rsindex 402e6f444..b5ce58253 100644--- a/crates/ui-egui/src/dialogs/all_tools.rs+++ b/crates/ui-egui/src/dialogs/all_tools.rs@@ -10,7 +10,16 @@ use crate::state::Dialog;use crate::theme::Tokens;use crate::{VectorcraftApp, icons, widgets};-pub(super) const SPEC: DialogSpec = DialogSpec { heading: |_| tl!("All Tools").into(), body, ok: None, min_width: 560.0, ..DialogSpec::FORM };+/// Keep the drawer to two tool cells instead of stretching across a wide window.+/// The shared dialog frame will shrink further on narrow screens.+pub(super) const SPEC: DialogSpec = DialogSpec {+ heading: |_| tl!("All Tools").into(),+ body,+ ok: None,+ min_width: 376.0,+ max_width: Some(376.0),+ ..DialogSpec::FORM+};/// A tool's cell: its icon and name.const CELL: egui::Vec2 = vec2(176.0, 28.0);@@ -95,6 +104,30 @@ mod tests {use super::*;/// Every tool is listed once, under a heading; the Basic toolbar's groups come first, in its order.+++ /// #1018: the All Tools drawer must not fill a desktop-sized window.+ #[test]+ fn all_tools_dialog_has_a_bounded_width() {+ use egui::{Pos2, RawInput, Rect};++ let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());+ app.ui.dialog = Some(Dialog::new("allTools", serde_json::json!({})));+ let ctx = egui::Context::default();+ crate::theme::install_fonts(&ctx);+ crate::theme::apply(&ctx, Default::default());+ for width in [1280.0, 430.0] {+ let screen = Rect::from_min_size(Pos2::ZERO, vec2(width, 900.0));+ for _ in 0..6 {+ let mut out = ctx.run_ui(RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| super::super::show(&mut app, ui.ctx()));+ out.textures_delta.clear();+ }+ let rect = ctx.memory(|m| m.area_rect(egui::Id::new(("dialog", "allTools")))).expect("drawer is shown");+ assert!(rect.width() <= width, "drawer exceeds viewport: {rect:?}");+ assert!(rect.width() <= 465.0, "drawer expanded beyond two tool columns: {rect:?}");+ }+ }+#[test]fn every_tool_is_listed_once_under_a_heading() {let s = sections();