fix(layers): preserve true colors

Closes #587
This commit is contained in:
Hakan Seven 2026-07-30 16:48:14 +03:00
commit 1b1d9af2d5
5 changed files with 16 additions and 69 deletions

View file

@ -64,7 +64,7 @@ impl OpenCADStudio {
.iter()
.map(|l| crate::ui::ribbon::LayerInfo {
name: l.name.clone(),
color: l.color,
color: crate::ui::window::layers::iced_color_from_acad(&l.color),
visible: l.visible,
frozen: l.frozen,
locked: l.locked,

View file

@ -1708,7 +1708,7 @@ pub enum Message {
LayerRenameEdit(String),
LayerColorPickerToggle(usize),
LayerColorMorePalette,
LayerColorSet(u8),
LayerColorSet(acadrust::types::Color),
LayerLinetypeSet(String),
LayerLineweightSet(LineWeight),
LayerTransparencyEdit(usize, String),

View file

@ -1,7 +1,6 @@
use super::{Message, OpenCADStudio};
use crate::scene::VIEWCUBE_DRAW_PX;
use crate::ui::PropertiesPanel;
use acadrust::types::Color as AcadColor;
use iced::time::Instant;
use iced::Task;
@ -1998,22 +1997,20 @@ impl OpenCADStudio {
Task::none()
}
Message::LayerColorSet(aci) => {
Message::LayerColorSet(color) => {
let i = self.active_tab;
// Apply to every selected layer (multi-select), not just one.
let names = self.selected_layer_names(i);
if !names.is_empty() {
let undo = self.begin_layer_undo(i, "LAYER COLOR", &names);
use crate::ui::window::layers::iced_color_from_acad;
let new_color = iced_color_from_acad(&AcadColor::Index(aci));
for name in &names {
if let Some(dl) = self.tabs[i].scene.document.layers.get_mut(name) {
dl.color = AcadColor::Index(aci);
dl.color = color;
}
}
for pl in self.tabs[i].layers.layers.iter_mut() {
if names.contains(&pl.name) {
pl.color = new_color;
pl.color = color;
}
}
self.tabs[i].dirty = true;

View file

@ -986,14 +986,7 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
}
Some(crate::app::ColorPickTarget::Layer(idx)) => {
self.tabs[self.active_tab].layers.selected = Some(idx);
let index = match color {
acadrust::types::Color::Index(i) => i,
acadrust::types::Color::Rgb { r, g, b } => {
crate::ui::color_select::nearest_aci(r, g, b)
}
_ => 7,
};
Some(Message::LayerColorSet(index))
Some(Message::LayerColorSet(color))
}
Some(crate::app::ColorPickTarget::LayerState(idx)) => {
Some(Message::LayerStateEditorLayerColor(idx, color))