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 <noreply@anthropic.com>
This commit is contained in:
parent
f7734b698f
commit
b7c5103891
2 changed files with 28 additions and 3 deletions
|
|
@ -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.
|
/// A small colour square.
|
||||||
fn swatch<'a>(bg: Color) -> Element<'a, Message> {
|
fn swatch<'a>(bg: Color) -> Element<'a, Message> {
|
||||||
container(text("").width(13).height(13))
|
container(text("").width(13).height(13))
|
||||||
|
|
@ -97,7 +117,8 @@ pub fn color_selector<'a>(
|
||||||
on_toggle: Message,
|
on_toggle: Message,
|
||||||
on_more: Message,
|
on_more: Message,
|
||||||
) -> Element<'a, 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.
|
// Closed button: current swatch + name + caret.
|
||||||
let head = button(
|
let head = button(
|
||||||
|
|
|
||||||
|
|
@ -858,8 +858,12 @@ pub(super) fn render_large<'a>(
|
||||||
.width(Length::Fixed(PROP_W))
|
.width(Length::Fixed(PROP_W))
|
||||||
};
|
};
|
||||||
|
|
||||||
let (color_swatch, color_label) = acad_color_display(active_color);
|
let (color_swatch, _) = acad_color_display(active_color);
|
||||||
let color_row = prop_row(color_label.to_string(), PROP_COLOR_ID, Some(color_swatch));
|
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 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);
|
let lw_row = prop_row(LwItem(active_lineweight).to_string(), PROP_LW_ID, None);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue