Select Color: frameless gradient button, hex beside H/S/B, all Options swatches

- The gradient mode button is just its gradient, without a frame.
- In the gradient view H, S and B sit on the left and Hex on the right
  of one row; the nearest index colour moves to the row below.
- Every colour swatch in Options opens the Select Color panel: the six
  theme colours, crosshair, snap marker and command line text join the
  three viewport backgrounds. BgTarget becomes UiColor, and one
  color_swatch helper replaces the four hand-built swatches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rGmDUNr1hUf4zo1X3dak8
This commit is contained in:
Claude committed 2026-10-12 18:33:23 +00:00
1 parent 0a28163ef5
commit c8c5f667f7
6 files changed
+102 -125

No files matched your search

+22 -76
View File
@@ -157,13 +157,12 @@ impl<T> fmt::Display for Labelled<T> {
}
}
/// A background swatch that opens the colour picker when clicked.
/// A colour swatch that opens the Select Color panel when clicked.
///
/// The picker sits alongside the hex field rather than replacing it: typing
/// The swatch sits beside the hex field rather than replacing it: typing
/// `#1E1E1E` stays the fastest way to reproduce an exact colour, while the
/// picker is for choosing one by eye.
fn bg_swatch_picker<'a>(target: crate::app::BgTarget, rgb: [u8; 3]) -> Element<'a, Message> {
let [r, g, b] = rgb;
/// panel is for choosing one by eye.
fn color_swatch<'a>(target: crate::app::UiColor, [r, g, b]: [u8; 3]) -> Element<'a, Message> {
let swatch = container(Space::new())
.width(28)
.height(22)
@@ -178,7 +177,7 @@ fn bg_swatch_picker<'a>(target: crate::app::BgTarget, rgb: [u8; 3]) -> Element<'
});
button(swatch)
.on_press(Message::OpenColorWindow(
crate::app::ColorPickTarget::Background(target),
crate::app::ColorPickTarget::Interface(target),
codec::types::Color::Rgb { r, g, b },
))
.padding(0)
@@ -298,18 +297,8 @@ pub fn view_window<'a>(
let mut color_controls = column![].spacing(8);
for (index, (label, color)) in colors.into_iter().enumerate() {
let swatch = container(Space::new())
.width(28)
.height(22)
.style(move |theme: &Theme| container::Style {
background: Some(Background::Color(color)),
border: Border {
color: theme.palette().background.strong.color,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
});
let [r, g, bl, _] = color.into_rgba8();
let swatch = color_swatch(crate::app::UiColor::Theme(index), [r, g, bl]);
color_controls = color_controls.push(
row![
text(label).size(12).width(110),
@@ -519,61 +508,18 @@ pub fn view_window<'a>(
.spacing(0)
.width(sizing.width);
let crosshair_rgb = crosshair_color.unwrap_or([255, 255, 255]);
let crosshair_swatch =
container(Space::new())
.width(28)
.height(22)
.style(move |theme: &Theme| container::Style {
background: Some(Background::Color(iced::Color::from_rgb8(
crosshair_rgb[0],
crosshair_rgb[1],
crosshair_rgb[2],
))),
border: Border {
color: theme.palette().background.strong.color,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
});
let command_rgb = command_text_color.unwrap_or([220, 220, 220]);
let command_swatch =
container(Space::new())
.width(28)
.height(22)
.style(move |theme: &Theme| container::Style {
background: Some(Background::Color(iced::Color::from_rgb8(
command_rgb[0],
command_rgb[1],
command_rgb[2],
))),
border: Border {
color: theme.palette().background.strong.color,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
});
let snap_rgb = snap_marker_color.unwrap_or([255, 230, 26]);
let snap_swatch = container(Space::new())
.width(28)
.height(22)
.style(move |theme: &Theme| container::Style {
background: Some(Background::Color(iced::Color::from_rgb8(
snap_rgb[0],
snap_rgb[1],
snap_rgb[2],
))),
border: Border {
color: theme.palette().background.strong.color,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
});
let crosshair_swatch = color_swatch(
crate::app::UiColor::Crosshair,
crosshair_color.unwrap_or([255, 255, 255]),
);
let command_swatch = color_swatch(
crate::app::UiColor::CommandText,
command_text_color.unwrap_or([220, 220, 220]),
);
let snap_swatch = color_swatch(
crate::app::UiColor::SnapMarker,
snap_marker_color.unwrap_or([255, 230, 26]),
);
let model_bg_rgb = model_space
.custom_bg
@@ -733,7 +679,7 @@ pub fn view_window<'a>(
display = display.push(Space::new().height(10)).push(
row![
text(crate::t!("Model background")).size(12).width(140),
bg_swatch_picker(crate::app::BgTarget::Model, model_bg_rgb),
color_swatch(crate::app::UiColor::ModelBackground, model_bg_rgb),
text_input("#RRGGBB", model_bg_input)
.on_input(Message::ModelSpaceBgChanged)
.width(150),
@@ -746,7 +692,7 @@ pub fn view_window<'a>(
display = display.push(Space::new().height(10)).push(
row![
text(crate::t!("Paper background")).size(12).width(140),
bg_swatch_picker(crate::app::BgTarget::Paper, paper_bg_rgb),
color_swatch(crate::app::UiColor::PaperBackground, paper_bg_rgb),
text_input("#RRGGBB", paper_bg_input)
.on_input(Message::PaperSpaceBgChanged)
.width(150),
@@ -758,7 +704,7 @@ pub fn view_window<'a>(
display = display.push(Space::new().height(10)).push(
row![
text(crate::t!("Desk surround")).size(12).width(140),
bg_swatch_picker(crate::app::BgTarget::Desk, desk_bg_rgb),
color_swatch(crate::app::UiColor::DeskBackground, desk_bg_rgb),
text_input("#RRGGBB", desk_bg_input)
.on_input(Message::DeskSpaceBgChanged)
.width(150),