mirror of
https://github.com/danbulant/cushy
synced 2026-07-06 11:40:37 +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.
|
on the next cursor event.
|
||||||
- `Scroll` no longer attempts to preserve scroll amounts using a percentage when
|
- `Scroll` no longer attempts to preserve scroll amounts using a percentage when
|
||||||
its child changes size.
|
its child changes size.
|
||||||
|
- `Stack` and `Grid` now properly recompute exact-sized `Lp` children when the
|
||||||
|
display scale is changed.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@ pub(crate) struct GridLayout {
|
||||||
fractional: Vec<(LotId, u8)>,
|
fractional: Vec<(LotId, u8)>,
|
||||||
fit_to_content: Vec<LotId>,
|
fit_to_content: Vec<LotId>,
|
||||||
premeasured: Vec<LotId>,
|
premeasured: Vec<LotId>,
|
||||||
|
measured_scale: Fraction,
|
||||||
pub orientation: Orientation,
|
pub orientation: Orientation,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,6 +301,7 @@ impl GridLayout {
|
||||||
fractional: Vec::new(),
|
fractional: Vec::new(),
|
||||||
fit_to_content: Vec::new(),
|
fit_to_content: Vec::new(),
|
||||||
premeasured: Vec::new(),
|
premeasured: Vec::new(),
|
||||||
|
measured_scale: Fraction::ONE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,6 +391,7 @@ impl GridLayout {
|
||||||
scale: Fraction,
|
scale: Fraction,
|
||||||
mut measure: impl FnMut(usize, usize, Size<ConstraintLimit>, bool) -> Size<UPx>,
|
mut measure: impl FnMut(usize, usize, Size<ConstraintLimit>, bool) -> Size<UPx>,
|
||||||
) -> Size<UPx> {
|
) -> Size<UPx> {
|
||||||
|
self.update_measured(scale);
|
||||||
let (space_constraint, mut other_constraint) = self.orientation.split_size(available);
|
let (space_constraint, mut other_constraint) = self.orientation.split_size(available);
|
||||||
let available_space = space_constraint.max();
|
let available_space = space_constraint.max();
|
||||||
let known_gutters = gutter.saturating_mul(UPx::new(
|
let known_gutters = gutter.saturating_mul(UPx::new(
|
||||||
|
|
@ -534,6 +537,20 @@ impl GridLayout {
|
||||||
self.orientation.make_size(measured, total_other)
|
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 {
|
fn total_other(&self) -> UPx {
|
||||||
self.others
|
self.others
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue