refactor(statusbar): unify popup menus

This commit is contained in:
Hakan Seven committed 2026-07-28 01:02:00 +03:00
1 parent d5be78a187
commit b9de8940bc
14 files changed
+478 -557

No files matched your search

+10 -46
View File
@@ -1,29 +1,24 @@
//! Scale picker dropdown — annotation scale (model space) or viewport scale (paper space).
//!
//! Rendered as a floating overlay above the status bar, same pattern as snap_popup.
//! Annotation / viewport scale status menu.
use iced::widget::{button, column, container, mouse_area, row, text};
use iced::{Background, Border, Color, Element, Fill, Length, Rectangle, Theme};
use iced::widget::{button, row, text};
use iced::{Background, Color, Element, Fill, Theme};
use crate::app::Message;
use crate::ui::statusbar::status_menu::Entry;
/// Full-screen overlay: transparent click-catcher + scale list panel pinned bottom-right.
///
/// - `is_model`: true = model space (dispatches SetAnnotationScale), false = paper space (SetViewportScale).
/// - `current_anno_scale`: current annotation_scale from Scene (used to highlight active row in model space).
/// - `viewport_scale`: current effective vp scale, view_height-first (used to highlight in paper space).
/// - `file_scales`: scale list read from the drawing (`ACAD_SCALELIST`). Only
/// scales actually stored in the file are shown; the picker never injects
/// scales of its own.
pub fn scale_popup_overlay(
pub fn menu_entries(
is_model: bool,
current_anno_scale: f32,
viewport_scale: Option<f64>,
file_scales: Vec<(String, f32, f64)>,
pill: Option<Rectangle>,
win: (f32, f32),
) -> Element<'static, Message> {
let mut rows: Vec<Element<'static, Message>> = file_scales
) -> Vec<Entry<'static>> {
let mut entries: Vec<Entry<'static>> = file_scales
.into_iter()
.map(|(label, anno_scale, vp_scale)| {
let active = if is_model {
@@ -38,33 +33,14 @@ pub fn scale_popup_overlay(
} else {
Message::SetViewportScale(vp_scale)
};
scale_row(label, active, msg)
Entry::close(scale_row(label, active, msg))
})
.collect();
// Model space gets a "Manage scales..." row that opens the scale manager.
if is_model {
rows.push(manage_row());
entries.push(Entry::close(manage_row()));
}
let width = if is_model { 150.0 } else { 120.0 };
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(width));
let positioned = super::position_statusbar_popup(panel.into(), pill, win, width, true);
mouse_area(positioned)
.on_press(Message::CloseScalePopup)
.into()
entries
}
fn scale_row(label: String, active: bool, msg: Message) -> Element<'static, Message> {
@@ -107,18 +83,6 @@ fn manage_row() -> Element<'static, Message> {
// ── 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,