forked from 1b-agent/opencadstudio-upstream
feat(statusbar): selection cycling shows a pick list, adds to selection
Replace the repeat-click cycling with a list box: when a click lands on two or more overlapping objects (cycling on), a small list of the candidates opens at the cursor. Picking a row adds that object to the current selection (accumulate); clicking outside dismisses it. A single object under the cursor falls through to the normal click. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
ac042c5dbf
commit
bcbda65746
5 files changed
+137
-28
No files matched your search
@@ -0,0 +1,87 @@
|
||||
//! Selection-cycling list box — shown at the cursor when a click lands on
|
||||
//! two or more overlapping objects. Each row names a candidate; clicking it
|
||||
//! adds that object to the current selection. Clicking outside dismisses it.
|
||||
|
||||
use iced::widget::{button, column, container, mouse_area, opaque, row, text, Space};
|
||||
use iced::{Background, Border, Color, Element, Fill, Length, Theme};
|
||||
|
||||
use crate::app::Message;
|
||||
|
||||
/// Full-canvas overlay: the list box anchored at `anchor` (canvas
|
||||
/// coordinates) plus a transparent click-catcher that cancels.
|
||||
pub fn cycle_popup_overlay(
|
||||
anchor: iced::Point,
|
||||
items: Vec<(acadrust::Handle, String)>,
|
||||
) -> Element<'static, Message> {
|
||||
let rows: Vec<Element<'static, Message>> = items
|
||||
.into_iter()
|
||||
.map(|(handle, label)| item_row(label, Message::CycleSelect(handle)))
|
||||
.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(150.0));
|
||||
|
||||
let positioned = column![
|
||||
Space::new().height(Length::Fixed(anchor.y.max(0.0))),
|
||||
row![
|
||||
Space::new().width(Length::Fixed(anchor.x.max(0.0))),
|
||||
opaque(panel),
|
||||
],
|
||||
]
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
mouse_area(positioned).on_press(Message::CycleCancel).into()
|
||||
}
|
||||
|
||||
fn item_row(label: String, msg: Message) -> Element<'static, Message> {
|
||||
let content = text(label).size(11).color(LABEL).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.45,
|
||||
b: 0.62,
|
||||
a: 1.0,
|
||||
};
|
||||
const LABEL: Color = Color {
|
||||
r: 0.92,
|
||||
g: 0.92,
|
||||
b: 0.92,
|
||||
a: 1.0,
|
||||
};
|
||||
@@ -7,6 +7,7 @@ pub mod app_menu;
|
||||
pub mod isolate_popup;
|
||||
pub mod update_notice;
|
||||
pub mod command_line;
|
||||
pub mod cycle_popup;
|
||||
pub mod dimstyle;
|
||||
pub mod layers;
|
||||
pub mod layout_manager;
|
||||
|
||||
Reference in new issue
Block a user