Insert Reference panel: one Attach, labelled underlay tools, slide-out with Edit Reference and xref fading

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-09-24 19:39:23 +03:00
1 parent 1a6279e841
commit 95e2bae0d2
35 files changed
+352 -54

No files matched your search

+6
View File
@@ -3519,6 +3519,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE حدد نقطة الإدراج:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Посочи точка на вмъкване:
insert =
.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
+6
View File
@@ -3504,6 +3504,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Zadejte bod vložení:
insert =
.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
+6
View File
@@ -3507,6 +3507,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Einführstelle angeben:
insert =
.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
+6
View File
@@ -3507,6 +3507,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Ορίστε σημείο εισαγωγής:
insert =
.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
+6
View File
@@ -3509,6 +3509,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Specify insertion point:
insert =
.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
+6
View File
@@ -3507,6 +3507,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Especifique el punto de inserción:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Määritä lisäyskohta:
insert =
.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
+6
View File
@@ -3507,6 +3507,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Spécifier le point d'insertion:
insert =
.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
+6
View File
@@ -3495,6 +3495,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE निर्दिष्ट सम्मिलन बिंदु:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Beszúrási pont megadása:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Specificare il punto di inserimento:
insert =
.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
+6
View File
@@ -3497,6 +3497,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE 挿入点を指定:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE 삽입점 지정:
insert =
.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
+6
View File
@@ -3505,6 +3505,12 @@ annotate =
.dimradius-select-arc-circle-or-polyline-arc = DIMRADIUS Selecteer een boog, cirkel of polylijnboog:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Określ punkt wstawienia:
insert =
.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
+6
View File
@@ -3507,6 +3507,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Especifique o ponto de inserção:
insert =
.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
+6
View File
@@ -3508,6 +3508,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Укажите точку вставки:
insert =
.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
+6
View File
@@ -3481,6 +3481,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE Ekleme noktasını belirtin:
insert =
.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ü
+6
View File
@@ -3494,6 +3494,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE 指定插入点:
insert =
.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
+6
View File
@@ -3506,6 +3506,12 @@ annotate =
.tolerance-specify-insertion-point = TOLERANCE 指定插入點:
insert =
.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
+3
View File
@@ -610,12 +610,15 @@ inventory::submit!(crate::command::CommandRegistration {
"FRAME",
"IMAGEFRAME",
"PDFFRAME",
"XDWGFADECTL",
"POINTCLOUDCLIPFRAME",
"XCLIPFRAME",
"WIPEOUTFRAME",
"FRAMES0",
"FRAMES1",
"FRAMES2",
"UOSNAP0",
"UOSNAP1",
"HALOGAP",
"TRACEWID",
"SKETCHINC",
+31
View File
@@ -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" => {
@@ -1015,6 +1017,7 @@ impl OpenCADStudio {
| "FRAME"
| "IMAGEFRAME"
| "PDFFRAME"
| "XDWGFADECTL"
| "POINTCLOUDCLIPFRAME"
| "XCLIPFRAME"
| "WIPEOUTFRAME"
@@ -1081,6 +1084,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 {
@@ -3525,3 +3541,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();
}
}
}
}
+5
View File
@@ -3814,6 +3814,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.
+14
View File
@@ -5716,6 +5716,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();
+1 -1
View File
@@ -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
};
+6
View File
@@ -2942,6 +2942,12 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Unable to save: file is in use." => Some(("command-line", "unable-to-save-file-is-in-use")),
"Unable to verify the server certificate" => Some(("plugins", "unable-to-verify-the-server-certificate")),
"Unavailable" => Some(("plugins", "unavailable")),
"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")),
"Underlay\nLayers" => Some(("insert", "underlay-layers")),
"Underlay Adjust" => Some(("properties", "underlay-adjust")),
+23 -25
View File
@@ -47,41 +47,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 ───────────────────────────────────────────────────
-13
View File
@@ -4,21 +4,8 @@ use acadrust::EntityType;
use glam::DVec3;
use crate::command::{CadCommand, CmdResult, WorkingPlane};
use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::t;
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()),
}
}
pub struct PdfAttachCommand {
definition_handle: Handle,
plane: WorkingPlane,
+1 -9
View File
@@ -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()),
}
}
+3 -3
View File
@@ -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()),
}
}
+24 -1
View File
@@ -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
}
+103 -1
View File
@@ -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,
},
];
fn panel_for_dropdown(id: &str) -> Option<Panel> {
@@ -159,7 +175,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![
@@ -173,6 +189,30 @@ 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();
if panel.id != REFERENCE_PANEL_ID {
return title_button;
}
// The corner arrow opens the External References palette.
let launcher = tooltip(
button(text("↘").size(10))
.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);
row![
iced::widget::Space::new().width(Fill),
title_button,
container(launcher).width(Fill).align_x(iced::Right)
]
.align_y(iced::Center)
.into()
}
@@ -211,8 +251,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);
+3
View File
@@ -102,6 +102,8 @@ pub struct Ribbon {
/// Set by `CollapsePanels` when the tool row is in its tight state; the mode
/// selector hides itself then to give the cramped tab row its space back.
collapse_tight: Arc<AtomicBool>,
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
pub xref_fade: i32,
}
/// Per-layer display data shown in the ribbon layer dropdown.
@@ -195,6 +197,7 @@ impl Ribbon {
tool_bar_h: Arc::new(AtomicU32::new(TOOL_BAR_H.to_bits())),
collapse_mode: CollapseMode::default(),
collapse_tight: Arc::new(AtomicBool::new(false)),
xref_fade: 50,
}
}
+9 -1
View File
@@ -665,7 +665,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),