forked from 1b-agent/opencadstudio-upstream
fix(annotative): stage scale-manager edits like the style managers
The scale manager now runs as a transaction, matching the style managers' staging: New starts a blank editor draft (nothing is added to the drawing until Apply), Delete removes immediately but staged, and closing the window without Apply restores the snapshot taken on open — so a scale created or deleted mid-session is discarded on cancel. Apply commits the staged list changes as a single undo entry. This replaces the earlier behaviour where New copied the selected scale and edits landed immediately. A `changed` flag guards the commit so a no-op / failed Apply (blank or invalid fields, or an edit that didn't apply) no longer dirties the drawing or pushes a phantom undo entry. Set Current is deliberately outside the transaction — it takes effect immediately like the scale pill (and syncs CANNOSCALEVALUE), so it is never rolled back on close. Renaming the current scale follows the pointer; editing one of the built-in fallback scales (shown when the drawing has no scale list) materialises it as a real scale; the snapshot restore touches only the ACAD_SCALELIST root entry. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
1071570f40
commit
cd766bc1f5
4 files changed
+220
-48
No files matched your search
@@ -146,28 +146,29 @@ pub fn view_window<'a, 'b>(
|
||||
});
|
||||
|
||||
// ── Right: editor (name + paper:drawing) ──────────────────────────────
|
||||
let field = |label: &'static str, value: &str, on: fn(String) -> Message| {
|
||||
row![
|
||||
text(label).size(11).color(DIM).width(96),
|
||||
text_input("", value)
|
||||
.on_input(on)
|
||||
.style(field_style)
|
||||
.size(12)
|
||||
.padding([5, 8])
|
||||
.width(Fill),
|
||||
]
|
||||
.align_y(iced::Center)
|
||||
.spacing(6)
|
||||
};
|
||||
let field =
|
||||
|label: &'static str, ph: &'static str, value: &str, on: fn(String) -> Message| {
|
||||
row![
|
||||
text(label).size(11).color(DIM).width(96),
|
||||
text_input(ph, value)
|
||||
.on_input(on)
|
||||
.style(field_style)
|
||||
.size(12)
|
||||
.padding([5, 8])
|
||||
.width(Fill),
|
||||
]
|
||||
.align_y(iced::Center)
|
||||
.spacing(6)
|
||||
};
|
||||
|
||||
let editor = container(
|
||||
column![
|
||||
text("Scale").size(10).color(DIM),
|
||||
field("Name", name_buf, Message::ScaleManagerNameBuf),
|
||||
field("Paper units", paper_buf, Message::ScaleManagerPaperBuf),
|
||||
field("Drawing units", drawing_buf, Message::ScaleManagerDrawingBuf),
|
||||
field("Name", "e.g. 1:50", name_buf, Message::ScaleManagerNameBuf),
|
||||
field("Paper units", "1", paper_buf, Message::ScaleManagerPaperBuf),
|
||||
field("Drawing units", "50", drawing_buf, Message::ScaleManagerDrawingBuf),
|
||||
Space::new().height(6),
|
||||
text("Type the ratio in the fields, then New to add or Apply to update the selected scale.")
|
||||
text("New starts a blank scale; edit the fields and click Apply to save it. Changes are discarded if you close without Apply.")
|
||||
.size(10)
|
||||
.color(DIM),
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user