Browse Source

Clean up demo slightly

pull/649/head
Emil Ernerfeldt 3 years ago
parent
commit
5d0e348777
  1. 10
      egui_demo_lib/src/apps/demo/widget_gallery.rs
  2. 67
      egui_demo_lib/src/apps/demo/window_options.rs
  3. 2
      egui_demo_lib/src/backend_panel.rs

10
egui_demo_lib/src/apps/demo/widget_gallery.rs

@ -147,7 +147,7 @@ impl WidgetGallery {
});
ui.end_row();
ui.add(doc_link_label("Combo box", "ComboBox"));
ui.add(doc_link_label("ComboBox", "ComboBox"));
egui::ComboBox::from_label("Take your pick")
.selected_text(format!("{:?}", radio))
@ -162,6 +162,10 @@ impl WidgetGallery {
ui.add(egui::Slider::new(scalar, 0.0..=360.0).suffix("°"));
ui.end_row();
ui.add(doc_link_label("DragValue", "DragValue"));
ui.add(egui::DragValue::new(scalar).speed(1.0));
ui.end_row();
ui.add(doc_link_label("ProgressBar", "ProgressBar"));
let progress = *scalar / 360.0;
let progress_bar = egui::ProgressBar::new(progress)
@ -173,10 +177,6 @@ impl WidgetGallery {
.hovered();
ui.end_row();
ui.add(doc_link_label("DragValue", "DragValue"));
ui.add(egui::DragValue::new(scalar).speed(1.0));
ui.end_row();
ui.add(doc_link_label("Color picker", "color_edit"));
ui.color_edit_button_srgba(color);
ui.end_row();

67
egui_demo_lib/src/apps/demo/window_options.rs

@ -21,7 +21,7 @@ impl Default for WindowOptions {
title_bar: true,
closable: true,
collapsible: true,
resizable: true,
resizable: false,
scroll: false,
disabled_time: f64::NEG_INFINITY,
anchored: false,
@ -82,7 +82,7 @@ impl super::View for WindowOptions {
collapsible,
resizable,
scroll,
disabled_time,
disabled_time: _,
anchored,
anchor,
anchor_offset,
@ -92,39 +92,48 @@ impl super::View for WindowOptions {
ui.label("title:");
ui.text_edit_singleline(title);
});
ui.checkbox(title_bar, "title_bar");
ui.checkbox(closable, "closable");
ui.checkbox(collapsible, "collapsible");
ui.checkbox(resizable, "resizable");
ui.checkbox(scroll, "scroll");
ui.group(|ui| {
ui.checkbox(anchored, "anchored");
ui.set_enabled(*anchored);
ui.horizontal(|ui| {
ui.label("x:");
ui.selectable_value(&mut anchor.0[0], egui::Align::LEFT, "Left");
ui.selectable_value(&mut anchor.0[0], egui::Align::Center, "Center");
ui.selectable_value(&mut anchor.0[0], egui::Align::RIGHT, "Right");
});
ui.horizontal(|ui| {
ui.label("y:");
ui.selectable_value(&mut anchor.0[1], egui::Align::TOP, "Top");
ui.selectable_value(&mut anchor.0[1], egui::Align::Center, "Center");
ui.selectable_value(&mut anchor.0[1], egui::Align::BOTTOM, "Bottom");
ui.horizontal(|ui| {
ui.group(|ui| {
ui.vertical(|ui| {
ui.checkbox(title_bar, "title_bar");
ui.checkbox(closable, "closable");
ui.checkbox(collapsible, "collapsible");
ui.checkbox(resizable, "resizable");
ui.checkbox(scroll, "scroll");
});
});
ui.horizontal(|ui| {
ui.label("Offset:");
ui.add(egui::DragValue::new(&mut anchor_offset.x));
ui.add(egui::DragValue::new(&mut anchor_offset.y));
ui.group(|ui| {
ui.vertical(|ui| {
ui.checkbox(anchored, "anchored");
ui.set_enabled(*anchored);
ui.horizontal(|ui| {
ui.label("x:");
ui.selectable_value(&mut anchor.0[0], egui::Align::LEFT, "Left");
ui.selectable_value(&mut anchor.0[0], egui::Align::Center, "Center");
ui.selectable_value(&mut anchor.0[0], egui::Align::RIGHT, "Right");
});
ui.horizontal(|ui| {
ui.label("y:");
ui.selectable_value(&mut anchor.0[1], egui::Align::TOP, "Top");
ui.selectable_value(&mut anchor.0[1], egui::Align::Center, "Center");
ui.selectable_value(&mut anchor.0[1], egui::Align::BOTTOM, "Bottom");
});
ui.horizontal(|ui| {
ui.label("Offset:");
ui.add(egui::DragValue::new(&mut anchor_offset.x));
ui.add(egui::DragValue::new(&mut anchor_offset.y));
});
});
});
});
if ui.button("Disable for 2 seconds").clicked() {
*disabled_time = ui.input().time;
}
ui.separator();
ui.vertical_centered(|ui| {
ui.horizontal(|ui| {
if ui.button("Disable for 2 seconds").clicked() {
self.disabled_time = ui.input().time;
}
egui::reset_button(ui, self);
ui.add(crate::__egui_github_link_file!());
});

2
egui_demo_lib/src/backend_panel.rs

@ -145,7 +145,7 @@ impl BackendPanel {
ui.separator();
ui.label("egui windows");
ui.label("egui windows:");
self.egui_windows.checkboxes(ui);
ui.separator();

Loading…
Cancel
Save