Restore New Document orientation glyphs

This commit is contained in:
haranishi
2026-11-20 04:02:13 +09:00
parent bafb452289
commit fb1f693195
3 changed files with 40 additions and 1 deletions
@@ -97,7 +97,10 @@ pub(super) fn show(ui: &mut Ui, session: &mut Session, values: &mut DocumentOpti
let size_units = unit_entries(read, &SIZE_UNITS);
let resolution_units = unit_entries(read, &RESOLUTION_UNITS);
let orientations = [Entry::new(Orientation::Portrait, words.portrait.clone()), Entry::new(Orientation::Landscape, words.landscape.clone())];
let orientations = [
Entry::new(Orientation::Portrait, words.portrait.clone()).icon(IconId::new("orientation_portrait")),
Entry::new(Orientation::Landscape, words.landscape.clone()).icon(IconId::new("orientation_landscape")),
];
let modes = ColorMode::ALL.map(|mode| Entry::new(mode, mode_label(words, mode).clone()));
let depths: Vec<_> = values.color_mode.depths().iter().map(|&depth| Entry::new(depth, depth_label(words, depth).clone())).collect();
let working = setup.profiles.iter().find(|profiles| profiles.mode == values.color_mode);
@@ -7,6 +7,7 @@ mod export;
mod files;
mod hosted;
mod new_document;
mod new_document_orientation;
mod params;
mod password;
mod preview;
@@ -0,0 +1,35 @@
//! The orientation segments are page glyphs with accessible names and still turn the document.
use craft_ui::contract::Bind;
use craft_ui::patterns::form_dialogs::{DocumentOptions, NewDocumentDialog};
use craft_ui::testing::{Fixture, trial};
use egui::Vec2;
use std::cell::RefCell;
use std::rc::Rc;
#[trial]
fn orientation_uses_icons_and_swaps_the_document_dimensions() {
let options = Rc::new(RefCell::new(DocumentOptions::default()));
let bound = Rc::clone(&options);
let mut fixture = Fixture::new(move |ui| {
let _ = NewDocumentDialog::new(Bind::bound(&mut *bound.borrow_mut())).show(ui);
});
fixture.room(Vec2::new(1400.0, 1000.0)).idle(30);
let portrait = fixture.by_label("Portrait").expect("an accessible Portrait choice");
assert!(fixture.by_label("Landscape").is_some(), "an accessible Landscape choice");
assert!(
fixture.texts().iter().all(|text| text.text != "Portrait" && text.text != "Landscape"),
"the orientation controls show page icons without painting their accessible names"
);
let original = options.borrow().size;
assert!(original.width > original.height);
fixture.click_at(portrait.center()).idle(10);
let rotated = options.borrow().size;
assert_eq!((rotated.width, rotated.height), (original.height, original.width));
let landscape = fixture.by_label("Landscape").expect("the Landscape choice after turning the page");
fixture.click_at(landscape.center()).idle(10);
assert_eq!(options.borrow().size, original);
}