fix(mleader): use lineweight choices
Replace the raw sentinel input with typed CAD lineweight options so special values display correctly and unsupported values cannot be entered. Refs #522
This commit is contained in:
parent
dce2533767
commit
a3538ddc45
5 changed files with 26 additions and 11 deletions
|
|
@ -630,7 +630,6 @@ pub(super) struct OpenCADStudio {
|
||||||
mls_line_color: String,
|
mls_line_color: String,
|
||||||
mls_text_color: String,
|
mls_text_color: String,
|
||||||
mls_description: String,
|
mls_description: String,
|
||||||
mls_line_weight: String,
|
|
||||||
mls_align_space: String,
|
mls_align_space: String,
|
||||||
mls_block_color: String,
|
mls_block_color: String,
|
||||||
mls_block_rotation: String,
|
mls_block_rotation: String,
|
||||||
|
|
@ -2336,6 +2335,7 @@ pub enum Message {
|
||||||
field: &'static str,
|
field: &'static str,
|
||||||
value: String,
|
value: String,
|
||||||
},
|
},
|
||||||
|
MLeaderStyleLineWeightChanged(LineWeight),
|
||||||
/// Set an Option<Handle> field (linetype / arrowhead / text style / block)
|
/// Set an Option<Handle> field (linetype / arrowhead / text style / block)
|
||||||
/// from a dropdown of record names ("None" clears it).
|
/// from a dropdown of record names ("None" clears it).
|
||||||
MLeaderStyleSetHandle {
|
MLeaderStyleSetHandle {
|
||||||
|
|
@ -2677,7 +2677,6 @@ impl OpenCADStudio {
|
||||||
mls_line_color: String::new(),
|
mls_line_color: String::new(),
|
||||||
mls_text_color: String::new(),
|
mls_text_color: String::new(),
|
||||||
mls_description: String::new(),
|
mls_description: String::new(),
|
||||||
mls_line_weight: String::new(),
|
|
||||||
mls_align_space: String::new(),
|
mls_align_space: String::new(),
|
||||||
mls_block_color: String::new(),
|
mls_block_color: String::new(),
|
||||||
mls_block_rotation: String::new(),
|
mls_block_rotation: String::new(),
|
||||||
|
|
|
||||||
|
|
@ -4809,6 +4809,13 @@ impl OpenCADStudio {
|
||||||
Message::MLeaderStyleSetEnum { field, value } => {
|
Message::MLeaderStyleSetEnum { field, value } => {
|
||||||
self.on_mleader_style_set_enum(field, value)
|
self.on_mleader_style_set_enum(field, value)
|
||||||
}
|
}
|
||||||
|
Message::MLeaderStyleLineWeightChanged(line_weight) => {
|
||||||
|
let i = self.active_tab;
|
||||||
|
if let Some(s) = self.mleaderstyle_mut(i) {
|
||||||
|
s.line_weight = line_weight;
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
Message::MLeaderStyleSetHandle { field, value } => {
|
Message::MLeaderStyleSetHandle { field, value } => {
|
||||||
self.on_mleader_style_set_handle(field, value)
|
self.on_mleader_style_set_handle(field, value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,6 @@ impl OpenCADStudio {
|
||||||
.map(|c| c.to_string())
|
.map(|c| c.to_string())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
self.mls_description = s.description.clone();
|
self.mls_description = s.description.clone();
|
||||||
self.mls_line_weight = s.line_weight.value().to_string();
|
|
||||||
self.mls_align_space = format!("{:.4}", s.align_space);
|
self.mls_align_space = format!("{:.4}", s.align_space);
|
||||||
self.mls_block_color = s
|
self.mls_block_color = s
|
||||||
.block_content_color
|
.block_content_color
|
||||||
|
|
@ -699,7 +698,6 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
|
||||||
"line_color" => self.mls_line_color = value,
|
"line_color" => self.mls_line_color = value,
|
||||||
"text_color" => self.mls_text_color = value,
|
"text_color" => self.mls_text_color = value,
|
||||||
"description" => self.mls_description = value,
|
"description" => self.mls_description = value,
|
||||||
"line_weight" => self.mls_line_weight = value,
|
|
||||||
"align_space" => self.mls_align_space = value,
|
"align_space" => self.mls_align_space = value,
|
||||||
"block_color" => self.mls_block_color = value,
|
"block_color" => self.mls_block_color = value,
|
||||||
"block_rotation" => self.mls_block_rotation = value,
|
"block_rotation" => self.mls_block_rotation = value,
|
||||||
|
|
@ -863,7 +861,6 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
|
||||||
self.mls_text_color.parse::<i16>().ok(),
|
self.mls_text_color.parse::<i16>().ok(),
|
||||||
);
|
);
|
||||||
let desc = self.mls_description.clone();
|
let desc = self.mls_description.clone();
|
||||||
let lw = self.mls_line_weight.parse::<i16>().ok();
|
|
||||||
let align = self.mls_align_space.parse::<f64>().ok();
|
let align = self.mls_align_space.parse::<f64>().ok();
|
||||||
let bclr = self.mls_block_color.parse::<i16>().ok();
|
let bclr = self.mls_block_color.parse::<i16>().ok();
|
||||||
let brot = self.mls_block_rotation.parse::<f64>().ok();
|
let brot = self.mls_block_rotation.parse::<f64>().ok();
|
||||||
|
|
@ -906,9 +903,6 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
|
||||||
s.text_color = acadrust::types::Color::from_index(v);
|
s.text_color = acadrust::types::Color::from_index(v);
|
||||||
}
|
}
|
||||||
s.description = desc;
|
s.description = desc;
|
||||||
if let Some(v) = lw {
|
|
||||||
s.line_weight = acadrust::types::LineWeight::from_value(v);
|
|
||||||
}
|
|
||||||
if let Some(v) = align {
|
if let Some(v) = align {
|
||||||
s.align_space = v;
|
s.align_space = v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,6 @@ impl OpenCADStudio {
|
||||||
line_color: &self.mls_line_color,
|
line_color: &self.mls_line_color,
|
||||||
text_color: &self.mls_text_color,
|
text_color: &self.mls_text_color,
|
||||||
description: &self.mls_description,
|
description: &self.mls_description,
|
||||||
line_weight: &self.mls_line_weight,
|
|
||||||
align_space: &self.mls_align_space,
|
align_space: &self.mls_align_space,
|
||||||
block_color: &self.mls_block_color,
|
block_color: &self.mls_block_color,
|
||||||
block_rotation: &self.mls_block_rotation,
|
block_rotation: &self.mls_block_rotation,
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ pub struct MLeaderStyleView<'a> {
|
||||||
pub line_color: &'a str,
|
pub line_color: &'a str,
|
||||||
pub text_color: &'a str,
|
pub text_color: &'a str,
|
||||||
pub description: &'a str,
|
pub description: &'a str,
|
||||||
pub line_weight: &'a str,
|
|
||||||
pub align_space: &'a str,
|
pub align_space: &'a str,
|
||||||
pub block_color: &'a str,
|
pub block_color: &'a str,
|
||||||
pub block_rotation: &'a str,
|
pub block_rotation: &'a str,
|
||||||
|
|
@ -176,6 +175,23 @@ fn enum_row<'a>(
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn lineweight_row<'a>(selected: acadrust::types::LineWeight) -> Element<'a, Message> {
|
||||||
|
let selected = crate::ui::properties::LwItem(selected);
|
||||||
|
row![
|
||||||
|
text("Line weight:").size(11).color(DIM).width(150),
|
||||||
|
pick_list(
|
||||||
|
crate::ui::properties::lw_options(),
|
||||||
|
Some(selected),
|
||||||
|
|item| Message::MLeaderStyleLineWeightChanged(item.0)
|
||||||
|
)
|
||||||
|
.text_size(11)
|
||||||
|
.width(190),
|
||||||
|
]
|
||||||
|
.spacing(8)
|
||||||
|
.align_y(iced::Center)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
/// The 11 horizontal text-attachment variants (debug names).
|
/// The 11 horizontal text-attachment variants (debug names).
|
||||||
const ATTACH_OPTS: [&str; 11] = [
|
const ATTACH_OPTS: [&str; 11] = [
|
||||||
"TopOfTopLine",
|
"TopOfTopLine",
|
||||||
|
|
@ -245,7 +261,7 @@ pub fn view_window<'a>(v: MLeaderStyleView<'a>) -> Element<'a, Message> {
|
||||||
"path_type"
|
"path_type"
|
||||||
),
|
),
|
||||||
color_row("Line color (ACI):", v.line_color, "line_color", v.color_open == Some("line_color")),
|
color_row("Line color (ACI):", v.line_color, "line_color", v.color_open == Some("line_color")),
|
||||||
num_row("Line weight:", "-2", v.line_weight, "line_weight"),
|
lineweight_row(s.line_weight),
|
||||||
handle_row(
|
handle_row(
|
||||||
"Line type:",
|
"Line type:",
|
||||||
v.lt_opts.clone(),
|
v.lt_opts.clone(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue