fix(color): show color book identity

This commit is contained in:
Hakan Seven committed 2026-09-01 08:44:28 +03:00
1 parent 7ea4f338f6
commit 6d6defa0ad
19 files changed
+142 -30

No files matched your search

+13 -1
View File
@@ -17,6 +17,18 @@ pub fn general_section(entity: &EntityType) -> PropSection {
((alpha as f64 / 255.0 * 100.0).round() as u32).to_string()
}
};
let color_value = common.color_name.as_deref().map_or_else(
|| PropValue::ColorChoice(common.color),
|identity| PropValue::NamedColorChoice {
color: common.color,
name: identity
.split_once('$')
.map(|(_, color_name)| color_name)
.filter(|color_name| !color_name.is_empty())
.unwrap_or(identity)
.to_string(),
},
);
// Hyperlink is stored in XDATA under the "PE_URL" application.
let hyperlink = common
@@ -36,7 +48,7 @@ pub fn general_section(entity: &EntityType) -> PropSection {
Property {
label: t!("Color").into_owned(),
field: "color",
value: PropValue::ColorChoice(common.color),
value: color_value,
},
Property {
label: t!("Layer").into_owned(),
+2
View File
@@ -30,6 +30,8 @@ pub enum PropValue {
},
/// ACI/RGB/ByLayer/ByBlock color — rendered as a color picker.
ColorChoice(AcadColor),
/// Color-book color with its file-provided display name.
NamedColorChoice { color: AcadColor, name: String },
/// Color varies across the current multi-selection.
ColorVaries,
/// Line weight — rendered as a combo_box.
+10 -2
View File
@@ -568,7 +568,8 @@ impl Scene {
}
QSelectValueEditor::Choice(values)
}
PropValue::ColorChoice(_) => QSelectValueEditor::Choice(vec![
PropValue::ColorChoice(_)
| PropValue::NamedColorChoice { .. } => QSelectValueEditor::Choice(vec![
"ByLayer".into(),
"ByBlock".into(),
]),
@@ -659,7 +660,13 @@ impl Scene {
match field {
"handle" => Some(entity.common().handle.value().to_string()),
"layer" => Some(entity.common().layer.clone()),
"color" => Some(Self::format_color(entity.common().color)),
"color" => Some(
entity
.common()
.color_name
.clone()
.unwrap_or_else(|| Self::format_color(entity.common().color)),
),
"linetype" => Some(if entity.common().linetype.is_empty() {
"ByLayer".to_string()
} else {
@@ -732,6 +739,7 @@ impl Scene {
PropValue::Choice { selected, .. } => selected,
PropValue::EditChoice { value, .. } => value,
PropValue::ColorChoice(c) => Self::format_color(c),
PropValue::NamedColorChoice { name, .. } => name,
PropValue::LwChoice(lw)
| PropValue::FieldLwChoice { value: lw, .. } => {
Self::format_lineweight(lw)
+3 -1
View File
@@ -296,7 +296,9 @@ pub fn toggle_invisible(entity: &mut EntityType) {
pub fn apply_color(entity: &mut EntityType, color: AcadColor) {
entity.as_entity_mut().set_color(color);
entity.common_mut().color_book_handle = None;
let common = entity.common_mut();
common.color_name = None;
common.color_book_handle = None;
}
pub fn apply_line_weight(entity: &mut EntityType, lw: LineWeight) {