From 550f3dcfa1a060e87799cd8e9e45f457b7ce9ad8 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 26 May 2020 08:44:48 +0200 Subject: [PATCH] [examples] fix fractal clock size --- emigui/src/examples/fractal_clock.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/emigui/src/examples/fractal_clock.rs b/emigui/src/examples/fractal_clock.rs index c53da8eda..6b5a5b52d 100644 --- a/emigui/src/examples/fractal_clock.rs +++ b/emigui/src/examples/fractal_clock.rs @@ -36,7 +36,7 @@ impl FractalClock { pub fn window(&mut self, ctx: &Arc, open: &mut bool) { Window::new("FractalClock") .open(open) - .default_rect(ctx.rect().expand(-40.0)) + .default_rect(ctx.rect().expand(-42.0)) .scroll(false) // Dark background frame to make it pop: .frame(Frame::window(&ctx.style()).fill(Some(color::black(250)))) @@ -51,7 +51,7 @@ impl FractalClock { .unwrap_or_else(|| ui.input().time); } - self.fractal_ui(ui); + self.fractal_ui(ui, ui.available_finite()); let frame = Frame::popup(ui.style()) .fill(Some(color::gray(34, 160))) @@ -60,6 +60,9 @@ impl FractalClock { frame.show(&mut ui.left_column(320.0), |ui| { CollapsingHeader::new("Settings").show(ui, |ui| self.options_ui(ui)); }); + + // Make sure we allocate what we used (everything) + ui.allocate_space(ui.available_finite().size()); } fn options_ui(&mut self, ui: &mut Ui) { @@ -94,7 +97,7 @@ impl FractalClock { ); } - fn fractal_ui(&mut self, ui: &mut Ui) { + fn fractal_ui(&mut self, ui: &mut Ui, rect: Rect) { struct Hand { length: f32, angle: f32, @@ -123,8 +126,6 @@ impl FractalClock { Hand::from_length_angle(0.5, angle_from_period(12.0 * 60.0 * 60.0)), ]; - let rect = ui.available_finite(); - let scale = self.zoom * rect.width().min(rect.height()); let mut paint_line = |points: [Pos2; 2], color: Color, width: f32| { let line = [