From 47163c64f97e6a5e558db39a1a021ea942584e89 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Tue, 28 May 2019 20:32:35 -0700 Subject: [PATCH] Ensure that root sizing uses the window dimensions --- alchemy/src/window/window.rs | 5 ++++- lifecycle/src/reconciler/mod.rs | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/alchemy/src/window/window.rs b/alchemy/src/window/window.rs index 5d5bd5e..1bc95a7 100644 --- a/alchemy/src/window/window.rs +++ b/alchemy/src/window/window.rs @@ -51,7 +51,10 @@ impl AppWindow { } }; - match RENDER_ENGINE.diff_and_render_root(self.render_key, children) { + match RENDER_ENGINE.diff_and_render_root(self.render_key, ( + self.dimensions.2, + self.dimensions.3 + ), children) { Ok(_) => { } Err(e) => { eprintln!("Error rendering window! {}", e); } } diff --git a/lifecycle/src/reconciler/mod.rs b/lifecycle/src/reconciler/mod.rs index 8a9f810..e1bae24 100644 --- a/lifecycle/src/reconciler/mod.rs +++ b/lifecycle/src/reconciler/mod.rs @@ -88,7 +88,12 @@ impl RenderEngine { /// `Window`). Thus, for this one, we do some manual mucking with what we know is the /// root view (a `Window` or such root component would call this with it's registered /// `ComponentKey`), and then recurse based on the children. - pub fn diff_and_render_root(&self, key: ComponentKey, child: RSX) -> Result<(), Box> { + pub fn diff_and_render_root( + &self, + key: ComponentKey, + dimensions: (f64, f64), + child: RSX + ) -> Result<(), Box> { let mut component_store = self.components.lock().unwrap(); let mut layout_store = self.layouts.lock().unwrap(); @@ -114,16 +119,16 @@ impl RenderEngine { let mut style = Style::default(); THEME_ENGINE.configure_styles_for_keys(&root_instance.props.styles, &mut style, &mut root_instance.appearance); style.size = Size { - width: Dimension::Points(600.), - height: Dimension::Points(600.) + width: Dimension::Points(dimensions.0 as f32), + height: Dimension::Points(dimensions.1 as f32) }; layout_store.set_style(layout, style); layout }; layout_store.compute_layout(layout_node, Size { - width: Number::Defined(600.), - height: Number::Defined(600.) + width: Number::Defined(dimensions.0 as f32), + height: Number::Defined(dimensions.1 as f32) })?; walk_and_apply_styles(key, &mut component_store, &mut layout_store)?;