Window: a narrow application bar drops Arrange Documents before the search icon

The search icon takes the first icon slot beside the workspace
switcher, as before Arrange Documents was added; Arrange Documents
shows only when a second slot fits.
This commit is contained in:
dotCooCoo
2026-11-14 16:45:34 -08:00
parent 40e1a80d5c
commit 02351b0105
2 changed files with 32 additions and 8 deletions
+25 -1
View File
@@ -341,7 +341,12 @@ fn the_tile_items_check_the_layout_the_panes_show() {
/// One frame of the application bar with screen-reader nodes on → the nodes.
fn app_bar_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<egui::accesskit::Node> {
let screen = egui::Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 800.0));
app_bar_frame_in(app, ctx, events, 1400.0)
}
/// [`app_bar_frame`] on a window `width` points wide.
fn app_bar_frame_in(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>, width: f32) -> Vec<egui::accesskit::Node> {
let screen = egui::Rect::from_min_size(Pos2::ZERO, vec2(width, 800.0));
let mut out = ctx.run_ui(egui::RawInput { events, screen_rect: Some(screen), ..Default::default() }, |ui| crate::chrome::app_bar(app, ui));
out.textures_delta.clear();
out.platform_output.accesskit_update.map(|u| u.nodes.into_iter().map(|(_, n)| n).collect()).unwrap_or_default()
@@ -395,6 +400,25 @@ fn the_arrange_documents_button_tiles_and_consolidates() {
assert!(!app.ui.tiled);
}
/// As the application bar narrows, Arrange Documents goes before the search icon.
#[test]
fn a_narrow_application_bar_keeps_search_before_arrange_documents() {
crate::i18n::set_current(crate::i18n::Lang::EN);
let mut app = app_with(3);
let ctx = egui::Context::default();
ctx.enable_accesskit();
crate::theme::install_fonts(&ctx);
let mut search_alone = false;
for width in (200..=1400).rev().step_by(4) {
app_bar_frame_in(&mut app, &ctx, vec![], width as f32);
let nodes = app_bar_frame_in(&mut app, &ctx, vec![], width as f32);
let (arrange, search) = (app_bar_node(&nodes, "Arrange Documents").is_some(), app_bar_node(&nodes, "Search commands and tools").is_some());
assert!(search || !arrange, "{width} pt: Arrange Documents shows without the search icon");
search_alone |= search && !arrange;
}
assert!(search_alone, "some width shows the search icon without Arrange Documents");
}
#[test]
fn tile_shows_a_pane_for_each_document_fitted_to_it() {
let mut app = app_with(3);
+7 -7
View File
@@ -84,8 +84,8 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
let menus_end = if app.services.native_menu.is_some() { ui.cursor().min.x } else { menus::menu_bar(app, ui) };
// The right-side group fills the space after the menus from the right; when it runs
// short, Discord goes first (it is also under Help), then Explore tutorials (also
// Window › Learn), then the search icon (the palette stays under its shortcut), then
// Arrange Documents (also Window › Arrange), then the workspace switcher narrows.
// Window › Learn), then Arrange Documents (also Window › Arrange), then the search icon
// (the palette stays under its shortcut), then the workspace switcher narrows.
let full = ui.max_rect();
let right_edge = if captions_right > 0.0 { full.right() - captions_right - 10.0 } else { full.right() };
let right = egui::Rect::from_min_max(egui::pos2(menus_end + 8.0, full.top()), egui::pos2(right_edge, full.bottom()));
@@ -105,15 +105,15 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
let ws = ui.painter().layout_no_wrap(ws_name, egui::FontId::proportional(12.0), t.text);
let ws_w = (ws.size().x + 36.0).clamp(112.0, 190.0);
let gap = ui.spacing().item_spacing.x;
// Arrange Documents, beside the switcher, then the search icon, as in PhotoCraft: each
// shown while a minimal switcher fits beside it.
// The search icon, as in PhotoCraft, then Arrange Documents between it and the switcher:
// each shown while a minimal switcher fits beside it.
let icon = 28.0;
let arrange = switcher && room >= 64.0 + 8.0 + gap + icon;
let search = arrange && room >= 64.0 + 8.0 + 2.0 * (gap + icon);
let search = switcher && room >= 64.0 + 8.0 + gap + icon;
let arrange = search && room >= 64.0 + 8.0 + 2.0 * (gap + icon);
let icons = f32::from(u8::from(arrange) + u8::from(search));
let ws_w = ws_w.min(room - 8.0 - icons * (gap + icon)).max(64.0);
// Explore tutorials, beside the search icon, opens the Learn panel.
let learn = search && room >= ws_w + 8.0 + 3.0 * (gap + icon);
let learn = arrange && room >= ws_w + 8.0 + 3.0 * (gap + icon);
let discord = learn && room >= ws_w + 8.0 + 3.0 * (gap + icon) + 10.0 + gap + crate::community::discord_width(ui, false);
let mut rui = ui.new_child(egui::UiBuilder::new().max_rect(right).layout(egui::Layout::right_to_left(egui::Align::Center)));
let ui = &mut rui;