From f0538190d98744d9fbac6bbcb40cecf83319ce88 Mon Sep 17 00:00:00 2001 From: leyoda Date: Fri, 24 Apr 2026 11:12:26 +0200 Subject: [PATCH] yoda: toolbar icon-only + clean visual (Control style, 32px squares) User feedback: segmented visual was noisy; only want icons, no labels. Changes: - rebuild_toolbar_model no longer sets .text() on entities, so the segmented_button widget draws icon-only squares. - toolbar renders with style(SegmentedButton::Control), button_height + min/max_button_width pinned at 32 px (square icon buttons), button_spacing = space_xs for clear separation (was space_xxs which looked conjoined), Alignment::Center. - container width = Length::Shrink so the toolbar only takes the space it needs instead of stretching across the window. --- src/app.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/app.rs b/src/app.rs index ef2c8e2..8adb742 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1827,14 +1827,17 @@ impl App { /// Called on init and on every config update. Each entity carries the /// associated `ToolbarAction` as data so click/reorder handlers can /// round-trip Entity → ToolbarAction without maintaining a side map. + /// + /// We insert ONLY the icon (no `.text()`) so the toolbar renders as a + /// clean icon row — user-visible labels stay in Settings/tooltips on + /// other surfaces. fn rebuild_toolbar_model(&mut self) { self.toolbar_model.clear(); for action in self.config.toolbar.iter().copied() { - let (icon_name, label, _msg) = toolbar_action_ui(action); + let (icon_name, _label, _msg) = toolbar_action_ui(action); self.toolbar_model .insert() .icon(widget::icon::from_name(icon_name).size(16).icon()) - .text(label) .data::(action); } } @@ -6833,7 +6836,7 @@ impl Application for App { /// Creates a view after each update. fn view(&self) -> Element<'_, Self::Message> { let cosmic_theme::Spacing { - space_xxs, space_s, .. + space_xxs, space_xs, space_s, .. } = theme::active().cosmic().spacing; let mut tab_column = widget::column::with_capacity(4); @@ -6885,18 +6888,24 @@ impl Application for App { // ToolbarAction's message). Drag past threshold = reorder // (ToolbarTabReorder → model.reorder + sync to config). if !self.config.toolbar.is_empty() { + // Use Control style (no TabBar underline, no bottom border) + // and let each button shrink to its icon. Spacing = space_xs + // keeps the buttons visually separated so it looks like an + // icon toolbar rather than a conjoined segmented control. let toolbar = widget::segmented_button::horizontal(&self.toolbar_model) + .style(theme::SegmentedButton::Control) .button_height(32) - .button_spacing(space_xxs) - .minimum_button_width(36) - .maximum_button_width(36) + .button_spacing(space_xs) + .button_alignment(Alignment::Center) + .minimum_button_width(32) + .maximum_button_width(32) .enable_tab_drag(String::from("x-cosmic-files/toolbar-dnd")) .on_reorder(Message::ToolbarTabReorder) .tab_drag_threshold(8.) .on_activate(Message::ToolbarTabActivate); tab_column = tab_column.push( widget::container(toolbar) - .width(Length::Fill) + .width(Length::Shrink) .padding([space_xxs, space_s]), ); }