diff --git a/src/app/mod.rs b/src/app/mod.rs index 9e5877083..3830c21dc 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1218,6 +1218,8 @@ pub enum ColorPickTarget { Properties, /// Selected entities' background colour (hatch / MTEXT background row). PropertiesBg, + /// A named per-entity Properties colour field. + PropertiesField(String), /// Current creation colour (ribbon). Ribbon, /// A layer's colour, by panel row index. diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index 2dd58b15b..24bb99c55 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -4841,6 +4841,11 @@ impl OpenCADStudio { | "dim_text_color" | "dim_text_fill_color" ) { + let fill_mode = (field == "dim_text_fill_color").then(|| match color { + acadrust::types::Color::None => 0, + acadrust::types::Color::ByBlock => 1, + _ => 2, + }); let aci = color.approximate_index(); let code = match field.as_str() { "dim_ext_line_color" => crate::entities::dim_override::DIMCLRE, @@ -4862,6 +4867,19 @@ impl OpenCADStudio { if !targets.is_empty() { self.push_undo_snapshot(i, "CHPROP"); for &handle in &targets { + if field == "dim_text_fill_color" { + crate::entities::dim_override::set( + &mut self.tabs[i].scene.document, + handle, + crate::entities::dim_override::DIMTFILL, + Some(acadrust::xdata::XDataValue::Integer16( + fill_mode.unwrap_or(2), + )), + ); + if fill_mode != Some(2) { + continue; + } + } crate::entities::dim_override::set( &mut self.tabs[i].scene.document, handle, @@ -7539,6 +7557,7 @@ impl OpenCADStudio { let i = self.active_tab; self.tabs[i].properties.color_picker_open = false; + self.tabs[i].properties.open_color_field = None; self.tabs[i].layers.color_picker_row = None; Task::none() diff --git a/src/app/update/style.rs b/src/app/update/style.rs index 4a13eb631..3574338df 100644 --- a/src/app/update/style.rs +++ b/src/app/update/style.rs @@ -1146,6 +1146,9 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task { Some(crate::app::ColorPickTarget::PropertiesBg) => { Some(Message::PropBgColorChanged(color)) } + Some(crate::app::ColorPickTarget::PropertiesField(field)) => { + Some(Message::PropColorFieldChanged { field, color }) + } Some(crate::app::ColorPickTarget::MText) => { Some(Message::MTextColorChanged(color)) } diff --git a/src/app/view/overlay.rs b/src/app/view/overlay.rs index 82e6f68b9..b5782f819 100644 --- a/src/app/view/overlay.rs +++ b/src/app/view/overlay.rs @@ -474,6 +474,7 @@ fn mtext_editor_content<'a>( crate::ui::color_select::ColorExtras { by_layer: true, by_block: false, + ..Default::default() }, Message::MTextColorChanged, Message::MTextColorPickerToggle, diff --git a/src/ui/color_select.rs b/src/ui/color_select.rs index 233ec87e4..0bc203cc4 100644 --- a/src/ui/color_select.rs +++ b/src/ui/color_select.rs @@ -16,6 +16,8 @@ use crate::t; pub struct ColorExtras { pub by_layer: bool, pub by_block: bool, + pub none: bool, + pub background: bool, } /// Encode a colour as the ACI integer string the style editors store @@ -38,7 +40,7 @@ pub fn iced_to_acad_color(color: Color) -> AcadColor { AcadColor::Rgb { r, g, b } } -/// Return the closest AutoCAD Color Index for an RGB colour. +/// Return the closest CAD Color Index for an RGB colour. pub fn nearest_aci(r: u8, g: u8, b: u8) -> u8 { let mut best = 7; let mut best_distance = u32::MAX; @@ -209,7 +211,27 @@ pub fn color_list<'a>( .into() }; + let logical_row = |color: AcadColor, label: &'static str| -> Element<'a, Message> { + let (bg, _) = acad_color_display(color); + button( + row![swatch(bg), text(t!(label)).size(11)] + .spacing(5) + .align_y(iced::Center), + ) + .on_press(on_select(color)) + .style(list_row_style) + .padding([2, 4]) + .width(Length::Fill) + .into() + }; + let mut list = column![].spacing(1); + if extras.none { + list = list.push(named_row(AcadColor::None)); + } + if extras.background { + list = list.push(logical_row(AcadColor::ByBlock, "Background")); + } if extras.by_layer { list = list.push(named_row(AcadColor::ByLayer)); } @@ -297,7 +319,7 @@ pub fn index_color_page<'a>( .into() }; - // AutoCAD's first standard indexed colours. + // The first standard indexed CAD colours. let mut standard = row![].spacing(4); for idx in 1u8..=9 { standard = standard.push(swatch_button(AcadColor::Index(idx), 22.0)); @@ -402,7 +424,7 @@ pub fn index_color_page<'a>( tabs, text("Standard colors").size(11), standard, - text("AutoCAD Color Index (ACI) 10–249").size(11), + text("CAD Color Index (ACI) 10–249").size(11), text("Color family → · Shade / intensity ↓") .size(9) diff --git a/src/ui/properties.rs b/src/ui/properties.rs index 1a036f4cb..5d562dd45 100644 --- a/src/ui/properties.rs +++ b/src/ui/properties.rs @@ -834,6 +834,7 @@ impl PropertiesPanel { crate::ui::color_select::ColorExtras { by_layer: true, by_block: true, + ..Default::default() }, Message::PropBgColorChanged, Message::PropBgColorPickerToggle, @@ -851,18 +852,35 @@ impl PropertiesPanel { // entity's main colour. Used by hatch gradient colours and the dim-line // colour override (Leader / Dimension). Dim colours legitimately take // ByLayer / ByBlock; gradient colours do not. - if field == "gradient_color_1" || field == "gradient_color_2" || field == "dim_line_color" { + if matches!( + field, + "gradient_color_1" + | "gradient_color_2" + | "dim_line_color" + | "dim_ext_line_color" + | "dim_text_color" + | "dim_text_fill_color" + ) { let open = self.open_color_field.as_deref() == Some(field); let fsel = field.to_string(); - let extras = if field == "dim_line_color" { + let full_palette_field = field.to_string(); + let extras = if field == "dim_text_fill_color" { + crate::ui::color_select::ColorExtras { + none: true, + background: true, + ..Default::default() + } + } else if field.starts_with("dim_") { crate::ui::color_select::ColorExtras { by_layer: true, by_block: true, + ..Default::default() } } else { crate::ui::color_select::ColorExtras { by_layer: false, by_block: false, + ..Default::default() } }; let selector = crate::ui::color_select::color_selector( @@ -874,7 +892,10 @@ impl PropertiesPanel { color: c, }, Message::PropColorFieldToggle(field.to_string()), - Message::PropColorFieldToggle(field.to_string()), + Message::OpenColorWindow( + crate::app::ColorPickTarget::PropertiesField(full_palette_field), + color, + ), ); return prop_row_widget(label, selector); } @@ -884,6 +905,7 @@ impl PropertiesPanel { crate::ui::color_select::ColorExtras { by_layer: true, by_block: true, + ..Default::default() }, Message::PropColorChanged, Message::PropColorPickerToggle, diff --git a/src/ui/ribbon/mod.rs b/src/ui/ribbon/mod.rs index abcccd86c..9af9ff610 100644 --- a/src/ui/ribbon/mod.rs +++ b/src/ui/ribbon/mod.rs @@ -1135,6 +1135,7 @@ impl Ribbon { crate::ui::color_select::ColorExtras { by_layer: true, by_block: true, + ..Default::default() }, Message::RibbonColorChanged, Message::OpenColorWindow( diff --git a/src/ui/style/dimstyle.rs b/src/ui/style/dimstyle.rs index e6a7a2005..dc2db0c6a 100644 --- a/src/ui/style/dimstyle.rs +++ b/src/ui/style/dimstyle.rs @@ -518,6 +518,7 @@ pub fn view_window<'a>( crate::ui::color_select::ColorExtras { by_layer: true, by_block: true, + ..Default::default() }, move |c| Message::DsEdit(f_sel.clone(), crate::ui::color_select::color_to_aci_string(c)), Message::DsColorMore(fld.clone()), diff --git a/src/ui/style/mleaderstyle.rs b/src/ui/style/mleaderstyle.rs index 0de3aee71..4b7e5a2a0 100644 --- a/src/ui/style/mleaderstyle.rs +++ b/src/ui/style/mleaderstyle.rs @@ -115,7 +115,11 @@ fn color_row<'a>( let selector = crate::ui::color_select::color_selector( current, open, - crate::ui::color_select::ColorExtras { by_layer: true, by_block: true }, + crate::ui::color_select::ColorExtras { + by_layer: true, + by_block: true, + ..Default::default() + }, move |color| Message::MLeaderStyleEdit { field, value: crate::ui::color_select::color_to_aci_string(color), diff --git a/src/ui/style/tablestyle.rs b/src/ui/style/tablestyle.rs index ce067b57a..4117ec778 100644 --- a/src/ui/style/tablestyle.rs +++ b/src/ui/style/tablestyle.rs @@ -317,7 +317,11 @@ fn cell_editor<'a>(v: &TableStyleView<'a>, row_index: u8) -> Element<'a, Message let selector = crate::ui::color_select::color_selector( current, v.color_open == Some((row_index, field)), - crate::ui::color_select::ColorExtras { by_layer: true, by_block: true }, + crate::ui::color_select::ColorExtras { + by_layer: true, + by_block: true, + ..Default::default() + }, move |color| Message::TableStyleCellEdit { row: row_index, field, diff --git a/src/ui/window/layer_state_manager.rs b/src/ui/window/layer_state_manager.rs index 00429e3f0..97f54f8b0 100644 --- a/src/ui/window/layer_state_manager.rs +++ b/src/ui/window/layer_state_manager.rs @@ -412,6 +412,7 @@ fn editor_layer_row<'a>( crate::ui::color_select::ColorExtras { by_layer: false, by_block: false, + ..Default::default() }, move |color| Message::LayerStateEditorLayerColor(index, color), Message::LayerStateEditorLayerColorToggle(index), diff --git a/src/ui/window/layers.rs b/src/ui/window/layers.rs index cffcfa4ab..11253ee51 100644 --- a/src/ui/window/layers.rs +++ b/src/ui/window/layers.rs @@ -813,6 +813,7 @@ fn layer_row<'a>( crate::ui::color_select::ColorExtras { by_layer: false, by_block: false, + ..Default::default() }, Message::LayerColorSet, Message::LayerColorPickerToggle(index),