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