forked from 1b-agent/opencadstudio-upstream
Merge pull request #1795 from MarcelP102/Select-Color-Redesign
[UX] Select Color redesign and feature parity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
843cbcd607
56 files changed
+4716
-606
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)
|
||||
|
||||
+31
-1
@@ -88,6 +88,9 @@ pub struct Ribbon {
|
||||
pub layer_filter: String,
|
||||
/// Active object color — ACI / ByLayer / ByBlock.
|
||||
pub active_color: AcadColor,
|
||||
/// Colour-book identity (`BOOK$NAME`) of a colour picked from a colour
|
||||
/// book, with the colour it was picked as; see `active_color_name`.
|
||||
pub active_color_book: Option<(AcadColor, String)>,
|
||||
/// Active linetype override ("ByLayer", "Continuous", …).
|
||||
pub active_linetype: String,
|
||||
/// Active lineweight.
|
||||
@@ -145,6 +148,14 @@ pub struct LayerInfo {
|
||||
pub vp_frozen: Option<(usize, bool)>,
|
||||
}
|
||||
|
||||
/// The colour of layer `name` in the ribbon's layer list.
|
||||
pub(super) fn layer_color(layers: &[LayerInfo], name: &str) -> Option<Color> {
|
||||
layers
|
||||
.iter()
|
||||
.find(|layer| layer.name == name)
|
||||
.map(|layer| layer.color)
|
||||
}
|
||||
|
||||
/// Full-screen backdrop for an open ribbon dropdown: closes the dropdown when
|
||||
/// the user clicks outside the panel. (Cursor motion leaking to the viewport
|
||||
/// beneath is blocked in `on_viewport_move`, not here — iced 0.14's mouse_area
|
||||
@@ -183,6 +194,20 @@ 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> {
|
||||
layer_color(&self.layer_infos, &self.active_layer)
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
self.active_color_book
|
||||
.as_ref()
|
||||
.filter(|(color, _)| *color == self.active_color)
|
||||
.map(|(_, name)| name.clone())
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
modules: all_ribbon_modules(),
|
||||
@@ -207,6 +232,7 @@ impl Ribbon {
|
||||
layer_infos: vec![],
|
||||
layer_filter: String::new(),
|
||||
active_color: AcadColor::ByLayer,
|
||||
active_color_book: None,
|
||||
active_linetype: "ByLayer".to_string(),
|
||||
active_lineweight: LineWeight::ByLayer,
|
||||
available_linetypes: vec![LinetypeItem {
|
||||
@@ -1293,7 +1319,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);
|
||||
|
||||
@@ -1193,7 +1193,10 @@ 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 = super::layer_color(layer_infos, active_layer)
|
||||
.filter(|_| active_color == AcadColor::ByLayer)
|
||||
.unwrap_or_else(|| acad_color_display(active_color).0);
|
||||
let color_row = prop_row(
|
||||
crate::ui::color_select::color_display_name(active_color),
|
||||
PROP_COLOR_ID,
|
||||
|
||||
Reference in new issue
Block a user