forked from 1b-agent/opencadstudio-upstream
Select Color and ribbon: ByLayer shows the layer's colour
ByLayer swatches were always gray. The Select Color panel's Current/New band and info line now show the colour of the layer the colour is for (the newest selected object's layer, or the current layer for new objects); the ribbon's colour control and the ByLayer row of its colour dropdown show the current layer's colour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013rGmDUNr1hUf4zo1X3dak8
This commit is contained in:
5 files changed
+79
-12
No files matched your search
@@ -157,12 +157,14 @@ fn divider<'a>() -> Element<'a, Message> {
|
||||
.into()
|
||||
}
|
||||
|
||||
/// `shown` overrides the swatch, so ByLayer can show the layer's colour.
|
||||
fn logical_row<'a>(
|
||||
color: AcadColor,
|
||||
cur_color: AcadColor,
|
||||
label: &'static str,
|
||||
shown: Option<iced::Color>,
|
||||
) -> Element<'a, Message> {
|
||||
let (bg, _) = acad_color_display(color);
|
||||
let bg = shown.unwrap_or_else(|| acad_color_display(color).0);
|
||||
let selected = color == cur_color;
|
||||
|
||||
let swatch = container(
|
||||
@@ -212,13 +214,15 @@ fn more_colors_row<'a>(active_color: AcadColor) -> Element<'a, Message> {
|
||||
}
|
||||
|
||||
/// Builds the complete 5-section color dropdown panel element.
|
||||
/// `layer_color` is the current layer's colour, shown on the ByLayer row.
|
||||
pub fn color_dropdown_panel<'a>(
|
||||
active_color: AcadColor,
|
||||
recent_colors: &[AcadColor],
|
||||
layer_color: Option<iced::Color>,
|
||||
) -> Element<'a, Message> {
|
||||
// 1. ByLayer and ByBlock
|
||||
let by_layer = logical_row(AcadColor::ByLayer, active_color, "ByLayer");
|
||||
let by_block = logical_row(AcadColor::ByBlock, active_color, "ByBlock");
|
||||
let by_layer = logical_row(AcadColor::ByLayer, active_color, "ByLayer", layer_color);
|
||||
let by_block = logical_row(AcadColor::ByBlock, active_color, "ByBlock", None);
|
||||
let section1 = column![by_layer, by_block].spacing(2);
|
||||
|
||||
// 2. 45-swatch Quick Pick Grid (5 rows × 9 columns)
|
||||
|
||||
+13
-1
@@ -174,6 +174,14 @@ fn position_ribbon_dropdown<'a>(
|
||||
}
|
||||
|
||||
impl Ribbon {
|
||||
/// The current layer's colour: what ByLayer looks like for new objects.
|
||||
pub fn active_layer_color(&self) -> Option<Color> {
|
||||
self.layer_infos
|
||||
.iter()
|
||||
.find(|layer| layer.name == self.active_layer)
|
||||
.map(|layer| layer.color)
|
||||
}
|
||||
|
||||
/// The colour-book identity of the active colour, while the active colour
|
||||
/// is still the one picked from the book.
|
||||
pub fn active_color_name(&self) -> Option<String> {
|
||||
@@ -1232,7 +1240,11 @@ impl Ribbon {
|
||||
win: (f32, f32),
|
||||
recent_colors: &[AcadColor],
|
||||
) -> Option<Element<'_, Message>> {
|
||||
let panel = color_dropdown::color_dropdown_panel(self.active_color, recent_colors);
|
||||
let panel = color_dropdown::color_dropdown_panel(
|
||||
self.active_color,
|
||||
recent_colors,
|
||||
self.active_layer_color(),
|
||||
);
|
||||
|
||||
let (align_right, h_pad, top) =
|
||||
self.dd_anchor(PROP_COLOR_ID, color_dropdown::PANEL_W, win.0);
|
||||
|
||||
@@ -1167,7 +1167,12 @@ pub(super) fn render_large<'a>(item: &RibbonItem, ctx: &RenderCtx<'_>) -> Elemen
|
||||
.width(Length::Fixed(PROP_W))
|
||||
};
|
||||
|
||||
let (color_swatch, _) = acad_color_display(active_color);
|
||||
// ByLayer shows the current layer's colour.
|
||||
let color_swatch = layer_infos
|
||||
.iter()
|
||||
.find(|layer| layer.name == active_layer)
|
||||
.filter(|_| active_color == AcadColor::ByLayer)
|
||||
.map_or_else(|| acad_color_display(active_color).0, |layer| layer.color);
|
||||
let color_row = prop_row(
|
||||
crate::ui::color_select::color_display_name(active_color),
|
||||
PROP_COLOR_ID,
|
||||
|
||||
Reference in new issue
Block a user