forked from 1b-agent/opencadstudio-upstream
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:
1 parent
4247b0c953
commit
8c9ef80b90
1 file changed
+45
-33
+45
-33
@@ -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,46 +1637,57 @@ 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 (bg, _) = acad_color_display(AcadColor::Index(ci));
|
||||||
|
let msg = on_aci(ci);
|
||||||
|
r = r.push(
|
||||||
|
button(text("").width(12).height(12))
|
||||||
|
.width(Length::FillPortion(1))
|
||||||
|
.on_press(msg)
|
||||||
|
.style(move |theme: &Theme, status| button::Style {
|
||||||
|
background: Some(Background::Color(bg)),
|
||||||
|
border: Border {
|
||||||
|
color: if matches!(status, button::Status::Hovered) {
|
||||||
|
theme.palette().primary.base.color
|
||||||
|
} else {
|
||||||
|
theme.palette().background.neutral.color
|
||||||
|
},
|
||||||
|
width: if matches!(status, button::Status::Hovered) {
|
||||||
|
1.5
|
||||||
|
} else {
|
||||||
|
1.0
|
||||||
|
},
|
||||||
|
radius: 1.0.into(),
|
||||||
|
},
|
||||||
|
text_color: theme.palette().background.base.text,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.padding(0),
|
||||||
|
);
|
||||||
|
idx += 1;
|
||||||
|
} else {
|
||||||
|
r = r.push(
|
||||||
|
Space::new()
|
||||||
|
.width(Length::FillPortion(1))
|
||||||
|
.height(12),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let ci = idx as u8;
|
|
||||||
let (bg, _) = acad_color_display(AcadColor::Index(ci));
|
|
||||||
let msg = on_aci(ci);
|
|
||||||
r = r.push(
|
|
||||||
button(text("").width(12).height(12))
|
|
||||||
.on_press(msg)
|
|
||||||
.style(move |theme: &Theme, status| button::Style {
|
|
||||||
background: Some(Background::Color(bg)),
|
|
||||||
border: Border {
|
|
||||||
color: if matches!(status, button::Status::Hovered) {
|
|
||||||
theme.palette().primary.base.color
|
|
||||||
} else {
|
|
||||||
theme.palette().background.neutral.color
|
|
||||||
},
|
|
||||||
width: if matches!(status, button::Status::Hovered) {
|
|
||||||
1.5
|
|
||||||
} else {
|
|
||||||
1.0
|
|
||||||
},
|
|
||||||
radius: 1.0.into(),
|
|
||||||
},
|
|
||||||
text_color: theme.palette().background.base.text,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.padding(0),
|
|
||||||
);
|
|
||||||
idx += 1;
|
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
|||||||
Reference in new issue
Block a user