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.
This commit is contained in:
parent
94c3e6c551
commit
f0538190d9
1 changed files with 16 additions and 7 deletions
23
src/app.rs
23
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::<ToolbarAction>(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]),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue