From 56502405f568aa80554862162cc68b4ea18c9ea0 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 16 Dec 2020 21:57:13 +0100 Subject: [PATCH] Tweak demo to work better on small screens (phones) --- egui/src/demos/demo_windows.rs | 49 +++++++++++++++++----------------- egui/src/demos/font_book.rs | 7 +++-- egui/src/demos/mod.rs | 2 +- egui/src/demos/widgets.rs | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/egui/src/demos/demo_windows.rs b/egui/src/demos/demo_windows.rs index 70c4ac08..67b9d1d3 100644 --- a/egui/src/demos/demo_windows.rs +++ b/egui/src/demos/demo_windows.rs @@ -105,30 +105,36 @@ impl DemoWindows { self.previous_link = env.link; } - crate::SidePanel::left("side_panel", 200.0).show(ctx, |ui| { + crate::SidePanel::left("side_panel", 190.0).show(ctx, |ui| { ui.heading("✒ Egui Demo"); crate::demos::warn_if_debug_build(ui); - ui.label("Egui is an immediate mode GUI library written in Rust."); - ui.add(crate::Hyperlink::new("https://github.com/emilk/egui").text(" Egui home page")); - - ui.label("Egui can be run on the web, or natively on 🐧"); - ui.separator(); - ui.label( - "This is an example of a panel. Windows are constrained to the area that remain.", - ); - if ui.button("Organize windows").clicked { - ui.ctx().memory().reset_areas(); - } ui.separator(); - ui.heading("S Windows:"); - ui.indent("windows", |ui| { - self.open_windows.checkboxes(ui); - self.demos.checkboxes(ui); + ScrollArea::auto_sized().show(ui, |ui| { + ui.label("Egui is an immediate mode GUI library written in Rust."); + ui.add( + crate::Hyperlink::new("https://github.com/emilk/egui").text(" Egui home page"), + ); + + ui.label("Egui can be run on the web, or natively on 🐧"); + + ui.separator(); + + ui.heading("Windows:"); + ui.indent("windows", |ui| { + self.open_windows.checkboxes(ui); + self.demos.checkboxes(ui); + }); + + ui.separator(); + + if ui.button("Organize windows").clicked { + ui.ctx().memory().reset_areas(); + } + + sidebar_ui(ui); }); - - sidebar_ui(ui); }); crate::TopPanel::top("menu_bar").show(ctx, |ui| { @@ -330,18 +336,13 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows, seconds_since_midnight: ui.ctx().memory().reset_areas(); } if ui - .button("Clear entire Egui memory") + .button("Clear Egui memory") .on_hover_text("Forget scroll, collapsing headers etc") .clicked { *ui.ctx().memory() = Default::default(); } }); - menu::menu(ui, "Windows", |ui| windows.checkboxes(ui)); - menu::menu(ui, "About", |ui| { - ui.label("This is Egui"); - ui.add(Hyperlink::new("https://github.com/emilk/egui").text(" Egui home page")); - }); if let Some(time) = seconds_since_midnight { let time = format!( diff --git a/egui/src/demos/font_book.rs b/egui/src/demos/font_book.rs index fdd3e8a8..a9dd5b73 100644 --- a/egui/src/demos/font_book.rs +++ b/egui/src/demos/font_book.rs @@ -13,7 +13,7 @@ impl Default for FontBook { standard: false, emojis: true, filter: Default::default(), - text_style: TextStyle::Heading, + text_style: TextStyle::Button, } } } @@ -66,10 +66,9 @@ impl demos::View for FontBook { ui.separator(); - ui.horizontal(|ui| { - ui.label("Text style:"); + combo_box_with_label(ui, "Text style", format!("{:?}", self.text_style), |ui| { for style in TextStyle::all() { - ui.radio_value(&mut self.text_style, style, format!("{:?}", style)); + ui.selectable_value(&mut self.text_style, style, format!("{:?}", style)); } }); diff --git a/egui/src/demos/mod.rs b/egui/src/demos/mod.rs index 5ead9200..544485fd 100644 --- a/egui/src/demos/mod.rs +++ b/egui/src/demos/mod.rs @@ -52,7 +52,7 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) { .small() .text_color(crate::color::RED), ) - .on_hover_text("Egui has detect that debug assertions are enabled."); + .on_hover_text("Egui was compiled with debug assertions enabled."); } } diff --git a/egui/src/demos/widgets.rs b/egui/src/demos/widgets.rs index a1042047..08fc98cc 100644 --- a/egui/src/demos/widgets.rs +++ b/egui/src/demos/widgets.rs @@ -35,7 +35,7 @@ impl Default for Widgets { radio: Enum::First, count: 0, sliders: Default::default(), - angle: TAU / 8.0, + angle: TAU / 3.0, color: (Rgba::new(0.0, 1.0, 0.5, 1.0) * 0.75).into(), single_line_text_input: "Hello World!".to_owned(), multiline_text_input: "Text can both be so wide that it needs a line break, but you can also add manual line break by pressing enter, creating new paragraphs.\nThis is the start of the next paragraph.\n\nClick me to edit me!".to_owned(),