feat(statusbar): scrollable layout tabs + layout-list dropdown (#199)

Keep the right-side status-bar tools from being pushed off the bar when a
drawing has many layouts: the layout tabs now live in a horizontal scrollable
that only takes the space left between the menu and the tools, with ‹ › arrows
(and the mouse wheel) to scroll them.

Repurpose the leftmost hamburger — which previously fired a no-op MENU command
— to open a dropdown listing Model and every layout (scrollable, current
highlighted); picking one switches to it, an outside click dismisses it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-27 14:24:47 +03:00
1 parent 4116b85af0
commit 3def2f2034
5 files changed
+173 -9

No files matched your search

+64 -1
View File
@@ -2,7 +2,7 @@
//! opened from the bar's far-right handle. Rendered as a floating overlay
//! above the status bar, same pattern as the scale picker.
use iced::widget::{button, column, container, mouse_area, row, text};
use iced::widget::{button, column, container, mouse_area, row, scrollable, text};
use iced::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
use crate::app::Message;
@@ -51,6 +51,69 @@ pub fn statusbar_menu_overlay(config: &StatusBarConfig) -> Element<'static, Mess
.into()
}
/// Dropdown listing Model + every paper layout, opened from the leftmost
/// hamburger. Pinned bottom-left just above the status bar; a click selects a
/// layout (and closes), an outside click just closes.
pub fn layout_list_overlay<'a>(layouts: &[String], current: &str) -> Element<'a, Message> {
let rows: Vec<Element<'a, Message>> = layouts
.iter()
.map(|name| layout_row(name.clone(), name == current))
.collect();
let panel = container(scrollable(column(rows)))
.style(|_: &Theme| container::Style {
background: Some(Background::Color(PANEL_BG)),
border: Border {
color: PANEL_BORDER,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
})
.width(Length::Fixed(200.0))
.max_height(360.0);
let positioned = container(panel)
.align_left(Fill)
.align_bottom(Fill)
.padding(Padding {
bottom: 27.0,
left: 4.0,
top: 0.0,
right: 0.0,
})
.width(Fill)
.height(Fill);
mouse_area(positioned)
.on_press(Message::CloseLayoutList)
.into()
}
fn layout_row<'a>(name: String, is_current: bool) -> Element<'a, Message> {
let lbl = text(name.clone())
.size(11)
.color(if is_current { LABEL_ON } else { LABEL_OFF });
button(row![lbl].align_y(iced::Center))
.on_press(Message::LayoutSwitch(name))
.style(move |_: &Theme, status| button::Style {
background: Some(Background::Color(match (is_current, status) {
(_, button::Status::Hovered) => ROW_HOVER,
(true, _) => Color {
r: 0.18,
g: 0.26,
b: 0.36,
a: 1.0,
},
_ => Color::TRANSPARENT,
})),
..Default::default()
})
.width(Fill)
.padding([4, 12])
.into()
}
fn menu_row(label: &'static str, checked: bool, msg: Message) -> Element<'static, Message> {
let check = crate::ui::icons::check_cell(checked, CHECK_COLOR);