forked from 1b-agent/opencadstudio-upstream
Merge pull request #1476 from ramox81:codex/insert-reference-panel
This commit is contained in:
commit
0ea8599f86
35 files changed
+357
-55
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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ü
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -622,12 +622,15 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
"PDFIMPORTMODE",
|
||||
"PDFIMPORTFILTER",
|
||||
"PDFIMPORTLAYERS",
|
||||
"XDWGFADECTL",
|
||||
"POINTCLOUDCLIPFRAME",
|
||||
"XCLIPFRAME",
|
||||
"WIPEOUTFRAME",
|
||||
"FRAMES0",
|
||||
"FRAMES1",
|
||||
"FRAMES2",
|
||||
"UOSNAP0",
|
||||
"UOSNAP1",
|
||||
"HALOGAP",
|
||||
"TRACEWID",
|
||||
"SKETCHINC",
|
||||
|
||||
@@ -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 <ByLayer|ByBlock|1-255|name> — 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::<i32>().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3833,6 +3833,11 @@ pub enum Message {
|
||||
XAttachPickResult(Result<std::path::PathBuf, String>),
|
||||
/// 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<std::path::PathBuf, String>),
|
||||
/// An edit in the Attach External Reference dialog.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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")),
|
||||
|
||||
+23
-25
@@ -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 ───────────────────────────────────────────────────
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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()),
|
||||
}
|
||||
}
|
||||
@@ -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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+24
-1
@@ -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
|
||||
}
|
||||
|
||||
+108
-2
@@ -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<String>) -> 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<String>) -> 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);
|
||||
|
||||
@@ -109,6 +109,8 @@ pub struct Ribbon {
|
||||
underlay_ctx: Option<UnderlayContext>,
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user