diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 8d3521c28..c674af70b 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -269,7 +269,7 @@ impl FigApp { let right_open = (self.right_panel_shown(hidden) && !narrow) || mobile == Some(MobilePanel::Right); if !hidden && (!narrow || mobile == Some(MobilePanel::Left)) { egui::Panel::left("left_rail") - .exact_size(56.0) + .exact_size(layers::RAIL_WIDTH) .resizable(false) .frame(egui::Frame::NONE.fill(t.panel).stroke(egui::Stroke::new(1.0, t.border))) .show(ui, |ui| { diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 1be4d28c7..7aab210e4 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -14,6 +14,8 @@ use crate::theme::{ACCENT, COMPONENT, Tokens, regular, semibold}; use crate::{FigApp, LeftTab}; pub const ROW: f32 = 32.0; +/// Width of the icon rail left of the side panel; the Home tab above it is as wide. +pub const RAIL_WIDTH: f32 = 56.0; /// A boolean operation's icon. pub fn op_icon(op: figcraft_doc::BoolOp) -> Icon { diff --git a/crates/ui-egui/src/tabs.rs b/crates/ui-egui/src/tabs.rs index 1a4c9f9b4..78193b011 100644 --- a/crates/ui-egui/src/tabs.rs +++ b/crates/ui-egui/src/tabs.rs @@ -105,8 +105,7 @@ pub fn tab_bar(app: &mut FigApp, ui: &mut Ui) { let rect = ui.max_rect(); let buttons_w = if app.ui.title_bar == TitleBar::Custom { window_buttons(app, ui, rect) } else { 0.0 }; let mut x = rect.min.x + if app.ui.title_bar == TitleBar::Inset { 76.0 } else { 8.0 }; - home_tab(app, ui, &t, x, rect); - x += 44.0; + x += home_tab(app, ui, &t, x, rect); ui.painter().line_segment([pos2(x, rect.min.y), pos2(x, rect.max.y)], Stroke::new(1.0, t.border)); let document_tabs: Vec = app.session.docs.iter().enumerate().filter_map(|(i, d)| app.shows(d.uid).then_some(i)).collect(); let now = ui.input(|input| input.time); @@ -318,9 +317,11 @@ fn close_tab(app: &mut FigApp, ui: &Ui, i: usize) { } } -/// The Home tab at `x`. -fn home_tab(app: &mut FigApp, ui: &mut Ui, t: &Tokens, x: f32, rect: Rect) { - let hr = Rect::from_min_size(pos2(x, rect.min.y), vec2(44.0, HEIGHT)); +/// The Home tab at `x`; returns its width. Without inset window buttons its divider continues the +/// icon rail's edge below. +fn home_tab(app: &mut FigApp, ui: &mut Ui, t: &Tokens, x: f32, rect: Rect) -> f32 { + let w = if app.ui.title_bar == TitleBar::Inset { 44.0 } else { rect.min.x + crate::layers::RAIL_WIDTH - x }; + let hr = Rect::from_min_size(pos2(x, rect.min.y), vec2(w, HEIGHT)); let hresp = ui.interact(hr, ui.scope_id().with("home"), Sense::click()).tip(tr("Home")); let home_active = (app.ui.home || !app.has_files()) && app.ui.present.is_none(); crate::a11y::tab(&hresp, tr("Home"), home_active); @@ -334,6 +335,7 @@ fn home_tab(app: &mut FigApp, ui: &mut Ui, t: &Tokens, x: f32, rect: Rect) { pause_present(app); app.ui.home = true; } + w } /// The theme toggle, left of the window buttons; returns its rect. diff --git a/crates/ui-egui/src/titlebar_tests.rs b/crates/ui-egui/src/titlebar_tests.rs index fff303efb..e329c7417 100644 --- a/crates/ui-egui/src/titlebar_tests.rs +++ b/crates/ui-egui/src/titlebar_tests.rs @@ -149,7 +149,7 @@ fn tabs_and_new_tab_keep_their_clicks() { assert!(!u.app.ui.home); // The `+` right of it opens a new file (found by clicking along the bar past the tab). let mut opened = false; - for x in (176..320).step_by(4) { + for x in (180..320).step_by(4) { u.time += 1.0; assert!(u.click(pos2(x as f32, 20.0)).is_empty(), "{x}"); if u.app.session.docs.len() > 1 {