1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

[demo] Move Fractal Clock to WrapApp

This commit is contained in:
Emil Ernerfeldt
2021-01-01 21:27:10 +01:00
parent b1022d01c1
commit 4848c171eb
10 changed files with 100 additions and 140 deletions

View File

@@ -137,11 +137,20 @@ impl TopPanel {
/// });
/// ```
#[derive(Default)]
pub struct CentralPanel {}
pub struct CentralPanel {
frame: Option<Frame>,
}
impl CentralPanel {
pub fn frame(mut self, frame: Frame) -> Self {
self.frame = Some(frame);
self
}
}
impl CentralPanel {
pub fn show<R>(self, ctx: &CtxRef, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Response) {
let Self {} = self;
let Self { frame } = self;
let panel_rect = ctx.available_rect();
@@ -151,7 +160,7 @@ impl CentralPanel {
let clip_rect = ctx.input().screen_rect();
let mut panel_ui = Ui::new(ctx.clone(), layer_id, id, panel_rect, clip_rect);
let frame = Frame::central_panel(&ctx.style());
let frame = frame.unwrap_or_else(|| Frame::central_panel(&ctx.style()));
let r = frame.show(&mut panel_ui, |ui| {
let r = add_contents(ui);
ui.expand_to_include_rect(ui.max_rect()); // Use it all