feat(statusbar): selection filtering by object type (FILTER pill)

Add a per-type selection filter to the scene: the FILTER pill opens a
checklist of the entity types in the layout, and unchecking a type
excludes it from interactive picking (click, box and lasso selection all
honour it). The pill lights up while any type is filtered out.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-04 23:39:48 +03:00
1 parent 834780ec5d
commit f7eac09b55
8 files changed
+219

No files matched your search

+1
View File
@@ -19,6 +19,7 @@ pub mod plotstyle;
pub mod properties;
pub mod ribbon;
pub mod scale_popup;
pub mod selection_filter_popup;
pub mod shortcuts;
pub mod snap_popup;
pub mod statusbar;
+131
View File
@@ -0,0 +1,131 @@
//! Selection-filter type picker — choose which entity types are selectable.
//! A checked row means that type can be picked; unchecking it excludes the
//! type from interactive selection. Opened from the FILTER status pill.
use std::collections::HashSet;
use iced::widget::{button, column, container, mouse_area, row, text};
use iced::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
use crate::app::Message;
/// Full-screen overlay: transparent click-catcher + type list pinned
/// bottom-right, above the status bar.
///
/// - `types`: entity-type names present in the current layout.
/// - `excluded`: types currently filtered out (unchecked).
pub fn selection_filter_popup_overlay(
types: Vec<String>,
excluded: &HashSet<String>,
) -> Element<'static, Message> {
let rows: Vec<Element<'static, Message>> = if types.is_empty() {
vec![empty_row()]
} else {
types
.into_iter()
.map(|name| {
let included = !excluded.contains(&name);
type_row(name, included)
})
.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(160.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::CloseSelectionFilterPopup)
.into()
}
fn type_row(name: String, included: bool) -> Element<'static, Message> {
let check = text(if included { "✓" } else { " " })
.size(11)
.color(if included { CHECK_COLOR } else { Color::TRANSPARENT })
.width(Length::Fixed(14.0));
let lbl = text(name.clone())
.size(11)
.color(if included { LABEL_ON } else { LABEL_OFF });
let content = row![check, lbl].spacing(6).align_y(iced::Center);
button(content)
.on_press(Message::ToggleSelectionFilterType(name))
.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()
}
fn empty_row() -> Element<'static, Message> {
container(text("No objects").size(11).color(LABEL_OFF))
.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.6,
g: 0.6,
b: 0.6,
a: 1.0,
};
+12
View File
@@ -65,6 +65,8 @@ impl StatusBar {
transparency_display: bool,
// Whether the Quick Properties floating panel is enabled.
quick_properties: bool,
// True when the selection filter is excluding at least one type.
selection_filter_active: bool,
// Which pills the user has chosen to show on the bar.
config: &'a StatusBarConfig,
) -> Element<'a, Message> {
@@ -201,6 +203,16 @@ impl StatusBar {
"Quick Properties\nFloating panel on selection",
));
}
if vis(StatusPill::SelFilter) {
right_status = right_status.push(tip(
toggle_pill(
"FILTER",
selection_filter_active,
Message::ToggleSelectionFilterPopup,
),
"Selection Filtering\nLimit which object types can be picked",
));
}
if vis(StatusPill::Vp) && !vp_label.is_empty() {
right_status = right_status.push(tip(
status_pill(vp_label).into(),
+4
View File
@@ -26,6 +26,7 @@ pub enum StatusPill {
Transparency,
Isolate,
QuickProps,
SelFilter,
Vp,
CleanScreen,
}
@@ -49,6 +50,7 @@ impl StatusPill {
StatusPill::Transparency,
StatusPill::Isolate,
StatusPill::QuickProps,
StatusPill::SelFilter,
StatusPill::Vp,
StatusPill::CleanScreen,
];
@@ -71,6 +73,7 @@ impl StatusPill {
StatusPill::Transparency => "transparency",
StatusPill::Isolate => "isolate",
StatusPill::QuickProps => "quickprops",
StatusPill::SelFilter => "selfilter",
StatusPill::Vp => "vp",
StatusPill::CleanScreen => "cleanscreen",
}
@@ -94,6 +97,7 @@ impl StatusPill {
StatusPill::Transparency => "Show Transparency",
StatusPill::Isolate => "Isolate Objects",
StatusPill::QuickProps => "Quick Properties",
StatusPill::SelFilter => "Selection Filtering",
StatusPill::Vp => "Viewport Count",
StatusPill::CleanScreen => "Clean Screen",
}