Files
OneCAD-Draft/src/ui/statusbar_menu.rs
T
Hakan SevenandClaude Opus 4.8 d829f80a04 feat(statusbar): customizable pills with coordinates and clean screen
Add a customization menu (far-right handle) that lists every status-bar
pill with a check mark; toggling a row shows or hides that pill, and the
choice persists across sessions in the config dir.

New pills:
- Coordinates: live cursor readout (re-adds the model-space world offset
  so it shows true drawing coordinates), updated on every move rather
  than only while a command is active.
- Clean Screen: hide the ribbon and side panels for a full canvas.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-04 19:14:04 +03:00

118 lines
3.2 KiB
Rust

//! Status-bar customization menu — a checkmark list of every toggle pill,
//! 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::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
use crate::app::Message;
use crate::ui::statusbar_config::{StatusBarConfig, StatusPill};
/// Full-screen overlay: transparent click-catcher + the menu panel pinned to
/// the bottom-right, just above the status bar.
pub fn statusbar_menu_overlay(config: &StatusBarConfig) -> Element<'static, Message> {
let rows: Vec<Element<'static, Message>> = StatusPill::ALL
.iter()
.map(|&pill| {
menu_row(
pill.label(),
config.is_visible(pill),
Message::ToggleStatusPill(pill),
)
})
.collect();
let panel = container(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));
let positioned = container(panel)
.align_right(Fill)
.align_bottom(Fill)
.padding(Padding {
bottom: 27.0,
right: 4.0,
top: 0.0,
left: 0.0,
})
.width(Fill)
.height(Fill);
mouse_area(positioned)
.on_press(Message::CloseStatusBarMenu)
.into()
}
fn menu_row(label: &'static str, checked: bool, msg: Message) -> Element<'static, Message> {
let check = text(if checked { "✓" } else { " " })
.size(11)
.color(if checked { CHECK_COLOR } else { Color::TRANSPARENT })
.width(Length::Fixed(14.0));
let lbl = text(label)
.size(11)
.color(if checked { LABEL_ON } else { LABEL_OFF });
let content = row![check, lbl].spacing(6).align_y(iced::Center);
button(content)
.on_press(msg)
.style(|_: &Theme, status| button::Style {
background: Some(Background::Color(match status {
button::Status::Hovered => ROW_HOVER,
_ => Color::TRANSPARENT,
})),
..Default::default()
})
.width(Fill)
.padding([4, 10])
.into()
}
// ── Colours ───────────────────────────────────────────────────────────────
const PANEL_BG: Color = Color {
r: 0.15,
g: 0.15,
b: 0.15,
a: 1.0,
};
const PANEL_BORDER: Color = Color {
r: 0.32,
g: 0.32,
b: 0.32,
a: 1.0,
};
const ROW_HOVER: Color = Color {
r: 0.22,
g: 0.22,
b: 0.22,
a: 1.0,
};
const CHECK_COLOR: Color = Color {
r: 0.35,
g: 0.75,
b: 1.00,
a: 1.0,
};
const LABEL_ON: Color = Color {
r: 0.92,
g: 0.92,
b: 0.92,
a: 1.0,
};
const LABEL_OFF: Color = Color {
r: 0.65,
g: 0.65,
b: 0.65,
a: 1.0,
};