mirror of
https://github.com/danbulant/cushy
synced 2026-06-19 14:31:04 +00:00
Stack/Grid exact-dimension scaling fix
This commit is contained in:
parent
7da5be6775
commit
34d1cf055e
2 changed files with 19 additions and 0 deletions
|
|
@ -97,6 +97,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
on the next cursor event.
|
||||
- `Scroll` no longer attempts to preserve scroll amounts using a percentage when
|
||||
its child changes size.
|
||||
- `Stack` and `Grid` now properly recompute exact-sized `Lp` children when the
|
||||
display scale is changed.
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ pub(crate) struct GridLayout {
|
|||
fractional: Vec<(LotId, u8)>,
|
||||
fit_to_content: Vec<LotId>,
|
||||
premeasured: Vec<LotId>,
|
||||
measured_scale: Fraction,
|
||||
pub orientation: Orientation,
|
||||
}
|
||||
|
||||
|
|
@ -300,6 +301,7 @@ impl GridLayout {
|
|||
fractional: Vec::new(),
|
||||
fit_to_content: Vec::new(),
|
||||
premeasured: Vec::new(),
|
||||
measured_scale: Fraction::ONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -389,6 +391,7 @@ impl GridLayout {
|
|||
scale: Fraction,
|
||||
mut measure: impl FnMut(usize, usize, Size<ConstraintLimit>, bool) -> Size<UPx>,
|
||||
) -> Size<UPx> {
|
||||
self.update_measured(scale);
|
||||
let (space_constraint, mut other_constraint) = self.orientation.split_size(available);
|
||||
let available_space = space_constraint.max();
|
||||
let known_gutters = gutter.saturating_mul(UPx::new(
|
||||
|
|
@ -534,6 +537,20 @@ impl GridLayout {
|
|||
self.orientation.make_size(measured, total_other)
|
||||
}
|
||||
|
||||
fn update_measured(&mut self, scale: Fraction) {
|
||||
if self.measured_scale != scale {
|
||||
self.measured_scale = scale;
|
||||
|
||||
for (spec, layout) in self.children.iter().zip(self.layouts.iter_mut()) {
|
||||
let GridDimension::Measured { size } = spec else {
|
||||
continue;
|
||||
};
|
||||
|
||||
layout.size = size.into_upx(scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn total_other(&self) -> UPx {
|
||||
self.others
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Reference in a new issue