diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 74358c60..fff3d20f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1571,7 +1571,9 @@ impl FigApp { use a11y::Tip as _; let t = theme::Tokens::get(ctx); egui::Area::new(egui::Id::new("mobile_panel_buttons")).order(egui::Order::Foreground).fixed_pos(at).show(ctx, |ui| { - for (side, icon, name) in [(MobilePanel::Left, icons::Icon::Layers, i18n::tr("Layers")), (MobilePanel::Right, icons::Icon::Panels, i18n::tr("Design"))] { + for (side, icon, name) in + [(MobilePanel::Left, icons::Icon::Layers, i18n::tr("Layers")), (MobilePanel::Right, icons::Icon::Panels, i18n::tr("Design"))] + { let open = self.ui.mobile_panel == Some(side); let (r, resp) = ui.allocate_exact_size(egui::vec2(40.0, 40.0), egui::Sense::click()); let resp = resp.tip(name); diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index ee154c20..384ed108 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -492,6 +492,17 @@ mod tests { use super::*; use egui::Shape; + #[test] + fn pill_never_outgrows_a_phone_canvas() { + let phone = Rect::from_min_size(pos2(0.0, 0.0), vec2(375.0, 700.0)); + let pill = pill_rect(phone, main_width()); + assert!(pill.width() <= phone.width() - 16.0 && pill.min.x >= 8.0 && pill.max.x <= phone.max.x - 8.0, "{pill:?}"); + // A desktop canvas keeps the full width, and a degenerate one doesn't go negative. + let wide = Rect::from_min_size(pos2(0.0, 0.0), vec2(1400.0, 800.0)); + assert_eq!(pill_rect(wide, main_width()).width(), main_width()); + assert_eq!(pill_rect(Rect::from_min_size(pos2(0.0, 0.0), vec2(4.0, 4.0)), main_width()).width(), 0.0); + } + /// The stroke widths `icon` paints with in a `size` box at `ppp` pixels per point. fn widths(ppp: f32, icon: Icon, size: f32) -> Vec { let ctx = egui::Context::default();