forked from 1b-agent/opencadstudio-upstream
Select Color: gradient field fills the space under the sliders
The field no longer has a fixed height with a gap above it; it takes the height the sliders leave, so in CMYK it is just one slider row lower. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013rGmDUNr1hUf4zo1X3dak8
This commit is contained in:
1 file changed
+21
-11
@@ -16,6 +16,7 @@ const ROW_HEIGHT: f32 = 26.0;
|
|||||||
const TRACK: f32 = 18.0;
|
const TRACK: f32 = 18.0;
|
||||||
const STRIP_WIDTH: f32 = 22.0;
|
const STRIP_WIDTH: f32 = 22.0;
|
||||||
const ROW_GAP: f32 = 6.0;
|
const ROW_GAP: f32 = 6.0;
|
||||||
|
/// The field's height in the interface picker, which has no fixed height.
|
||||||
const FIELD_HEIGHT: f32 = 96.0;
|
const FIELD_HEIGHT: f32 = 96.0;
|
||||||
const MODE_WIDTH: f32 = 48.0;
|
const MODE_WIDTH: f32 = 48.0;
|
||||||
const MODE_HEIGHT: f32 = 24.0;
|
const MODE_HEIGHT: f32 = 24.0;
|
||||||
@@ -151,19 +152,28 @@ impl ColorEditor {
|
|||||||
|
|
||||||
/// `mode_end` sits at the far right of the mode buttons (the pipette);
|
/// `mode_end` sits at the far right of the mode buttons (the pipette);
|
||||||
/// `hex_end` at the far right of the hex row (the nearest index colour).
|
/// `hex_end` at the far right of the hex row (the nearest index colour).
|
||||||
/// With `fill` the field and hex row sit at the bottom of the space, so
|
/// With `fill` the field takes all the height the sliders leave, so the
|
||||||
/// they stay put when CMYK adds a fourth slider.
|
/// hex row stays at the bottom and CMYK's fourth slider only makes the
|
||||||
|
/// field a little lower.
|
||||||
pub fn view<'a>(
|
pub fn view<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
mode_end: Option<Element<'a, Message>>,
|
mode_end: Option<Element<'a, Message>>,
|
||||||
hex_end: Option<Element<'a, Message>>,
|
hex_end: Option<Element<'a, Message>>,
|
||||||
fill: bool,
|
fill: bool,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
let mut view = column![self.mode_row(mode_end), self.slider_rows()].spacing(12);
|
let height = if fill {
|
||||||
if fill {
|
Length::Fill
|
||||||
view = view.push(Space::new().height(Length::Fill));
|
} else {
|
||||||
}
|
Length::Fixed(FIELD_HEIGHT)
|
||||||
view.push(self.field()).push(self.hex_row(hex_end)).into()
|
};
|
||||||
|
column![
|
||||||
|
self.mode_row(mode_end),
|
||||||
|
self.slider_rows(),
|
||||||
|
self.field(height),
|
||||||
|
self.hex_row(hex_end),
|
||||||
|
]
|
||||||
|
.spacing(12)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RGB, HSB and CMYK, with `end` at the far right.
|
/// RGB, HSB and CMYK, with `end` at the far right.
|
||||||
@@ -270,21 +280,21 @@ impl ColorEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The saturation/brightness field with its hue strip.
|
/// The saturation/brightness field with its hue strip.
|
||||||
fn field<'a>(&self) -> Element<'a, Message> {
|
fn field<'a>(&self, height: Length) -> Element<'a, Message> {
|
||||||
let Hsb { h, s, b } = self.hsb;
|
let Hsb { h, s, b } = self.hsb;
|
||||||
let area = ColorArea::new(hsb_color(h, 1.0, 1.0), rgb_color(self.rgb), s, b, |s, b| {
|
let area = ColorArea::new(hsb_color(h, 1.0, 1.0), rgb_color(self.rgb), s, b, |s, b| {
|
||||||
msg(EditorMsg::Field(s, b))
|
msg(EditorMsg::Field(s, b))
|
||||||
})
|
})
|
||||||
.height(Length::Fixed(FIELD_HEIGHT));
|
.height(height);
|
||||||
// A vertical slider grows upwards; the strip runs red at the top.
|
// A vertical slider grows upwards; the strip runs red at the top.
|
||||||
let strip = stack![
|
let strip = stack![
|
||||||
container(Space::new())
|
container(Space::new())
|
||||||
.width(STRIP_WIDTH)
|
.width(STRIP_WIDTH)
|
||||||
.height(FIELD_HEIGHT)
|
.height(height)
|
||||||
.style(|_theme: &Theme| gradient_box(std::f32::consts::PI, &hue_stops())),
|
.style(|_theme: &Theme| gradient_box(std::f32::consts::PI, &hue_stops())),
|
||||||
vertical_slider(0.0..=360.0, 360.0 - h, |v| msg(EditorMsg::Hue(360.0 - v)))
|
vertical_slider(0.0..=360.0, 360.0 - h, |v| msg(EditorMsg::Hue(360.0 - v)))
|
||||||
.width(STRIP_WIDTH)
|
.width(STRIP_WIDTH)
|
||||||
.height(FIELD_HEIGHT)
|
.height(height)
|
||||||
.style(handle_style),
|
.style(handle_style),
|
||||||
];
|
];
|
||||||
row![area, strip].spacing(12).into()
|
row![area, strip].spacing(12).into()
|
||||||
|
|||||||
Reference in new issue
Block a user