From b7c5103891c98ee6d3dd766f9f6d71e24b87226d Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 14 Jun 2026 14:27:35 +0300 Subject: [PATCH] feat(ui): show RGB for unnamed palette colours instead of "Index" Picking a colour from the full palette showed a generic "Index" label. Add color_display_name: standard names for ACI 1-9 / ByLayer / ByBlock, "R,G,B" (0-255) for every other indexed or true colour. Used by the shared colour selector button and the ribbon colour combo. Co-Authored-By: Claude Opus 4.8 --- src/ui/color_select.rs | 23 ++++++++++++++++++++++- src/ui/ribbon/widgets.rs | 8 ++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/ui/color_select.rs b/src/ui/color_select.rs index 081ed15c2..d0859f45d 100644 --- a/src/ui/color_select.rs +++ b/src/ui/color_select.rs @@ -60,6 +60,26 @@ pub fn aci_string_to_color(s: &str) -> AcadColor { } } +/// Display name for a colour: the standard name for ACI 1-9 / ByLayer / +/// ByBlock, otherwise the "R,G,B" values (0-255) so unnamed palette colours +/// read meaningfully. +pub fn color_display_name(c: AcadColor) -> String { + let (_, label) = acad_color_display(c); + if label == "Index" || label == "Custom" { + match c { + AcadColor::Index(i) => { + let (r, g, b) = + acadrust::types::aci_table::aci_to_rgb(i).unwrap_or((128, 128, 128)); + format!("{r},{g},{b}") + } + AcadColor::Rgb { r, g, b } => format!("{r},{g},{b}"), + _ => label.to_string(), + } + } else { + label.to_string() + } +} + /// A small colour square. fn swatch<'a>(bg: Color) -> Element<'a, Message> { container(text("").width(13).height(13)) @@ -97,7 +117,8 @@ pub fn color_selector<'a>( on_toggle: Message, on_more: Message, ) -> Element<'a, Message> { - let (cur_bg, cur_name) = acad_color_display(current); + let (cur_bg, _) = acad_color_display(current); + let cur_name = color_display_name(current); // Closed button: current swatch + name + caret. let head = button( diff --git a/src/ui/ribbon/widgets.rs b/src/ui/ribbon/widgets.rs index 1b4e2be7c..e39c4c49d 100644 --- a/src/ui/ribbon/widgets.rs +++ b/src/ui/ribbon/widgets.rs @@ -858,8 +858,12 @@ pub(super) fn render_large<'a>( .width(Length::Fixed(PROP_W)) }; - let (color_swatch, color_label) = acad_color_display(active_color); - let color_row = prop_row(color_label.to_string(), PROP_COLOR_ID, Some(color_swatch)); + let (color_swatch, _) = acad_color_display(active_color); + let color_row = prop_row( + crate::ui::color_select::color_display_name(active_color), + PROP_COLOR_ID, + Some(color_swatch), + ); let lt_row = prop_row(active_linetype.to_string(), PROP_LINETYPE_ID, None); let lw_row = prop_row(LwItem(active_lineweight).to_string(), PROP_LW_ID, None);