diff --git a/locales/ar-SA/opencadstudio.ftl b/locales/ar-SA/opencadstudio.ftl index b5b52b214..41b5274fd 100644 --- a/locales/ar-SA/opencadstudio.ftl +++ b/locales/ar-SA/opencadstudio.ftl @@ -3583,6 +3583,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/bg-BG/opencadstudio.ftl b/locales/bg-BG/opencadstudio.ftl index 9e160c284..afa5f27c6 100644 --- a/locales/bg-BG/opencadstudio.ftl +++ b/locales/bg-BG/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/cs-CZ/opencadstudio.ftl b/locales/cs-CZ/opencadstudio.ftl index cb2dbd5fd..28a81eef9 100644 --- a/locales/cs-CZ/opencadstudio.ftl +++ b/locales/cs-CZ/opencadstudio.ftl @@ -3568,6 +3568,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/de-DE/opencadstudio.ftl b/locales/de-DE/opencadstudio.ftl index 0b5726b07..49aa5435e 100644 --- a/locales/de-DE/opencadstudio.ftl +++ b/locales/de-DE/opencadstudio.ftl @@ -3571,6 +3571,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/el-GR/opencadstudio.ftl b/locales/el-GR/opencadstudio.ftl index 93238ee8b..42807d01d 100644 --- a/locales/el-GR/opencadstudio.ftl +++ b/locales/el-GR/opencadstudio.ftl @@ -3571,6 +3571,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/en-US/opencadstudio.ftl b/locales/en-US/opencadstudio.ftl index a1da84051..25797df8f 100644 --- a/locales/en-US/opencadstudio.ftl +++ b/locales/en-US/opencadstudio.ftl @@ -3572,6 +3572,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/es-ES/opencadstudio.ftl b/locales/es-ES/opencadstudio.ftl index 47df32a13..88b5c13fd 100644 --- a/locales/es-ES/opencadstudio.ftl +++ b/locales/es-ES/opencadstudio.ftl @@ -3571,6 +3571,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/fi-FI/opencadstudio.ftl b/locales/fi-FI/opencadstudio.ftl index b663e3526..3cd366010 100644 --- a/locales/fi-FI/opencadstudio.ftl +++ b/locales/fi-FI/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/fr-FR/opencadstudio.ftl b/locales/fr-FR/opencadstudio.ftl index 0fceb5ba8..7e0219344 100644 --- a/locales/fr-FR/opencadstudio.ftl +++ b/locales/fr-FR/opencadstudio.ftl @@ -3571,6 +3571,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/hi-IN/opencadstudio.ftl b/locales/hi-IN/opencadstudio.ftl index 8db40abbe..cd2b00dbb 100644 --- a/locales/hi-IN/opencadstudio.ftl +++ b/locales/hi-IN/opencadstudio.ftl @@ -3559,6 +3559,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/hu-HU/opencadstudio.ftl b/locales/hu-HU/opencadstudio.ftl index 7bb2fd143..f39afb99b 100644 --- a/locales/hu-HU/opencadstudio.ftl +++ b/locales/hu-HU/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/it-IT/opencadstudio.ftl b/locales/it-IT/opencadstudio.ftl index 41a09aa50..332b99767 100644 --- a/locales/it-IT/opencadstudio.ftl +++ b/locales/it-IT/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/ja-JP/opencadstudio.ftl b/locales/ja-JP/opencadstudio.ftl index 87b0c88e9..6ef6bebc1 100644 --- a/locales/ja-JP/opencadstudio.ftl +++ b/locales/ja-JP/opencadstudio.ftl @@ -3561,6 +3561,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/ko-KR/opencadstudio.ftl b/locales/ko-KR/opencadstudio.ftl index f60cc8de8..fa5d64017 100644 --- a/locales/ko-KR/opencadstudio.ftl +++ b/locales/ko-KR/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/nl-NL/opencadstudio.ftl b/locales/nl-NL/opencadstudio.ftl index a9e461925..5ec3e222e 100644 --- a/locales/nl-NL/opencadstudio.ftl +++ b/locales/nl-NL/opencadstudio.ftl @@ -3569,6 +3569,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/pl-PL/opencadstudio.ftl b/locales/pl-PL/opencadstudio.ftl index 05151e318..b518cae38 100644 --- a/locales/pl-PL/opencadstudio.ftl +++ b/locales/pl-PL/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/pt-BR/opencadstudio.ftl b/locales/pt-BR/opencadstudio.ftl index a05c43150..4c3a95027 100644 --- a/locales/pt-BR/opencadstudio.ftl +++ b/locales/pt-BR/opencadstudio.ftl @@ -3571,6 +3571,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/ru-RU/opencadstudio.ftl b/locales/ru-RU/opencadstudio.ftl index fcc5dc966..a5fb82176 100644 --- a/locales/ru-RU/opencadstudio.ftl +++ b/locales/ru-RU/opencadstudio.ftl @@ -3572,6 +3572,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/tr-TR/opencadstudio.ftl b/locales/tr-TR/opencadstudio.ftl index 08c0b33ab..86a7aee2f 100644 --- a/locales/tr-TR/opencadstudio.ftl +++ b/locales/tr-TR/opencadstudio.ftl @@ -3545,6 +3545,12 @@ insert = Tek renkli göster .select-pdf-file = PDF Dosyası Seç + .refui-requires-int-90 = -90 ile 90 arasında bir tam sayı gerekir. + .refui-xref-fading = Xref soldurma + .refui-edit-reference = Referansı Düzenle + .refui-snap-to-underlays-off = Altlıklara Yakala Kapalı + .refui-snap-to-underlays-on = Altlıklara Yakala Açık + .refui-snap-to-underlays = Altlıklara Yakala .xref-attach-dialog-title = Harici Referans Ekle .xref-attach-browse = Gözat... .xref-attach-reference-type = Referans Türü diff --git a/locales/zh-CN/opencadstudio.ftl b/locales/zh-CN/opencadstudio.ftl index 0af91b489..1f508ef20 100644 --- a/locales/zh-CN/opencadstudio.ftl +++ b/locales/zh-CN/opencadstudio.ftl @@ -3558,6 +3558,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/locales/zh-TW/opencadstudio.ftl b/locales/zh-TW/opencadstudio.ftl index ecb6dca35..ff52f4561 100644 --- a/locales/zh-TW/opencadstudio.ftl +++ b/locales/zh-TW/opencadstudio.ftl @@ -3570,6 +3570,12 @@ insert = Display in Monochrome .select-pdf-file = Select PDF File + .refui-requires-int-90 = Requires an integer between -90 and 90. + .refui-xref-fading = Xref fading + .refui-edit-reference = Edit Reference + .refui-snap-to-underlays-off = Snap to Underlays OFF + .refui-snap-to-underlays-on = Snap to Underlays ON + .refui-snap-to-underlays = Snap to Underlays .xref-attach-dialog-title = Attach External Reference .xref-attach-browse = Browse... .xref-attach-reference-type = Reference Type diff --git a/src/app/commands/mod.rs b/src/app/commands/mod.rs index 58f2164da..7768d92c5 100644 --- a/src/app/commands/mod.rs +++ b/src/app/commands/mod.rs @@ -622,12 +622,15 @@ inventory::submit!(crate::command::CommandRegistration { "PDFIMPORTMODE", "PDFIMPORTFILTER", "PDFIMPORTLAYERS", + "XDWGFADECTL", "POINTCLOUDCLIPFRAME", "XCLIPFRAME", "WIPEOUTFRAME", "FRAMES0", "FRAMES1", "FRAMES2", + "UOSNAP0", + "UOSNAP1", "HALOGAP", "TRACEWID", "SKETCHINC", diff --git a/src/app/commands/styleprops.rs b/src/app/commands/styleprops.rs index c19c8dee6..29053a930 100644 --- a/src/app/commands/styleprops.rs +++ b/src/app/commands/styleprops.rs @@ -10,6 +10,8 @@ impl OpenCADStudio { "FRAMES0" => return self.dispatch_styleprops("SETVAR FRAME 0", i), "FRAMES1" => return self.dispatch_styleprops("SETVAR FRAME 1", i), "FRAMES2" => return self.dispatch_styleprops("SETVAR FRAME 2", i), + "UOSNAP0" => return self.dispatch_styleprops("SETVAR UOSNAP 0", i), + "UOSNAP1" => return self.dispatch_styleprops("SETVAR UOSNAP 1", i), // COLOR — the colour applied to new // objects (CECOLOR). Bare COLOR reports the current value. "COLOR" | "COLOUR" | "CECOLOR" | "DDCOLOR" => { @@ -1020,6 +1022,7 @@ impl OpenCADStudio { | "PDFIMPORTMODE" | "PDFIMPORTFILTER" | "PDFIMPORTLAYERS" + | "XDWGFADECTL" | "POINTCLOUDCLIPFRAME" | "XCLIPFRAME" | "WIPEOUTFRAME" @@ -1086,6 +1089,19 @@ impl OpenCADStudio { crate::t!("SETVAR: CETRANSPARENCY LTSCALE CELTSCALE PDMODE PDSIZE TEXTSIZE ORTHOMODE FILLMODE MIRRTEXT FRAME IMAGEFRAME PDFFRAME WIPEOUTFRAME XCLIPFRAME POINTCLOUDCLIPFRAME ZOOMWHEEL ZOOMFACTOR SHORTCUTMENU SHORTCUTMENUDURATION CURSORSIZE PICKBOX CURSORTYPE SNAPANG TEXTFILL CLIPROMPTLINES COMMANDLINEFADETIME ATTREQ ATTDIA DIMASSOC DIMCONTINUEMODE CONSTRAINTSOLVEMODE CONSTRAINTINFER CONSTRAINTBARDISPLAY CONSTRAINTBARMODE CONSTRAINTNAMEFORMAT DYNCONSTRAINTDISPLAY ANGBASE ANGDIR SKETCHINC SKPOLY SKTOLERANCE DONUTID DONUTOD CENTEREXE CENTERLAYER CENTERLTYPE CENTERLTSCALE CENTERLTYPEFILE CENTERCROSSSIZE CENTERCROSSGAP CENTERMARKEXE COLORTHEME SELECTIONAREA SELECTIONAREAOPACITY SELECTIONEFFECT SELECTIONEFFECTCOLOR WINDOWSAREACOLOR CROSSINGAREACOLOR SELECTIONPREVIEW GRIPSIZE GRIPCOLOR GRIPHOT GRIPHOVER GRIPOBJLIMIT | CLAYER CELTYPE TEXTSTYLE (read-only)").as_ref(), ); } else { + if name == "XDWGFADECTL" { + let current = crate::scene::cache::block_cache::xref_fade_ctl(); + if let Some(value) = &value { + match value.parse::().ok().filter(|v| (-90..=90).contains(v)) { + Some(fade) => self.set_xref_fade(fade), + None => self.command_line.push_error("Requires an integer between -90 and 90."), + } + } else { + self.command_line.push_output(&format!("Enter new value for XDWGFADECTL <{current}>:")); + self.pending_setvar = Some(name.clone()); + } + return Some(self.finish_dispatch(cmd)); + } if name == "CETRANSPARENCY" { let current = self.tabs[i].scene.document.current_entity_transparency(); if let Some(value) = &value { @@ -3579,3 +3595,18 @@ mod scale_validation_tests { } } } + +impl OpenCADStudio { + /// XDWGFADECTL: store it, show it on the ribbon and redraw every tab's + /// referenced drawings. + pub(in crate::app) fn set_xref_fade(&mut self, fade: i32) { + crate::scene::cache::block_cache::set_xref_fade_ctl(fade); + self.ribbon.xref_fade = crate::scene::cache::block_cache::xref_fade_ctl(); + for tab in &mut self.tabs { + if !tab.is_start { + tab.scene.recolor_meshes(); + tab.scene.bump_geometry(); + } + } + } +} diff --git a/src/app/mod.rs b/src/app/mod.rs index 56ad8e6e5..f6c15b672 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -3833,6 +3833,11 @@ pub enum Message { XAttachPickResult(Result), /// ATTACH: pick a drawing, image or PDF to reference. AttachPick, + /// The Reference slide-out's xref fading: amount dragged, drag done, + /// switch. + XrefFadeSlide(u8), + XrefFadeCommit, + XrefFadeToggle, /// Result of the ATTACH file picker. AttachPickResult(Result), /// An edit in the Attach External Reference dialog. diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index a2e027a17..d5da6dcb0 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -5742,6 +5742,20 @@ impl OpenCADStudio { self.ribbon.close_dropdown(); Task::none() } + Message::XrefFadeSlide(amount) => { + let sign = if self.ribbon.xref_fade < 0 { -1 } else { 1 }; + self.ribbon.xref_fade = sign * amount as i32; + Task::none() + } + Message::XrefFadeCommit => { + self.set_xref_fade(self.ribbon.xref_fade); + Task::none() + } + Message::XrefFadeToggle => { + let fade = crate::scene::cache::block_cache::xref_fade_ctl(); + self.set_xref_fade(if fade == 0 { 50 } else { -fade }); + Task::none() + } Message::DropdownSelectItem { dropdown_id, cmd } => { if self.tabs[self.active_tab].is_start { self.ribbon.close_dropdown(); diff --git a/src/entities/insert.rs b/src/entities/insert.rs index 5fe92b024..20e7f88f7 100644 --- a/src/entities/insert.rs +++ b/src/entities/insert.rs @@ -414,7 +414,7 @@ pub(crate) fn append_insert_attribute_wires( ); let sub_color = render::adapt_to_bg(sub_color, bg_color); let sub_color = if is_xref && !sel { - block_cache::fade_toward_bg(sub_color, bg_color) + block_cache::xref_fade(sub_color, bg_color) } else { sub_color }; diff --git a/src/locale_catalog.rs b/src/locale_catalog.rs index eafd05c23..87b1740ff 100644 --- a/src/locale_catalog.rs +++ b/src/locale_catalog.rs @@ -2946,6 +2946,12 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static "Applied" => Some(("properties", "applied")), "No PDF underlays found." => Some(("insert", "pdfui-no-pdf-underlays")), "Specify insertion point:" => Some(("insert", "pdfui-specify-insertion-point")), + "Snap to Underlays" => Some(("insert", "refui-snap-to-underlays")), + "Snap to Underlays ON" => Some(("insert", "refui-snap-to-underlays-on")), + "Snap to Underlays OFF" => Some(("insert", "refui-snap-to-underlays-off")), + "Edit Reference" => Some(("insert", "refui-edit-reference")), + "Xref fading" => Some(("insert", "refui-xref-fading")), + "Requires an integer between -90 and 90." => Some(("insert", "refui-requires-int-90")), "Underlay" => Some(("properties", "underlay")), "PDF Underlay" => Some(("properties", "pdf-underlay")), "DWF Underlay" => Some(("properties", "dwf-underlay")), diff --git a/src/modules/insert/mod.rs b/src/modules/insert/mod.rs index 1f7ee46f0..27c9d92d6 100644 --- a/src/modules/insert/mod.rs +++ b/src/modules/insert/mod.rs @@ -49,41 +49,39 @@ impl CadModule for InsertModule { title: "Reference", tools: vec![ RibbonItem::LargeTool(xattach::tool()), - RibbonItem::LargeTool(pdf_attach::tool()), RibbonItem::LargeTool(xclip::tool()), RibbonItem::LargeTool(xadjust::tool()), - RibbonItem::Tool(underlay_layers::tool()), - RibbonItem::Dropdown { + RibbonItem::LabeledTool(underlay_layers::tool()), + // An empty label shows the chosen item's. + RibbonItem::LabeledDropdown { id: "FRAMES_DROPDOWN", + label: "", icon: IconKind::Svg(include_bytes!( "../../../assets/icons/underlay_frames.svg" )), items: vec![ - ( - "FRAMES0", - "Frames Off", - IconKind::Svg(include_bytes!( - "../../../assets/icons/underlay_frames.svg" - )), - ), - ( - "FRAMES1", - "Frames On", - IconKind::Svg(include_bytes!( - "../../../assets/icons/underlay_frames.svg" - )), - ), - ( - "FRAMES2", - "Frames On, Not Plotted", - IconKind::Svg(include_bytes!( - "../../../assets/icons/underlay_frames.svg" - )), - ), + ("FRAMES0", "Frames Off", IconKind::Svg(include_bytes!( + "../../../assets/icons/underlay_frames.svg" + ))), + ("FRAMES1", "Frames On", IconKind::Svg(include_bytes!( + "../../../assets/icons/underlay_frames.svg" + ))), + ("FRAMES2", "Frames On, Not Plotted", IconKind::Svg(include_bytes!( + "../../../assets/icons/underlay_frames.svg" + ))), ], default: "FRAMES1", }, - RibbonItem::Tool(snap_underlays::tool()), + RibbonItem::LabeledDropdown { + id: "UOSNAP_DROPDOWN", + label: "Snap to Underlays", + icon: snap_underlays::ICON, + items: vec![ + ("UOSNAP1", "Snap to Underlays ON", snap_underlays::ICON), + ("UOSNAP0", "Snap to Underlays OFF", snap_underlays::ICON), + ], + default: "UOSNAP1", + }, ], }, // ── Point Cloud ─────────────────────────────────────────────────── diff --git a/src/modules/insert/pdf_attach.rs b/src/modules/insert/pdf_attach.rs index 337327d48..9593bea76 100644 --- a/src/modules/insert/pdf_attach.rs +++ b/src/modules/insert/pdf_attach.rs @@ -20,21 +20,8 @@ use acadrust::{CadDocument, EntityType}; use glam::DVec3; use crate::command::{CadCommand, CmdOption, CmdResult, InputKind, WorkingPlane}; -use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -pub const ICON: IconKind = - IconKind::Svg(include_bytes!("../../../assets/icons/underlay_layers.svg")); - -pub fn tool() -> ToolDef { - ToolDef { - id: "PDFATTACH", - label: "Attach PDF", - icon: ICON, - event: ModuleEvent::Command("PDFATTACH".to_string()), - } -} - /// Units the Unit option offers: keyword, the name the prompt shows. const UNITS: [(&str, &str); 9] = [ ("MM", "Millimeters"), diff --git a/src/modules/insert/snap_underlays.rs b/src/modules/insert/snap_underlays.rs index 7c7ae9527..db2c4df0a 100644 --- a/src/modules/insert/snap_underlays.rs +++ b/src/modules/insert/snap_underlays.rs @@ -1,11 +1,3 @@ -use crate::modules::{IconKind, ModuleEvent, ToolDef}; +use crate::modules::IconKind; pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/snap_underlays.svg")); -pub fn tool() -> ToolDef { - ToolDef { - id: "UOSNAP", - label: "Snap to\nUnderlays", - icon: ICON, - event: ModuleEvent::Command("UOSNAP".to_string()), - } -} diff --git a/src/modules/insert/xattach.rs b/src/modules/insert/xattach.rs index c9d2f7967..aa3917f41 100644 --- a/src/modules/insert/xattach.rs +++ b/src/modules/insert/xattach.rs @@ -26,10 +26,10 @@ use crate::scene::Scene; pub fn tool() -> ToolDef { ToolDef { - id: "XATTACH", - label: "Attach XREF", + id: "ATTACH", + label: "Attach", icon: IconKind::Svg(include_bytes!("../../../assets/icons/blocks/insert.svg")), - event: ModuleEvent::Command("XATTACH".to_string()), + event: ModuleEvent::Command("ATTACH".to_string()), } } diff --git a/src/scene/cache/block_cache.rs b/src/scene/cache/block_cache.rs index d327d8a92..51bc96c1b 100644 --- a/src/scene/cache/block_cache.rs +++ b/src/scene/cache/block_cache.rs @@ -1467,6 +1467,29 @@ pub(crate) fn fade_toward_bg(color: [f32; 4], bg: [f32; 4]) -> [f32; 4] { ] } +/// XDWGFADECTL: how far referenced drawings fade toward the background, in +/// percent (0–90); zero or negative shows them unfaded. +static XREF_FADE: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(50); + +pub fn xref_fade_ctl() -> i32 { + XREF_FADE.load(std::sync::atomic::Ordering::Relaxed) +} + +pub fn set_xref_fade_ctl(value: i32) { + XREF_FADE.store(value.clamp(-90, 90), std::sync::atomic::Ordering::Relaxed); +} + +/// A referenced drawing's colour faded by XDWGFADECTL. +pub(crate) fn xref_fade(color: [f32; 4], bg: [f32; 4]) -> [f32; 4] { + let t = xref_fade_ctl().clamp(0, 90) as f32 / 100.0; + [ + color[0] * (1.0 - t) + bg[0] * t, + color[1] * (1.0 - t) + bg[1] * t, + color[2] * (1.0 - t) + bg[2] * t, + color[3], + ] +} + /// Style fingerprint used to group local wires into a single GPU buffer. /// f32 fields are bit-cast to u32 to make the key Hash + Eq. #[derive(Clone, Debug, PartialEq, Eq, Hash)] @@ -2135,7 +2158,7 @@ fn resolve_wire_color(lw: &LocalWire, ctx: &ExpandCtx) -> [f32; 4] { }; } if ctx.is_xref && !ctx.selected { - fade_toward_bg(color, ctx.bg_color) + xref_fade(color, ctx.bg_color) } else { color } diff --git a/src/ui/ribbon/draw_panel.rs b/src/ui/ribbon/draw_panel.rs index 0a5fa27f3..787777917 100644 --- a/src/ui/ribbon/draw_panel.rs +++ b/src/ui/ribbon/draw_panel.rs @@ -111,6 +111,16 @@ struct Panel { tools: &'static [Tool], } +/// The Reference panel's slide-out: Edit Reference, then the xref fading +/// switch and amount (drawn by `reference_overlay`). +const REFERENCE_TOOLS: &[Tool] = &[Tool { + command: "REFEDIT", + label: "Edit Reference", + icon: include_bytes!("../../../assets/icons/edit_block.svg"), + options: &[], +}]; +pub(super) const REFERENCE_PANEL_ID: &str = "reference_extension"; + const PANELS: &[Panel] = &[ Panel { id: PANEL_ID, @@ -124,6 +134,12 @@ const PANELS: &[Panel] = &[ title: "Modify", tools: super::modify_panel::TOOLS, }, + Panel { + id: REFERENCE_PANEL_ID, + title_id: "reference_extension_title", + title: "Reference", + tools: REFERENCE_TOOLS, + }, ]; /// Command, label and icon of every tool in the expanded Draw and Modify @@ -168,7 +184,7 @@ pub(super) fn group_title<'a>(title: &'static str, open: &Option) -> Ele } else { icons::themed_arrow_down(GROUP_TITLE_ARROW_SIZE) }; - PosReport::new( + let title_button: Element<'a, Message> = PosReport::new( panel.id, button( row![ @@ -182,7 +198,35 @@ pub(super) fn group_title<'a>(title: &'static str, open: &Option) -> Ele .style(move |theme: &Theme, status| tool_btn_style(theme, expanded, status)) .padding([1, 4]), ) - .into() + .into(); + if panel.id != REFERENCE_PANEL_ID { + return title_button; + } + // The corner arrow opens the External References palette. + let launcher = tooltip( + // A right arrow turned to point into the corner. + button( + iced::widget::svg(iced::widget::svg::Handle::from_memory(icons::ARROW_LONG_RIGHT)) + .width(10) + .height(10) + .rotation(iced::Radians(std::f32::consts::FRAC_PI_4)), + ) + .on_press(Message::RibbonToolClick { + tool_id: "EXTERNALREFERENCES".to_string(), + event: crate::modules::ModuleEvent::Command("EXTERNALREFERENCES".to_string()), + }) + .style(move |theme: &Theme, status| tool_btn_style(theme, false, status)) + .padding([0, 3]), + make_tip(format!("{}\n{} EXTERNALREFERENCES", t!("External References"), t!("Command:"))), + tooltip::Position::Bottom, + ) + .delay(Duration::from_millis(400)) + .style(tip_style); + // Shrink-sized: a Fill here would make the panel claim the whole row. + row![title_button, launcher] + .spacing(6) + .align_y(iced::Center) + .into() } fn tool_button(tool: &Tool, active: bool, panel_id: &'static str) -> Element<'static, Message> { @@ -220,8 +264,70 @@ fn tool_button(tool: &Tool, active: bool, panel_id: &'static str) -> Element<'st } } +/// The Reference slide-out: Edit Reference, and xref fading on/off with its +/// amount (XDWGFADECTL; the switch keeps the amount as a negative value). +fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Element<'a, Message> { + let width: f32 = 260.0_f32.min((win.0 - 8.0).max(120.0)); + let (_, x, anchor_top) = ribbon.dd_anchor(panel.id, width, win.0); + let left = x.clamp(0.0, (win.0 - width).max(0.0)); + let top = anchor_top.min((win.1 - 80.0).max(0.0)); + let tool = &panel.tools[0]; + let edit = button( + row![ + make_icon(IconKind::Svg(tool.icon), 16.0), + text(t!(tool.label)).size(11) + ] + .spacing(6) + .align_y(iced::Center), + ) + .on_press(Message::DropdownSelectItem { + dropdown_id: panel.id, + cmd: tool.command, + }) + .style(popup_row_style) + .width(Fill) + .padding([3, 6]); + let fade = ribbon.xref_fade; + let on = fade > 0; + let switch = button(make_icon( + IconKind::Svg(include_bytes!("../../../assets/icons/underlay_frames.svg")), + 16.0, + )) + .on_press(Message::XrefFadeToggle) + .style(move |theme: &Theme, status| tool_btn_style(theme, on, status)) + .padding(3); + let amount = fade.unsigned_abs().min(90) as u8; + let fading = row![ + tooltip( + switch, + make_tip(format!("{}\n{} XDWGFADECTL", t!("Xref fading"), t!("Command:"))), + tooltip::Position::Bottom + ) + .delay(Duration::from_millis(400)) + .style(tip_style), + text(t!("Xref fading")).size(11), + iced::widget::slider(0..=90u8, amount, Message::XrefFadeSlide) + .on_release(Message::XrefFadeCommit) + .width(Fill), + text(amount.to_string()).size(11).width(22), + ] + .spacing(6) + .align_y(iced::Center); + let body = container(column![edit, fading].spacing(4).padding(6)) + .width(width) + .style(|theme: &Theme| { + let mut style = popup_panel_style(theme); + style.border.color = theme.palette().primary.base.color; + style + }); + dropdown_backdrop(position_ribbon_dropdown(body.into(), false, left, top)) +} + pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element<'a, Message> { let panel = panel_for_dropdown(id).expect("registered ribbon extension"); + if panel.id == REFERENCE_PANEL_ID { + return reference_overlay(ribbon, panel, win); + } let tools = panel.tools; let width = (7.0 * (CELL + GAP) - GAP + 12.0).min((win.0 - 8.0).max(CELL + 12.0)); let (_, x, anchor_top) = ribbon.dd_anchor(panel.id, width, win.0); diff --git a/src/ui/ribbon/mod.rs b/src/ui/ribbon/mod.rs index 4d6de1cf6..5ef85eb8a 100644 --- a/src/ui/ribbon/mod.rs +++ b/src/ui/ribbon/mod.rs @@ -109,6 +109,8 @@ pub struct Ribbon { underlay_ctx: Option, /// The contextual underlay tab is the one shown. underlay_tab_active: bool, + /// XDWGFADECTL as the Reference slide-out shows it (negative = off). + pub xref_fade: i32, } /// Per-layer display data shown in the ribbon layer dropdown. @@ -204,6 +206,7 @@ impl Ribbon { collapse_tight: Arc::new(AtomicBool::new(false)), underlay_ctx: None, underlay_tab_active: false, + xref_fade: 50, } } diff --git a/src/ui/ribbon/widgets.rs b/src/ui/ribbon/widgets.rs index 17d317706..d920d61b9 100644 --- a/src/ui/ribbon/widgets.rs +++ b/src/ui/ribbon/widgets.rs @@ -671,7 +671,15 @@ pub(super) fn render_small<'a>( items.iter().find(|(candidate, _, _)| *candidate == cmd) .map(|(_, _, item_icon)| *item_icon) }).or_else(|| items.first().map(|(_, _, item_icon)| *item_icon)).unwrap_or(*icon); - let localized_label = t!(*label).into_owned(); + let localized_label = if label.is_empty() { + items + .iter() + .find(|(cmd, _, _)| *cmd == last) + .map(|(_, item_label, _)| t!(*item_label).into_owned()) + .unwrap_or_default() + } else { + t!(*label).into_owned() + }; let face = row![ container(make_icon(cur_icon, SMALL_ICON)).width(Length::Fixed(SMALL_W)), text(localized_label.clone()).size(10).wrapping(advanced_text::Wrapping::None),