forked from 1b-agent/opencadstudio-upstream
refactor(statusbar): unify popup menus
This commit is contained in:
1 parent
d5be78a187
commit
b9de8940bc
14 files changed
+478
-557
No files matched your search
+10
-46
@@ -1,12 +1,10 @@
|
||||
//! Polar-tracking angle picker — sets the polar increment used by POLAR
|
||||
//! tracking. Rendered as a floating overlay above the status bar, same pattern
|
||||
//! as the units / scale pickers. Offers the common AutoCAD-style increments
|
||||
//! plus a free-text field for any custom angle (#264).
|
||||
//! Polar-tracking angle status menu.
|
||||
|
||||
use iced::widget::{button, column, container, mouse_area, row, text, text_input};
|
||||
use iced::{Background, Border, Color, Element, Fill, Length, Rectangle, Theme};
|
||||
use iced::widget::{button, container, row, text, text_input};
|
||||
use iced::{Background, Color, Element, Fill, Length, Theme};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
|
||||
/// Angle increments offered in the picker, in degrees. Matches the common
|
||||
/// drafting set and adds the fine 1° step requested in #264.
|
||||
@@ -21,20 +19,15 @@ pub fn angle_label(deg: f32) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Full-screen overlay: transparent click-catcher + angle list pinned
|
||||
/// bottom-right, above the status bar. `custom` is the live text of the
|
||||
/// free-entry field.
|
||||
pub fn polar_popup_overlay<'a>(
|
||||
pub fn menu_entries<'a>(
|
||||
current: f32,
|
||||
custom: &'a str,
|
||||
pill: Option<Rectangle>,
|
||||
win: (f32, f32),
|
||||
) -> Element<'a, Message> {
|
||||
let mut rows: Vec<Element<'a, Message>> = PRESETS
|
||||
) -> Vec<Entry<'a>> {
|
||||
let mut entries: Vec<Entry<'a>> = PRESETS
|
||||
.iter()
|
||||
.map(|°| {
|
||||
let active = (current - deg).abs() < 1e-3;
|
||||
angle_row(deg, active)
|
||||
Entry::close(angle_row(deg, active))
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -54,25 +47,8 @@ pub fn polar_popup_overlay<'a>(
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.padding([5, 10]);
|
||||
rows.push(custom_row.into());
|
||||
|
||||
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(120.0));
|
||||
|
||||
let positioned = super::position_statusbar_popup(panel.into(), pill, win, 120.0, true);
|
||||
|
||||
mouse_area(positioned)
|
||||
.on_press(Message::ClosePolarPopup)
|
||||
.into()
|
||||
entries.push(Entry::stay(custom_row));
|
||||
entries
|
||||
}
|
||||
|
||||
fn angle_row<'a>(deg: f32, active: bool) -> Element<'a, Message> {
|
||||
@@ -100,18 +76,6 @@ fn angle_row<'a>(deg: f32, active: bool) -> Element<'a, 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,
|
||||
|
||||
Reference in new issue
Block a user