Small improvements to the demo (add source code links etc)
This commit is contained in:
parent
25d4a7e11e
commit
d6233de9dc
4 changed files with 40 additions and 20 deletions
|
@ -91,7 +91,7 @@ impl DemoWindows {
|
|||
/// Show the app ui (menu bar and windows).
|
||||
/// `sidebar_ui` can be used to optionally show some things in the sidebar
|
||||
pub fn ui(&mut self, ctx: &CtxRef) {
|
||||
egui::SidePanel::left("side_panel", 185.0).show(ctx, |ui| {
|
||||
egui::SidePanel::left("side_panel", 190.0).show(ctx, |ui| {
|
||||
ui.heading("✒ egui demos");
|
||||
|
||||
ui.separator();
|
||||
|
|
|
@ -34,7 +34,7 @@ impl super::Demo for PlotDemo {
|
|||
use super::View;
|
||||
Window::new(self.name())
|
||||
.open(open)
|
||||
.default_size(vec2(512.0, 512.0))
|
||||
.default_size(vec2(400.0, 400.0))
|
||||
.scroll(false)
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
|
@ -62,23 +62,29 @@ impl PlotDemo {
|
|||
ui.vertical(|ui| {
|
||||
ui.label("Circle:");
|
||||
ui.add(
|
||||
egui::Slider::f32(circle_radius, 1e-4..=1e4)
|
||||
.logarithmic(true)
|
||||
.smallest_positive(1e-2)
|
||||
.text("radius"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::f32(&mut circle_center.x, -1e4..=1e4)
|
||||
.logarithmic(true)
|
||||
.smallest_positive(1e-2)
|
||||
.text("center x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::f32(&mut circle_center.y, -1e4..=1e4)
|
||||
.logarithmic(true)
|
||||
.smallest_positive(1e-2)
|
||||
.text("center y"),
|
||||
egui::DragValue::f32(circle_radius)
|
||||
.speed(0.1)
|
||||
.clamp_range(0.0..=f32::INFINITY)
|
||||
// .logarithmic(true)
|
||||
// .smallest_positive(1e-2)
|
||||
.prefix("r: "),
|
||||
);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add(
|
||||
egui::DragValue::f32(&mut circle_center.x)
|
||||
.speed(0.1)
|
||||
// .logarithmic(true)
|
||||
// .smallest_positive(1e-2)
|
||||
.prefix("x: "),
|
||||
);
|
||||
ui.add(
|
||||
egui::DragValue::f32(&mut circle_center.y)
|
||||
.speed(1.0)
|
||||
// .logarithmic(true)
|
||||
// .smallest_positive(1e-2)
|
||||
.prefix("y: "),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -143,7 +149,7 @@ impl super::View for PlotDemo {
|
|||
.curve(self.circle())
|
||||
.curve(self.sin())
|
||||
.curve(self.thingy())
|
||||
.min_size(Vec2::new(400.0, 300.0));
|
||||
.min_size(Vec2::new(256.0, 200.0));
|
||||
if self.square {
|
||||
plot = plot.view_aspect(1.0);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ impl super::Demo for ManualLayoutTest {
|
|||
impl super::View for ManualLayoutTest {
|
||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
egui::reset_button(ui, self);
|
||||
|
||||
let Self {
|
||||
widget_offset,
|
||||
widget_size,
|
||||
|
@ -117,9 +118,12 @@ impl super::View for ManualLayoutTest {
|
|||
ui.add(egui::Slider::f32(&mut widget_size.y, 0.0..=400.0));
|
||||
ui.end_row();
|
||||
});
|
||||
|
||||
let widget_rect =
|
||||
egui::Rect::from_min_size(ui.min_rect().min + *widget_offset, *widget_size);
|
||||
|
||||
ui.add(crate::__egui_github_link_file!());
|
||||
|
||||
// Showing how to place a widget anywhere in the `Ui`:
|
||||
match *widget_type {
|
||||
WidgetType::Button => {
|
||||
|
@ -137,6 +141,7 @@ impl super::View for ManualLayoutTest {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct TableTest {
|
||||
num_cols: usize,
|
||||
num_rows: usize,
|
||||
|
@ -209,6 +214,11 @@ impl super::View for TableTest {
|
|||
ui.end_row();
|
||||
}
|
||||
});
|
||||
|
||||
ui.vertical_centered(|ui| {
|
||||
egui::reset_button(ui, self);
|
||||
ui.add(crate::__egui_github_link_file!());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,6 +248,10 @@ impl super::Demo for InputTest {
|
|||
|
||||
impl super::View for InputTest {
|
||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add(crate::__egui_github_link_file!());
|
||||
});
|
||||
|
||||
let response = ui.add(
|
||||
egui::Button::new("Click, double-click or drag me with any mouse button")
|
||||
.sense(egui::Sense::click_and_drag()),
|
||||
|
|
|
@ -125,7 +125,7 @@ impl WidgetGallery {
|
|||
ui.end_row();
|
||||
|
||||
ui.add(doc_link_label(
|
||||
"SelectableLabel:",
|
||||
"SelectableLabel",
|
||||
"selectable_value,SelectableLabel",
|
||||
));
|
||||
ui.horizontal(|ui| {
|
||||
|
|
Loading…
Reference in a new issue