Fix color palette width

Make palette rows fill the available panel width while reserving an embedded scrollbar lane. Keep the final row aligned with the 16-column grid.\n\nFixes #968
This commit is contained in:
Hakan Seven committed 2026-09-02 21:17:53 +03:00
1 parent 4247b0c953
commit 8c9ef80b90
1 file changed
+19 -7
+19 -7
View File
@@ -1556,12 +1556,13 @@ pub fn color_picker_dropdown<'a>(
// 9 standard ACI swatches (1-9) // 9 standard ACI swatches (1-9)
let standard: Element<'a, Message> = (1u8..=9u8) let standard: Element<'a, Message> = (1u8..=9u8)
.fold(row![].spacing(2), |r, idx| { .fold(row![].spacing(2).width(Length::Fill), |r, idx| {
let c = AcadColor::Index(idx); let c = AcadColor::Index(idx);
let (bg, _) = acad_color_display(c); let (bg, _) = acad_color_display(c);
let msg = on_aci(idx); let msg = on_aci(idx);
r.push( r.push(
button(text("").width(18).height(18)) button(text("").width(18).height(18))
.width(Length::FillPortion(1))
.on_press(msg) .on_press(msg)
.style(move |theme: &Theme, status| button::Style { .style(move |theme: &Theme, status| button::Style {
background: Some(Background::Color(bg)), background: Some(Background::Color(bg)),
@@ -1636,19 +1637,18 @@ pub fn color_picker_dropdown<'a>(
// Full ACI palette (expanded) // Full ACI palette (expanded)
if palette_open { if palette_open {
const COLS: u16 = 16; const COLS: u16 = 16;
let mut rows = column![].spacing(1); let mut rows = column![].spacing(1).width(Length::Fill);
let mut idx: u16 = 1; let mut idx: u16 = 1;
while idx <= 255 { while idx <= 255 {
let mut r = row![].spacing(1); let mut r = row![].spacing(1).width(Length::Fill);
for _ in 0..COLS { for _ in 0..COLS {
if idx > 255 { if idx <= 255 {
break;
}
let ci = idx as u8; let ci = idx as u8;
let (bg, _) = acad_color_display(AcadColor::Index(ci)); let (bg, _) = acad_color_display(AcadColor::Index(ci));
let msg = on_aci(ci); let msg = on_aci(ci);
r = r.push( r = r.push(
button(text("").width(12).height(12)) button(text("").width(12).height(12))
.width(Length::FillPortion(1))
.on_press(msg) .on_press(msg)
.style(move |theme: &Theme, status| button::Style { .style(move |theme: &Theme, status| button::Style {
background: Some(Background::Color(bg)), background: Some(Background::Color(bg)),
@@ -1671,11 +1671,23 @@ pub fn color_picker_dropdown<'a>(
.padding(0), .padding(0),
); );
idx += 1; idx += 1;
} else {
r = r.push(
Space::new()
.width(Length::FillPortion(1))
.height(12),
);
}
} }
rows = rows.push(r); rows = rows.push(r);
} }
col = col.push( col = col.push(
container(scrollable(rows).height(160)) container(
scrollable(rows)
.height(160)
.width(Length::Fill)
.spacing(2),
)
.style(|theme: &Theme| { .style(|theme: &Theme| {
let palette = theme.palette(); let palette = theme.palette();
container::Style { container::Style {