[demo] Refactor and minor cleanup
This commit is contained in:
parent
e82fb81f07
commit
6377a4231f
11 changed files with 147 additions and 116 deletions
|
@ -873,6 +873,11 @@ impl Context {
|
||||||
|
|
||||||
ui.shrink_width_to_current(); // don't let the text below grow this window wider
|
ui.shrink_width_to_current(); // don't let the text below grow this window wider
|
||||||
ui.label("NOTE: the position of this window cannot be reset from within itself.");
|
ui.label("NOTE: the position of this window cannot be reset from within itself.");
|
||||||
|
|
||||||
|
ui.collapsing("Interaction", |ui| {
|
||||||
|
let interaction = self.memory().interaction.clone();
|
||||||
|
interaction.ui(ui);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,3 +142,16 @@ impl Widget for &mut epaint::TessellationOptions {
|
||||||
.response
|
.response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Widget for &memory::Interaction {
|
||||||
|
fn ui(self, ui: &mut Ui) -> Response {
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.label(format!("click_id: {:?}", self.click_id));
|
||||||
|
ui.label(format!("drag_id: {:?}", self.drag_id));
|
||||||
|
ui.label(format!("drag_is_window: {:?}", self.drag_is_window));
|
||||||
|
ui.label(format!("click_interest: {:?}", self.click_interest));
|
||||||
|
ui.label(format!("drag_interest: {:?}", self.drag_interest));
|
||||||
|
})
|
||||||
|
.response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ epi = { version = "0.8.0", path = "../epi" }
|
||||||
|
|
||||||
# feature "http":
|
# feature "http":
|
||||||
image = { version = "0.23", default_features = false, features = ["jpeg", "png"], optional = true }
|
image = { version = "0.23", default_features = false, features = ["jpeg", "png"], optional = true }
|
||||||
syntect = { version = "4", default_features = false, features = ["default-fancy"], optional = true }
|
syntect = { version = "4", default_features = false, features = ["default-fancy"], optional = true } # optional syntax highlighting
|
||||||
|
|
||||||
# feature "persistence":
|
# feature "persistence":
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
|
|
|
@ -26,8 +26,21 @@ impl Default for DemoWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DemoWindow {
|
impl Demo for DemoWindow {
|
||||||
pub fn ui(&mut self, ui: &mut Ui) {
|
fn name(&self) -> &str {
|
||||||
|
"✨ Misc Demos"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show(&mut self, ctx: &CtxRef, open: &mut bool) {
|
||||||
|
Window::new(self.name())
|
||||||
|
.open(open)
|
||||||
|
.scroll(true)
|
||||||
|
.show(ctx, |ui| self.ui(ui));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl View for DemoWindow {
|
||||||
|
fn ui(&mut self, ui: &mut Ui) {
|
||||||
CollapsingHeader::new("Widgets")
|
CollapsingHeader::new("Widgets")
|
||||||
.default_open(true)
|
.default_open(true)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use egui::{CtxRef, Resize, ScrollArea, Ui, Window};
|
use egui::{CtxRef, ScrollArea, Ui, Window};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -16,11 +16,13 @@ impl Default for Demos {
|
||||||
Box::new(super::dancing_strings::DancingStrings::default()),
|
Box::new(super::dancing_strings::DancingStrings::default()),
|
||||||
Box::new(super::drag_and_drop::DragAndDropDemo::default()),
|
Box::new(super::drag_and_drop::DragAndDropDemo::default()),
|
||||||
Box::new(super::font_book::FontBook::default()),
|
Box::new(super::font_book::FontBook::default()),
|
||||||
|
Box::new(super::DemoWindow::default()),
|
||||||
Box::new(super::painting::Painting::default()),
|
Box::new(super::painting::Painting::default()),
|
||||||
Box::new(super::scrolling::Scrolling::default()),
|
Box::new(super::scrolling::Scrolling::default()),
|
||||||
Box::new(super::sliders::Sliders::default()),
|
Box::new(super::sliders::Sliders::default()),
|
||||||
Box::new(super::widget_gallery::WidgetGallery::default()),
|
Box::new(super::widget_gallery::WidgetGallery::default()),
|
||||||
Box::new(super::window_options::WindowOptions::default()),
|
Box::new(super::window_options::WindowOptions::default()),
|
||||||
|
Box::new(super::tests::WindowResizeTest::default()),
|
||||||
// Tests:
|
// Tests:
|
||||||
Box::new(super::tests::IdTest::default()),
|
Box::new(super::tests::IdTest::default()),
|
||||||
Box::new(super::tests::InputTest::default()),
|
Box::new(super::tests::InputTest::default()),
|
||||||
|
@ -70,7 +72,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", 200.0).show(ctx, |ui| {
|
egui::SidePanel::left("side_panel", 185.0).show(ctx, |ui| {
|
||||||
ui.heading("✒ egui demos");
|
ui.heading("✒ egui demos");
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
@ -86,10 +88,8 @@ impl DemoWindows {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
ui.heading("Windows:");
|
ui.heading("Windows:");
|
||||||
ui.indent("windows", |ui| {
|
self.demos.checkboxes(ui);
|
||||||
self.open_windows.checkboxes(ui);
|
self.open_windows.checkboxes(ui);
|
||||||
self.demos.checkboxes(ui);
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
|
@ -117,18 +117,10 @@ impl DemoWindows {
|
||||||
fn windows(&mut self, ctx: &CtxRef) {
|
fn windows(&mut self, ctx: &CtxRef) {
|
||||||
let Self {
|
let Self {
|
||||||
open_windows,
|
open_windows,
|
||||||
demo_window,
|
|
||||||
demos,
|
demos,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
Window::new("✨ Demo")
|
|
||||||
.open(&mut open_windows.demo)
|
|
||||||
.scroll(true)
|
|
||||||
.show(ctx, |ui| {
|
|
||||||
demo_window.ui(ui);
|
|
||||||
});
|
|
||||||
|
|
||||||
Window::new("🔧 Settings")
|
Window::new("🔧 Settings")
|
||||||
.open(&mut open_windows.settings)
|
.open(&mut open_windows.settings)
|
||||||
.scroll(true)
|
.scroll(true)
|
||||||
|
@ -151,61 +143,6 @@ impl DemoWindows {
|
||||||
});
|
});
|
||||||
|
|
||||||
demos.show(ctx);
|
demos.show(ctx);
|
||||||
|
|
||||||
self.resize_windows(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn resize_windows(&mut self, ctx: &CtxRef) {
|
|
||||||
let open = &mut self.open_windows.resize;
|
|
||||||
|
|
||||||
Window::new("resizable")
|
|
||||||
.open(open)
|
|
||||||
.scroll(false)
|
|
||||||
.resizable(true)
|
|
||||||
.show(ctx, |ui| {
|
|
||||||
ui.label("scroll: NO");
|
|
||||||
ui.label("resizable: YES");
|
|
||||||
ui.label(crate::LOREM_IPSUM);
|
|
||||||
});
|
|
||||||
|
|
||||||
Window::new("resizable + embedded scroll")
|
|
||||||
.open(open)
|
|
||||||
.scroll(false)
|
|
||||||
.resizable(true)
|
|
||||||
.default_height(300.0)
|
|
||||||
.show(ctx, |ui| {
|
|
||||||
ui.label("scroll: NO");
|
|
||||||
ui.label("resizable: YES");
|
|
||||||
ui.heading("We have a sub-region with scroll bar:");
|
|
||||||
ScrollArea::auto_sized().show(ui, |ui| {
|
|
||||||
ui.label(crate::LOREM_IPSUM_LONG);
|
|
||||||
ui.label(crate::LOREM_IPSUM_LONG);
|
|
||||||
});
|
|
||||||
// ui.heading("Some additional text here, that should also be visible"); // this works, but messes with the resizing a bit
|
|
||||||
});
|
|
||||||
|
|
||||||
Window::new("resizable + scroll")
|
|
||||||
.open(open)
|
|
||||||
.scroll(true)
|
|
||||||
.resizable(true)
|
|
||||||
.default_height(300.0)
|
|
||||||
.show(ctx, |ui| {
|
|
||||||
ui.label("scroll: YES");
|
|
||||||
ui.label("resizable: YES");
|
|
||||||
ui.label(crate::LOREM_IPSUM_LONG);
|
|
||||||
});
|
|
||||||
|
|
||||||
Window::new("auto_sized")
|
|
||||||
.open(open)
|
|
||||||
.auto_sized()
|
|
||||||
.show(ctx, |ui| {
|
|
||||||
ui.label("This window will auto-size based on its contents.");
|
|
||||||
ui.heading("Resize this area:");
|
|
||||||
Resize::default().show(ui, |ui| {
|
|
||||||
ui.label(crate::LOREM_IPSUM);
|
|
||||||
});
|
|
||||||
ui.heading("Resize the above area!");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,54 +150,39 @@ impl DemoWindows {
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct OpenWindows {
|
struct OpenWindows {
|
||||||
demo: bool,
|
|
||||||
|
|
||||||
// egui stuff:
|
// egui stuff:
|
||||||
settings: bool,
|
settings: bool,
|
||||||
inspection: bool,
|
inspection: bool,
|
||||||
memory: bool,
|
memory: bool,
|
||||||
resize: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OpenWindows {
|
impl Default for OpenWindows {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
OpenWindows::none()
|
||||||
demo: true,
|
|
||||||
..OpenWindows::none()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpenWindows {
|
impl OpenWindows {
|
||||||
fn none() -> Self {
|
fn none() -> Self {
|
||||||
Self {
|
Self {
|
||||||
demo: false,
|
|
||||||
|
|
||||||
settings: false,
|
settings: false,
|
||||||
inspection: false,
|
inspection: false,
|
||||||
memory: false,
|
memory: false,
|
||||||
resize: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn checkboxes(&mut self, ui: &mut Ui) {
|
fn checkboxes(&mut self, ui: &mut Ui) {
|
||||||
let Self {
|
let Self {
|
||||||
demo,
|
|
||||||
settings,
|
settings,
|
||||||
inspection,
|
inspection,
|
||||||
memory,
|
memory,
|
||||||
resize,
|
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
ui.label("egui:");
|
ui.label("egui:");
|
||||||
ui.checkbox(settings, "🔧 Settings");
|
ui.checkbox(settings, "🔧 Settings");
|
||||||
ui.checkbox(inspection, "🔍 Inspection");
|
ui.checkbox(inspection, "🔍 Inspection");
|
||||||
ui.checkbox(memory, "📝 Memory");
|
ui.checkbox(memory, "📝 Memory");
|
||||||
ui.separator();
|
|
||||||
ui.checkbox(demo, "✨ Demo");
|
|
||||||
ui.separator();
|
|
||||||
ui.checkbox(resize, "↔ Resize examples");
|
|
||||||
ui.separator();
|
|
||||||
ui.label("Misc:");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ use egui::{color::*, *};
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "persistence", serde(default))]
|
||||||
|
#[derive(PartialEq)]
|
||||||
pub struct Scrolling {
|
pub struct Scrolling {
|
||||||
track_item: usize,
|
track_item: usize,
|
||||||
tack_item_align: Align,
|
tack_item_align: Align,
|
||||||
|
@ -36,14 +37,6 @@ impl super::Demo for Scrolling {
|
||||||
|
|
||||||
impl super::View for Scrolling {
|
impl super::View for Scrolling {
|
||||||
fn ui(&mut self, ui: &mut Ui) {
|
fn ui(&mut self, ui: &mut Ui) {
|
||||||
ScrollArea::from_max_height(200.0)
|
|
||||||
.id_source("lorem_ipsum_scroll_area")
|
|
||||||
.show(ui, |ui| {
|
|
||||||
ui.label(crate::LOREM_IPSUM_LONG);
|
|
||||||
ui.label(crate::LOREM_IPSUM_LONG);
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.separator();
|
|
||||||
ui.label("This shows how you can scroll to a specific item or pixel offset");
|
ui.label("This shows how you can scroll to a specific item or pixel offset");
|
||||||
|
|
||||||
let mut track_item = false;
|
let mut track_item = false;
|
||||||
|
@ -88,6 +81,7 @@ impl super::View for Scrolling {
|
||||||
scroll_area = scroll_area.scroll_offset(self.offset);
|
scroll_area = scroll_area.scroll_offset(self.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
let (current_scroll, max_scroll) = scroll_area.show(ui, |ui| {
|
let (current_scroll, max_scroll) = scroll_area.show(ui, |ui| {
|
||||||
if scroll_top {
|
if scroll_top {
|
||||||
ui.scroll_to_cursor(Align::TOP);
|
ui.scroll_to_cursor(Align::TOP);
|
||||||
|
@ -95,10 +89,11 @@ impl super::View for Scrolling {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
for item in 1..=50 {
|
for item in 1..=50 {
|
||||||
if track_item && item == self.track_item {
|
if track_item && item == self.track_item {
|
||||||
let response = ui.colored_label(Color32::YELLOW, format!("Item {}", item));
|
let response =
|
||||||
|
ui.colored_label(Color32::YELLOW, format!("This is item {}", item));
|
||||||
response.scroll_to_me(self.tack_item_align);
|
response.scroll_to_me(self.tack_item_align);
|
||||||
} else {
|
} else {
|
||||||
ui.label(format!("Item {}", item));
|
ui.label(format!("This is item {}", item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -113,10 +108,17 @@ impl super::View for Scrolling {
|
||||||
let max_scroll = ui.min_rect().height() - ui.clip_rect().height() + 2.0 * margin;
|
let max_scroll = ui.min_rect().height() - ui.clip_rect().height() + 2.0 * margin;
|
||||||
(current_scroll, max_scroll)
|
(current_scroll, max_scroll)
|
||||||
});
|
});
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
ui.colored_label(
|
ui.label(format!(
|
||||||
Color32::WHITE,
|
"Scroll offset: {:.0}/{:.0} px",
|
||||||
format!("{:.0}/{:.0} px", current_scroll, max_scroll),
|
current_scroll, max_scroll
|
||||||
);
|
));
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.vertical_centered(|ui| {
|
||||||
|
egui::reset_button(ui, self);
|
||||||
|
ui.add(crate::__egui_github_link_file!());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,9 @@ impl super::View for Sliders {
|
||||||
ui.label("Smart Aim will guide you towards round values when you drag the slider so you you are more likely to hit 250 than 247.23");
|
ui.label("Smart Aim will guide you towards round values when you drag the slider so you you are more likely to hit 250 than 247.23");
|
||||||
ui.advance_cursor(8.0);
|
ui.advance_cursor(8.0);
|
||||||
|
|
||||||
egui::reset_button(ui, self);
|
ui.vertical_centered(|ui| {
|
||||||
|
egui::reset_button(ui, self);
|
||||||
|
ui.add(crate::__egui_github_link_file!());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,3 +266,68 @@ impl super::View for InputTest {
|
||||||
ui.label(&self.info);
|
ui.label(&self.info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct WindowResizeTest {}
|
||||||
|
|
||||||
|
impl super::Demo for WindowResizeTest {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"↔ Window Resize"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
|
||||||
|
use egui::*;
|
||||||
|
|
||||||
|
Window::new("↔ resizable")
|
||||||
|
.open(open)
|
||||||
|
.scroll(false)
|
||||||
|
.resizable(true)
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
assert!(ui.enabled()); // TODO: remove
|
||||||
|
ui.label("scroll: NO");
|
||||||
|
ui.label("resizable: YES");
|
||||||
|
ui.label(crate::LOREM_IPSUM);
|
||||||
|
});
|
||||||
|
|
||||||
|
Window::new("↔ resizable + embedded scroll")
|
||||||
|
.open(open)
|
||||||
|
.scroll(false)
|
||||||
|
.resizable(true)
|
||||||
|
.default_height(300.0)
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label("scroll: NO");
|
||||||
|
ui.label("resizable: YES");
|
||||||
|
ui.heading("We have a sub-region with scroll bar:");
|
||||||
|
ScrollArea::auto_sized().show(ui, |ui| {
|
||||||
|
ui.label(crate::LOREM_IPSUM_LONG);
|
||||||
|
ui.label(crate::LOREM_IPSUM_LONG);
|
||||||
|
});
|
||||||
|
// ui.heading("Some additional text here, that should also be visible"); // this works, but messes with the resizing a bit
|
||||||
|
});
|
||||||
|
|
||||||
|
Window::new("↔ resizable + scroll")
|
||||||
|
.open(open)
|
||||||
|
.scroll(true)
|
||||||
|
.resizable(true)
|
||||||
|
.default_height(300.0)
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label("scroll: YES");
|
||||||
|
ui.label("resizable: YES");
|
||||||
|
ui.label(crate::LOREM_IPSUM_LONG);
|
||||||
|
});
|
||||||
|
|
||||||
|
Window::new("↔ auto_sized")
|
||||||
|
.open(open)
|
||||||
|
.auto_sized()
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label("This window will auto-size based on its contents.");
|
||||||
|
ui.heading("Resize this area:");
|
||||||
|
Resize::default().show(ui, |ui| {
|
||||||
|
ui.label(crate::LOREM_IPSUM);
|
||||||
|
});
|
||||||
|
ui.heading("Resize the above area!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl Default for Enum {
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "persistence", serde(default))]
|
||||||
pub struct Widgets {
|
pub struct Widgets {
|
||||||
button_enabled: bool,
|
group_enabled: bool,
|
||||||
count: usize,
|
count: usize,
|
||||||
radio: Enum,
|
radio: Enum,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
|
@ -30,7 +30,7 @@ pub struct Widgets {
|
||||||
impl Default for Widgets {
|
impl Default for Widgets {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
button_enabled: true,
|
group_enabled: true,
|
||||||
radio: Enum::First,
|
radio: Enum::First,
|
||||||
count: 0,
|
count: 0,
|
||||||
angle: std::f32::consts::TAU / 3.0,
|
angle: std::f32::consts::TAU / 3.0,
|
||||||
|
@ -78,6 +78,8 @@ impl Widgets {
|
||||||
.on_hover_ui(tooltip_ui);
|
.on_hover_ui(tooltip_ui);
|
||||||
|
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
|
ui.checkbox(&mut self.group_enabled, "Group enabled");
|
||||||
|
ui.set_enabled(self.group_enabled);
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.radio_value(&mut self.radio, Enum::First, "First");
|
ui.radio_value(&mut self.radio, Enum::First, "First");
|
||||||
ui.radio_value(&mut self.radio, Enum::Second, "Second");
|
ui.radio_value(&mut self.radio, Enum::Second, "Second");
|
||||||
|
@ -91,11 +93,9 @@ impl Widgets {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.checkbox(&mut self.button_enabled, "Button enabled");
|
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(Button::new("Click me").enabled(self.button_enabled))
|
.button("Click me")
|
||||||
.on_hover_text("This will just increase a counter.")
|
.on_hover_text("This will just increase a counter.")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,8 +63,6 @@ impl super::Demo for WindowOptions {
|
||||||
|
|
||||||
impl super::View for WindowOptions {
|
impl super::View for WindowOptions {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
egui::reset_button(ui, self);
|
|
||||||
|
|
||||||
let Self {
|
let Self {
|
||||||
title,
|
title,
|
||||||
title_bar,
|
title_bar,
|
||||||
|
@ -84,12 +82,14 @@ impl super::View for WindowOptions {
|
||||||
ui.checkbox(collapsible, "collapsible");
|
ui.checkbox(collapsible, "collapsible");
|
||||||
ui.checkbox(resizable, "resizable");
|
ui.checkbox(resizable, "resizable");
|
||||||
ui.checkbox(scroll, "scroll");
|
ui.checkbox(scroll, "scroll");
|
||||||
ui.vertical_centered(|ui| {
|
|
||||||
ui.add(crate::__egui_github_link_file!());
|
|
||||||
});
|
|
||||||
|
|
||||||
if ui.button("Disable for 2 seconds").clicked() {
|
if ui.button("Disable for 2 seconds").clicked() {
|
||||||
*disabled_time = ui.input().time;
|
*disabled_time = ui.input().time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.vertical_centered(|ui| {
|
||||||
|
egui::reset_button(ui, self);
|
||||||
|
ui.add(crate::__egui_github_link_file!());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,15 @@ impl epi::App for WrapApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn warm_up_enabled(&self) -> bool {
|
fn warm_up_enabled(&self) -> bool {
|
||||||
true // The example windows use a lot of emojis. Pre-cache them by running one frame where everything is open.
|
// The example windows use a lot of emojis. Pre-cache them by running one frame where everything is open
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
false // debug
|
||||||
|
}
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
{
|
||||||
|
true // release
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, ctx: &egui::CtxRef, frame: &mut epi::Frame<'_>) {
|
fn update(&mut self, ctx: &egui::CtxRef, frame: &mut epi::Frame<'_>) {
|
||||||
|
|
Loading…
Reference in a new issue