Tweak demo to work better on small screens (phones)

This commit is contained in:
Emil Ernerfeldt 2020-12-16 21:57:13 +01:00
parent 8af83bf93f
commit 56502405f5
4 changed files with 30 additions and 30 deletions

View file

@ -105,30 +105,36 @@ impl DemoWindows {
self.previous_link = env.link; 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"); ui.heading("✒ Egui Demo");
crate::demos::warn_if_debug_build(ui); 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.separator();
ui.heading(" Windows:"); ScrollArea::auto_sized().show(ui, |ui| {
ui.indent("windows", |ui| { ui.label("Egui is an immediate mode GUI library written in Rust.");
self.open_windows.checkboxes(ui); ui.add(
self.demos.checkboxes(ui); 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| { 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(); ui.ctx().memory().reset_areas();
} }
if ui if ui
.button("Clear entire Egui memory") .button("Clear Egui memory")
.on_hover_text("Forget scroll, collapsing headers etc") .on_hover_text("Forget scroll, collapsing headers etc")
.clicked .clicked
{ {
*ui.ctx().memory() = Default::default(); *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 { if let Some(time) = seconds_since_midnight {
let time = format!( let time = format!(

View file

@ -13,7 +13,7 @@ impl Default for FontBook {
standard: false, standard: false,
emojis: true, emojis: true,
filter: Default::default(), filter: Default::default(),
text_style: TextStyle::Heading, text_style: TextStyle::Button,
} }
} }
} }
@ -66,10 +66,9 @@ impl demos::View for FontBook {
ui.separator(); ui.separator();
ui.horizontal(|ui| { combo_box_with_label(ui, "Text style", format!("{:?}", self.text_style), |ui| {
ui.label("Text style:");
for style in TextStyle::all() { 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));
} }
}); });

View file

@ -52,7 +52,7 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) {
.small() .small()
.text_color(crate::color::RED), .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.");
} }
} }

View file

@ -35,7 +35,7 @@ impl Default for Widgets {
radio: Enum::First, radio: Enum::First,
count: 0, count: 0,
sliders: Default::default(), 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(), color: (Rgba::new(0.0, 1.0, 0.5, 1.0) * 0.75).into(),
single_line_text_input: "Hello World!".to_owned(), 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(), 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(),