Clean up Graphic Attributes palette

- Revert formatting, import/module reordering and unrelated rewrites
  outside the feature (command.rs, style.rs, paper.rs, view/mod.rs,
  properties.rs, dialog.rs, ValuePromptCommand); the new SVG icons stay.
- Move the palette logic out of dialog.rs into update/graphic_attributes.rs.
- Replace 14 loose app fields and ~50 Message variants by
  GraphicAttributesState (one Menu enum for the open drop-down) and a
  nested GraphicAttributesMsg / GradientMsg, like BlockPaletteMsg.
- Share the selection -> line/fill handles -> unlocked edit path, reuse
  valid_block_name, the ribbon lineweight handler and fill_handles, and
  drop the unused GradientColorToggle, color_open and LineLinetypeScaleInput.
- Linetype scale accepts any positive value (e.g. ISO pen widths 0.13,
  0.18, 0.25, 0.35) instead of rounding to 0.1 with a 0.1 minimum.
- Closing open boundaries and creating the fill is one undo step.
- The close prompt also answers typed Y/N + Enter, a bare Enter (Yes)
  and Escape (cancel), not only the option buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgkJN8DEojuPTumAXLHotu
This commit is contained in:
Claude committed 2026-10-07 16:45:39 +00:00
1 parent 3e45331de1
commit 3c859c6b0e
17 files changed
+3478 -3992

No files matched your search

+9 -22
View File
@@ -308,10 +308,6 @@ pub struct ValuePromptCommand {
prompt: &'static str,
}
fn dispatch_prompt_value(name: &str, text: &str) -> CmdResult {
CmdResult::Dispatch(format!("{name} {}", text.trim()))
}
impl ValuePromptCommand {
pub fn new(name: &'static str, prompt: &'static str) -> Self {
Self { name, prompt }
@@ -332,7 +328,12 @@ impl CadCommand for ValuePromptCommand {
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
Some(dispatch_prompt_value(self.name, text))
let t = text.trim();
if t.is_empty() {
Some(CmdResult::Dispatch(format!("{} ", self.name)))
} else {
Some(CmdResult::Dispatch(format!("{} {t}", self.name)))
}
}
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
@@ -342,7 +343,7 @@ impl CadCommand for ValuePromptCommand {
fn on_enter(&mut self) -> CmdResult {
// Bare Enter → report the current value via the inline handler.
dispatch_prompt_value(self.name, "")
CmdResult::Dispatch(format!("{} ", self.name))
}
}
@@ -374,7 +375,7 @@ impl CadCommand for FreeTextValuePromptCommand {
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
Some(dispatch_prompt_value(self.name, text))
Some(CmdResult::Dispatch(format!("{} {}", self.name, text.trim())))
}
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
@@ -382,7 +383,7 @@ impl CadCommand for FreeTextValuePromptCommand {
}
fn on_enter(&mut self) -> CmdResult {
dispatch_prompt_value(self.name, "")
CmdResult::Dispatch(format!("{} ", self.name))
}
}
@@ -3078,20 +3079,6 @@ mod constraint_registry_tests {
mod tests {
use super::*;
#[test]
fn prompt_dispatch_trims_values_and_preserves_empty_argument() {
let CmdResult::Dispatch(value) = dispatch_prompt_value("TEST", " value with spaces ")
else {
panic!("prompt input should dispatch a command");
};
assert_eq!(value, "TEST value with spaces");
let CmdResult::Dispatch(value) = dispatch_prompt_value("TEST", " ") else {
panic!("empty prompt input should dispatch a command");
};
assert_eq!(value, "TEST ");
}
#[test]
fn test_mid2point_command() {
let mut cmd = Mid2PointCommand::new();