diff --git a/src/app/mod.rs b/src/app/mod.rs index ff481c411..e2f103d81 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1854,6 +1854,8 @@ pub enum ModalKind { /// means and what usually fixes it. Queued once per verdict; the status /// bar's ⚠ pill reopens it. GpuWarning, + /// Reference Manager help window (toolbar Help button). + XrefHelp, } /// A property group controlled by a layer state's restore mask. @@ -2473,6 +2475,8 @@ pub enum Message { XrefManagerRefreshMenu, /// Toggle the Change Path dropdown menu. XrefManagerPathMenu, + /// Open the Reference Manager help window. + XrefHelpOpen, /// Close all palette dropdown menus (overlay dismissal). XrefManagerDismissMenus, /// Open the file picker for Select New Path (anchor entry). diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index 4cbb1056d..ee962d958 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -2395,6 +2395,10 @@ impl OpenCADStudio { self.xref_manager.refresh_open = false; Task::none() } + Message::XrefHelpOpen => { + self.active_modal = Some(super::ModalKind::XrefHelp); + Task::none() + } Message::XrefManagerDismissMenus => { self.xref_manager.attach_open = false; self.xref_manager.refresh_open = false; diff --git a/src/app/view/modal.rs b/src/app/view/modal.rs index 04fe270ec..d3bc809ab 100644 --- a/src/app/view/modal.rs +++ b/src/app/view/modal.rs @@ -56,6 +56,7 @@ impl OpenCADStudio { Some(K::MissingFonts) => crate::t!("Missing fonts").into_owned(), Some(K::RecoveryPrompt) => crate::tr!("modal", "recovery-prompt"), Some(K::GpuWarning) => crate::tr!("gpu", "title"), + Some(K::XrefHelp) => crate::t!("Reference Manager Help").into_owned(), None => String::new(), } } @@ -85,6 +86,9 @@ impl OpenCADStudio { super::super::ModalKind::About => { automatic_flow(ex, crate::ui::window::about::view_window) } + super::super::ModalKind::XrefHelp => { + automatic_flow(ex, crate::ui::window::xref_help::view_window) + } super::super::ModalKind::Shortcuts => { // Keys claimed by two rows — the cells turn red and a // persistent warning names the command already using each diff --git a/src/ui/window/mod.rs b/src/ui/window/mod.rs index 00c05410e..ac3352c5c 100644 --- a/src/ui/window/mod.rs +++ b/src/ui/window/mod.rs @@ -22,4 +22,5 @@ pub mod annotation_data; pub mod alias_editor; pub mod find_replace; pub mod named_parameters; +pub mod xref_help; pub mod xref_manager; diff --git a/src/ui/window/xref_help.rs b/src/ui/window/xref_help.rs new file mode 100644 index 000000000..39ec474e9 --- /dev/null +++ b/src/ui/window/xref_help.rs @@ -0,0 +1,102 @@ +//! Reference Manager help window: how the manager works on the web build +//! (read-only list, disabled mutations, no previews) and where to report +//! issues. Rendered as a modal like About/DSettings so the text gets a +//! proper window width — an anchored toolbar dropdown squeezed it into an +//! unreadable sliver. + +use crate::app::Message; +use iced::widget::{button, column, container, row, text, Space}; +use iced::{Background, Element, Fill, Length, Theme}; + +/// GitHub issues page linked from the help window, so web users can report +/// missing or broken behavior where it will be seen. +pub const XREF_ISSUES_URL: &str = "https://github.com/HakanSeven12/OpenCADStudio/issues"; + +fn muted_style(theme: &Theme) -> iced::widget::text::Style { + iced::widget::text::Style { + color: Some(theme.palette().background.base.text.scale_alpha(0.68)), + } +} + +pub fn view_window(sizing: crate::ui::modal::ModalSizing) -> Element<'static, Message> { + // Fixed window width: paragraphs wrap against this instead of the + // toolbar, which is what made the dropdown unreadable. + let body_w = Length::Fixed(460.0); + let para = |label: String| -> Element<'static, Message> { + text(label).size(12).width(Fill).into() + }; + + let intro = para(crate::t!("How the Reference Manager works on web").into_owned()); + let list = para( + crate::t!( + "This panel lists the drawing's references read-only: status, type, size, date and saved path, plus the Details pane. Select rows to inspect them; List and Tree switch the presentation." + ) + .into_owned(), + ); + let limits = para( + crate::t!( + "Attach, Refresh and Change Path stay disabled here: the web build has no filesystem access and no native file pickers, so references can be neither added, reloaded nor repathed — and previews stay unavailable. Nested references are read-only on every platform, and relative paths need the drawing saved first." + ) + .into_owned(), + ); + let report_hint = para( + crate::t!( + "Hit something broken or missing? Report it on the GitHub issues page so it can be fixed." + ) + .into_owned(), + ); + + let report_button = button(text(crate::t!("Report an issue")).size(12)) + .on_press(Message::OpenUrl(XREF_ISSUES_URL.to_string())) + .style(button::primary) + .padding([6, 18]); + let close_button = button(text(crate::t!("Close")).size(12)) + .on_press(Message::CloseModal) + .style(button::secondary) + .padding([6, 18]); + let action_row: Element<'static, Message> = row![ + Space::new().width(Fill), + report_button, + close_button, + ] + .spacing(8) + .align_y(iced::Center) + .into(); + + let content = column![ + text(crate::t!("Reference Manager — Web").into_owned()) + .size(14), + text(crate::t!("EXTERNALREFERENCES on the web build").into_owned()) + .size(11) + .style(muted_style), + intro, + list, + limits, + report_hint, + Space::new().height(4), + action_row, + ] + .spacing(10) + .padding(16) + .width(body_w); + + container(content) + .width(sizing.width) + .height(sizing.height) + .style(|theme: &Theme| container::Style { + background: Some(Background::Color( + theme.palette().background.base.color, + )), + ..Default::default() + }) + .into() +} + +#[cfg(test)] +mod tests { + #[test] + fn issues_url_points_at_github_issues() { + assert!(super::XREF_ISSUES_URL.starts_with("https://github.com/")); + assert!(super::XREF_ISSUES_URL.contains("/issues")); + } +} diff --git a/src/ui/window/xref_manager.rs b/src/ui/window/xref_manager.rs index 50626d5a5..7ea68ed8b 100644 --- a/src/ui/window/xref_manager.rs +++ b/src/ui/window/xref_manager.rs @@ -22,6 +22,8 @@ use std::time::{SystemTime, UNIX_EPOCH}; /// read-only list renders everywhere. const IS_WASM: bool = cfg!(target_arch = "wasm32"); + + /// Font size for table cells (mirrors `layers.rs`). const FONT_SZ: f32 = ROW_H * 0.42; // ≈11 px at ROW_H=26 /// Fixed table height so the details pane below keeps stable space. @@ -784,9 +786,12 @@ impl XrefManagerPanel { ) } }; - let help = toolbar_tip( + // Help opens a modal window explaining the manager (and its web + // shortcomings): the old disabled tip could never be clicked, and + // an anchored dropdown squeezes the text into the toolbar's width. + let help = toolbar_btn( crate::t!("Help").into_owned(), - crate::t!("Reference Manager — select rows, then Detach, Unload, Reload, Bind, Overlay, or a Change Path mode.").into_owned(), + Some(Message::XrefHelpOpen), false, ); let toolbar = container(