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

+23 -1
View File
@@ -124,9 +124,31 @@ pub fn color_selector<'a>(
on_select: impl Fn(AcadColor) -> Message + 'a,
on_toggle: Message,
on_more: Message,
) -> Element<'a, Message> {
color_selector_with_name(
current,
None,
open,
extras,
on_select,
on_toggle,
on_more,
)
}
pub fn color_selector_with_name<'a>(
current: AcadColor,
display_name: Option<&'a str>,
open: bool,
extras: ColorExtras,
on_select: impl Fn(AcadColor) -> Message + 'a,
on_toggle: Message,
on_more: Message,
) -> Element<'a, Message> {
let (cur_bg, _) = acad_color_display(current);
let cur_name = color_display_name(current);
let cur_name = display_name
.map(str::to_string)
.unwrap_or_else(|| color_display_name(current));
let on_dismiss = on_toggle.clone();
// Closed button: current swatch + name + caret.
+9 -2
View File
@@ -776,7 +776,12 @@ impl PropertiesPanel {
label: &'a str,
) -> Element<'a, Message> {
match &prop.value {
PropValue::ColorChoice(color) => self.render_color_row(label, prop.field, *color),
PropValue::ColorChoice(color) => {
self.render_color_row(label, prop.field, *color, None)
}
PropValue::NamedColorChoice { color, name } => {
self.render_color_row(label, prop.field, *color, Some(name))
}
PropValue::ColorVaries => self.render_color_varies_row(label),
PropValue::LayerChoice(layer) => self.render_layer_row(label, layer),
PropValue::LwChoice(lw) => self.render_lw_row(label, *lw),
@@ -848,6 +853,7 @@ impl PropertiesPanel {
label: &'a str,
field: &'static str,
color: AcadColor,
display_name: Option<&'a str>,
) -> Element<'a, Message> {
// MTEXT background colour uses its own picker state + messages so it
// routes to `background_color`, not the entity's main colour.
@@ -929,8 +935,9 @@ impl PropertiesPanel {
);
return prop_row_widget(label, selector);
}
let selector = crate::ui::color_select::color_selector(
let selector = crate::ui::color_select::color_selector_with_name(
color,
display_name,
self.color_picker_open,
crate::ui::color_select::ColorExtras {
by_layer: true,
+8 -1
View File
@@ -90,6 +90,8 @@ pub struct Layer {
pub locked: bool,
pub plottable: bool,
pub color: AcadColor,
pub color_name: Option<String>,
pub book_name: Option<String>,
pub linetype: String,
pub lineweight: LineWeight,
pub transparency: i32,
@@ -106,6 +108,8 @@ impl Layer {
locked: false,
plottable: true,
color,
color_name: None,
book_name: None,
linetype: "Continuous".to_string(),
lineweight: LineWeight::Default,
transparency: 0,
@@ -220,6 +224,8 @@ impl LayerPanel {
locked: l.flags.locked,
plottable: l.is_plottable,
color: l.color,
color_name: l.color_name.clone(),
book_name: l.book_name.clone(),
linetype: if l.line_type.is_empty() {
"Continuous".to_string()
} else {
@@ -808,8 +814,9 @@ fn layer_row<'a>(
// Color cell — looks like a combo_box input; click opens swatch dropdown below row.
// Shared colour selector. Layers carry a concrete colour (no ByLayer /
// ByBlock); true colours stay RGB instead of being collapsed to ACI 7.
let color_cell: Element<'_, Message> = container(crate::ui::color_select::color_selector(
let color_cell: Element<'_, Message> = container(crate::ui::color_select::color_selector_with_name(
layer.color,
layer.color_name.as_deref(),
color_picker_open,
crate::ui::color_select::ColorExtras {
by_layer: false,