diff --git a/src/app/mod.rs b/src/app/mod.rs index f9d3f85bf..da282cadf 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -175,6 +175,8 @@ pub(super) struct OpenCADStudio { statusbar_menu_open: bool, /// True while the drawing-units picker is open. units_popup_open: bool, + /// True while the Isolate pill's action menu is open. + isolate_popup_open: bool, /// Clean-screen mode: hide ribbon and side panels for a full canvas. clean_screen: bool, /// Which status-bar pills the user has chosen to show (persisted). @@ -754,6 +756,10 @@ pub enum Message { CloseUnitsPopup, /// Set the drawing units (INSUNITS) for the active drawing. SetDrawingUnits(i16), + /// Toggle the Isolate pill's action menu open/closed. + ToggleIsolatePopup, + /// Close the Isolate action menu. + CloseIsolatePopup, /// Toggle dynamic input overlay (F12). ToggleDynInput, /// Toggle object snap tracking (F11). @@ -1212,6 +1218,7 @@ impl OpenCADStudio { scale_popup_open: false, statusbar_menu_open: false, units_popup_open: false, + isolate_popup_open: false, statusbar_config: crate::ui::statusbar_config::StatusBarConfig::load(), clean_screen: false, pre_cmd_tangent: None, diff --git a/src/app/update.rs b/src/app/update.rs index aa8bbfd84..ec040d416 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -1353,6 +1353,8 @@ impl OpenCADStudio { // Close viewport context menu if open. let i = self.active_tab; self.tabs[i].scene.selection.borrow_mut().context_menu = None; + // Any command also dismisses the Isolate action menu. + self.isolate_popup_open = false; self.dispatch_command(&cmd) } @@ -3595,6 +3597,14 @@ impl OpenCADStudio { self.tabs[i].dirty = true; Task::none() } + Message::ToggleIsolatePopup => { + self.isolate_popup_open ^= true; + Task::none() + } + Message::CloseIsolatePopup => { + self.isolate_popup_open = false; + Task::none() + } Message::ToggleSnap(t) => { self.snapper.toggle(t); Task::none() diff --git a/src/app/view.rs b/src/app/view.rs index 017afb7c4..f5d7c372c 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -1016,6 +1016,7 @@ impl OpenCADStudio { if let Some(p) = ctx_pos { let has_cmd = tab.active_cmd.is_some(); let has_selection = !tab.scene.selected.is_empty(); + let isolation_active = tab.scene.is_isolation_active(); let last_cmds: Vec = self .command_line .cmd_recall @@ -1028,6 +1029,7 @@ impl OpenCADStudio { p, has_cmd, has_selection, + isolation_active, last_cmds, draworder_open, )); @@ -1210,6 +1212,15 @@ impl OpenCADStudio { iced::widget::Space::new().width(0).height(0).into() }; + let isolate_layer: Element<'_, Message> = if self.isolate_popup_open { + crate::ui::isolate_popup::isolate_popup_overlay( + !tab.scene.selected.is_empty(), + tab.scene.is_isolation_active(), + ) + } else { + iced::widget::Space::new().width(0).height(0).into() + }; + let dropdown_layer: Element<'_, Message> = self .ribbon .dropdown_overlay( @@ -1247,6 +1258,7 @@ impl OpenCADStudio { scale_layer, statusbar_menu_layer, units_layer, + isolate_layer, dropdown_layer, layout_ctx_layer, qselect_layer, @@ -2201,6 +2213,7 @@ fn viewport_context_menu_overlay( pos: iced::Point, has_cmd: bool, has_selection: bool, + isolation_active: bool, last_cmds: Vec, draworder_open: bool, ) -> Element<'static, Message> { @@ -2341,8 +2354,23 @@ fn viewport_context_menu_overlay( )); } items.push(sep()); + items.push(item( + "Isolate Objects".to_string(), + Message::Command("ISOLATEOBJECTS".to_string()), + )); + items.push(item( + "Hide Objects".to_string(), + Message::Command("HIDEOBJECTS".to_string()), + )); + items.push(sep()); items.push(item("Select Similar".to_string(), Message::SelectSimilar)); } + if isolation_active { + items.push(item( + "End Object Isolation".to_string(), + Message::Command("UNISOLATEOBJECTS".to_string()), + )); + } items.push(item( "Select All".to_string(), Message::Command("SELECTALL".to_string()), diff --git a/src/ui/isolate_popup.rs b/src/ui/isolate_popup.rs new file mode 100644 index 000000000..3f815c0fe --- /dev/null +++ b/src/ui/isolate_popup.rs @@ -0,0 +1,117 @@ +//! Isolate action menu — Isolate / Hide / End Isolation. Opened from the +//! ISO status pill, rendered as a floating overlay above the status bar +//! (same pattern as the scale picker). The same actions are also offered +//! in the viewport right-click menu. + +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 + action list pinned +/// bottom-right, above the status bar. +/// +/// - `has_selection`: enables Isolate / Hide (they act on the selection). +/// - `isolation_active`: enables End Isolation (something is hidden). +pub fn isolate_popup_overlay(has_selection: bool, isolation_active: bool) -> Element<'static, Message> { + let rows = column![ + action_row( + "Isolate Objects", + has_selection, + Message::Command("ISOLATEOBJECTS".to_string()), + ), + action_row( + "Hide Objects", + has_selection, + Message::Command("HIDEOBJECTS".to_string()), + ), + action_row( + "End Isolation", + isolation_active, + Message::Command("UNISOLATEOBJECTS".to_string()), + ), + ]; + + let panel = container(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::CloseIsolatePopup) + .into() +} + +fn action_row(label: &'static str, enabled: bool, msg: Message) -> Element<'static, Message> { + let lbl = text(label) + .size(11) + .color(if enabled { LABEL_ON } else { LABEL_OFF }); + let content = row![lbl].align_y(iced::Center); + + let mut btn = button(content) + .style(move |_: &Theme, status| button::Style { + background: Some(Background::Color(match (enabled, status) { + (true, button::Status::Hovered) => ROW_HOVER, + _ => Color::TRANSPARENT, + })), + ..Default::default() + }) + .width(Fill) + .padding([4, 12]); + if enabled { + btn = btn.on_press(msg); + } + btn.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 LABEL_ON: Color = Color { + r: 0.92, + g: 0.92, + b: 0.92, + a: 1.0, +}; +const LABEL_OFF: Color = Color { + r: 0.5, + g: 0.5, + b: 0.5, + a: 1.0, +}; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e62743bc3..1d3aeadcc 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -4,6 +4,7 @@ pub const ROW_H: f32 = 26.0; pub mod about; pub mod app_menu; +pub mod isolate_popup; pub mod update_notice; pub mod command_line; pub mod dimstyle; diff --git a/src/ui/statusbar.rs b/src/ui/statusbar.rs index ad45d1946..6051f52ba 100644 --- a/src/ui/statusbar.rs +++ b/src/ui/statusbar.rs @@ -177,12 +177,8 @@ impl StatusBar { } if vis(StatusPill::Isolate) { right_status = right_status.push(tip( - toggle_pill( - "ISO", - isolation_active, - Message::Command("UNISOLATEOBJECTS".into()), - ), - "Isolate Objects\nISOLATEOBJECTS / HIDEOBJECTS to hide; click to restore", + toggle_pill("ISO", isolation_active, Message::ToggleIsolatePopup), + "Isolate Objects\nClick for Isolate / Hide / End", )); } if vis(StatusPill::Vp) && !vp_label.is_empty() {