mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-30 05:16:56 -06:00
M6: mobile: test that the toolbar pill fits a phone canvas; rustfmt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ab375119ad
commit
ea03f90aaf
@@ -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);
|
||||
|
||||
@@ -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<f32> {
|
||||
let ctx = egui::Context::default();
|
||||
|
||||
Reference in New Issue
Block a user