summaryrefslogtreecommitdiff
path: root/src/layout/fixed.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout/fixed.rs')
-rw-r--r--src/layout/fixed.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/layout/fixed.rs b/src/layout/fixed.rs
index 233c27f3..19876987 100644
--- a/src/layout/fixed.rs
+++ b/src/layout/fixed.rs
@@ -12,16 +12,37 @@ pub struct FixedNode {
}
impl Layout for FixedNode {
- fn layout(&self, ctx: &mut LayoutContext, regions: &Regions) -> Vec<Frame> {
+ fn layout(
+ &self,
+ ctx: &mut LayoutContext,
+ regions: &Regions,
+ ) -> Vec<Constrained<Frame>> {
let Regions { current, base, .. } = regions;
+ let mut constraints = Constraints::new(regions.expand);
+ constraints.set_base_using_linears(Spec::new(self.width, self.height), &regions);
+
let size = Size::new(
self.width.map_or(current.width, |w| w.resolve(base.width)),
self.height.map_or(current.height, |h| h.resolve(base.height)),
);
+ // If one dimension was not specified, the `current` size needs to remain static.
+ if self.width.is_none() {
+ constraints.exact.horizontal = Some(current.width);
+ }
+ if self.height.is_none() {
+ constraints.exact.vertical = Some(current.height);
+ }
+
let expand = Spec::new(self.width.is_some(), self.height.is_some());
let regions = Regions::one(size, expand);
- self.child.layout(ctx, &regions)
+ let mut frames = self.child.layout(ctx, &regions);
+
+ if let Some(frame) = frames.first_mut() {
+ frame.constraints = constraints;
+ }
+
+ frames
}
}