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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user