mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 14:49:06 -04:00
eframe: Replace Frame::update with fn logic and fn ui (#7775)
* Part of https://github.com/emilk/egui/issues/5113 * Part of https://github.com/emilk/egui/issues/3524 ## What This deprecates `eframe::App::update` and replaces it with two new functions: ```rs pub trait App { /// Called just before `ui`, and in the future this will /// also be called for background apps when needed. fn logic(&mut self, ctx: &egui::Context, frame: &mut Frame) { } /// Show your user interface to the user. fn ui(&mut self, ui: &mut egui::Ui, frame: &mut Frame); … } ``` Similarly, `Context::run` is deprecated in favor of `Context::run_ui`. `Plugin`s are now handed a `Ui` instead of just a `Context` in `on_begin/end_frame`. ## TODO …either in this PR or a later one * [x] Deprecate `App::update` * [x] Deprecate `Context::run` * [x] Change plugins to get a `Ui` * [x] Update kittest * [x] Change viewports to get UI:s (`show_viewport_immediate` etc) - https://github.com/emilk/egui/pull/7779 ## Later PRs * [ ] Deprecate `Panel::show` * [ ] Deprecate `CentralPanel::show` * [ ] Deprecate `CentralPanel` ?
This commit is contained in:
@@ -23,16 +23,16 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("Try to close the window");
|
||||
});
|
||||
|
||||
if ctx.input(|i| i.viewport().close_requested()) {
|
||||
if ui.input(|i| i.viewport().close_requested()) {
|
||||
if self.allowed_to_close {
|
||||
// do nothing - we will close
|
||||
} else {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::CancelClose);
|
||||
self.show_confirmation_dialog = true;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ impl eframe::App for MyApp {
|
||||
egui::Window::new("Do you want to quit?")
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
.show(ui.ctx(), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("No").clicked() {
|
||||
self.show_confirmation_dialog = false;
|
||||
|
||||
@@ -43,8 +43,8 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
ui.label("The triangle is being painted using ");
|
||||
|
||||
@@ -86,8 +86,8 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("egui using custom fonts");
|
||||
ui.text_edit_multiline(&mut self.text);
|
||||
});
|
||||
|
||||
@@ -65,8 +65,8 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, content);
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::Window::new("Custom Keypad")
|
||||
.default_pos([100.0, 100.0])
|
||||
.title_bar(true)
|
||||
.show(ctx, |ui| {
|
||||
.show(ui.ctx(), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Your name: ");
|
||||
ui.text_edit_singleline(&mut self.name);
|
||||
@@ -60,7 +60,7 @@ impl eframe::App for MyApp {
|
||||
ui.label(format!("Hello '{}', age {}", self.name, self.age));
|
||||
});
|
||||
|
||||
self.keypad.show(ctx);
|
||||
self.keypad.show(ui.ctx());
|
||||
}
|
||||
|
||||
fn raw_input_hook(&mut self, ctx: &egui::Context, raw_input: &mut egui::RawInput) {
|
||||
|
||||
@@ -57,8 +57,8 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("egui using a customized style");
|
||||
ui.label("Switch between dark and light mode to see the different styles in action.");
|
||||
global_theme_preference_buttons(ui);
|
||||
|
||||
@@ -31,8 +31,8 @@ impl eframe::App for MyApp {
|
||||
egui::Rgba::TRANSPARENT.to_array() // Make sure we don't paint anything behind the rounded corners
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
custom_window_frame(ctx, "egui with custom frame", |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
custom_window_frame(ui.ctx(), "egui with custom frame", |ui| {
|
||||
ui.label("This is just the contents of the window.");
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("egui theme:");
|
||||
|
||||
@@ -44,8 +44,8 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("My External Eventloop Application");
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
@@ -82,7 +82,7 @@ impl eframe::App for MyApp {
|
||||
ui.label("Blinky!");
|
||||
});
|
||||
|
||||
ctx.request_repaint_after_secs((0.5 - (now % 0.5)) as f32);
|
||||
ui.request_repaint_after_secs((0.5 - (now % 0.5)) as f32);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("My External Eventloop Application");
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
@@ -86,7 +86,7 @@ impl eframe::App for MyApp {
|
||||
}
|
||||
if ui.button("Increment Later").clicked() {
|
||||
let value = self.value.clone();
|
||||
let ctx = ctx.clone();
|
||||
let ctx = ui.ctx().clone();
|
||||
tokio::task::spawn_local(async move {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
value.set(value.get() + 1);
|
||||
@@ -123,7 +123,7 @@ impl eframe::App for MyApp {
|
||||
ui.label("Blinky!");
|
||||
});
|
||||
|
||||
ctx.request_repaint_after_secs((0.5 - (now % 0.5)) as f32);
|
||||
ui.request_repaint_after_secs((0.5 - (now % 0.5)) as f32);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.label("Drag-and-drop files onto the window!");
|
||||
|
||||
if ui.button("Open file…").clicked()
|
||||
@@ -73,10 +73,10 @@ impl eframe::App for MyApp {
|
||||
}
|
||||
});
|
||||
|
||||
preview_files_being_dropped(ctx);
|
||||
preview_files_being_dropped(ui.ctx());
|
||||
|
||||
// Collect dropped files:
|
||||
ctx.input(|i| {
|
||||
ui.input(|i| {
|
||||
if !i.raw.dropped_files.is_empty() {
|
||||
self.dropped_files.clone_from(&i.raw.dropped_files);
|
||||
}
|
||||
|
||||
@@ -36,16 +36,16 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
// Reserve some space at the top so the demo ui isn't hidden behind the android status bar
|
||||
// TODO(lucasmerlin): This is a pretty big hack, should be fixed once safe_area implemented
|
||||
// for android:
|
||||
// https://github.com/rust-windowing/winit/issues/3910
|
||||
egui::Panel::top("status_bar_space").show(ctx, |ui| {
|
||||
egui::Panel::top("status_bar_space").show_inside(ui, |ui| {
|
||||
ui.set_height(32.0);
|
||||
});
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
self.demo.ui(ui);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("My egui Application");
|
||||
ui.horizontal(|ui| {
|
||||
let name_label = ui.label("Your name: ");
|
||||
|
||||
@@ -116,15 +116,15 @@ impl std::ops::Drop for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::Window::new("Main thread").show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::Window::new("Main thread").show(ui.ctx(), |ui| {
|
||||
if ui.button("Spawn another thread").clicked() {
|
||||
self.spawn_thread();
|
||||
}
|
||||
});
|
||||
|
||||
for (_handle, show_tx) in &self.threads {
|
||||
let _ = show_tx.send(ctx.clone());
|
||||
let _ = show_tx.send(ui.ctx().clone());
|
||||
}
|
||||
|
||||
for _ in 0..self.threads.len() {
|
||||
|
||||
@@ -15,8 +15,8 @@ fn main() -> eframe::Result {
|
||||
let mut name = "Arthur".to_owned();
|
||||
let mut age = 42;
|
||||
|
||||
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
eframe::run_ui_native("My egui App", options, move |ui, _frame| {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("My egui Application");
|
||||
ui.horizontal(|ui| {
|
||||
let name_label = ui.label("Your name: ");
|
||||
|
||||
@@ -24,8 +24,8 @@ fn main() -> eframe::Result {
|
||||
struct MyApp {}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
egui::ScrollArea::both().show(ui, |ui| {
|
||||
ui.image(egui::include_image!("cat.webp"))
|
||||
.on_hover_text_at_pointer("WebP");
|
||||
|
||||
@@ -20,8 +20,8 @@ struct Content {
|
||||
}
|
||||
|
||||
impl eframe::App for Content {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("Press/Hold/Release example. Press A to test.");
|
||||
if ui.button("Clear").clicked() {
|
||||
self.text.clear();
|
||||
@@ -33,14 +33,14 @@ impl eframe::App for Content {
|
||||
ui.label(&self.text);
|
||||
});
|
||||
|
||||
if ctx.input(|i| i.key_pressed(Key::A)) {
|
||||
if ui.input(|i| i.key_pressed(Key::A)) {
|
||||
self.text.push_str("\nPressed");
|
||||
}
|
||||
if ctx.input(|i| i.key_down(Key::A)) {
|
||||
if ui.input(|i| i.key_down(Key::A)) {
|
||||
self.text.push_str("\nHeld");
|
||||
ui.request_repaint(); // make sure we note the holding.
|
||||
}
|
||||
if ctx.input(|i| i.key_released(Key::A)) {
|
||||
if ui.input(|i| i.key_released(Key::A)) {
|
||||
self.text.push_str("\nReleased");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -35,8 +35,8 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.label("Hello from the root viewport");
|
||||
|
||||
ui.checkbox(
|
||||
@@ -61,7 +61,7 @@ impl eframe::App for MyApp {
|
||||
});
|
||||
|
||||
if self.show_immediate_viewport {
|
||||
ctx.show_viewport_immediate(
|
||||
ui.ctx().show_viewport_immediate(
|
||||
egui::ViewportId::from_hash_of("immediate_viewport"),
|
||||
egui::ViewportBuilder::default()
|
||||
.with_title("Immediate Viewport")
|
||||
@@ -87,7 +87,7 @@ impl eframe::App for MyApp {
|
||||
|
||||
if self.show_deferred_viewport.load(Ordering::Relaxed) {
|
||||
let show_deferred_viewport = self.show_deferred_viewport.clone();
|
||||
ctx.show_viewport_deferred(
|
||||
ui.ctx().show_viewport_deferred(
|
||||
egui::ViewportId::from_hash_of("deferred_viewport"),
|
||||
egui::ViewportBuilder::default()
|
||||
.with_title("Deferred Viewport")
|
||||
|
||||
@@ -18,8 +18,8 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
|
||||
CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut eframe::egui::Ui, _frame: &mut eframe::Frame) {
|
||||
CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.label("PopupCloseBehavior::CloseOnClick popup");
|
||||
ComboBox::from_label("ComboBox")
|
||||
.selected_text(format!("{}", self.number))
|
||||
|
||||
@@ -54,8 +54,8 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.heading("Example of how to use the puffin profiler with egui");
|
||||
ui.separator();
|
||||
|
||||
@@ -103,7 +103,7 @@ impl eframe::App for MyApp {
|
||||
});
|
||||
|
||||
if self.show_immediate_viewport {
|
||||
ctx.show_viewport_immediate(
|
||||
ui.ctx().show_viewport_immediate(
|
||||
egui::ViewportId::from_hash_of("immediate_viewport"),
|
||||
egui::ViewportBuilder::default()
|
||||
.with_title("Immediate Viewport")
|
||||
@@ -130,7 +130,7 @@ impl eframe::App for MyApp {
|
||||
|
||||
if self.show_deferred_viewport.load(Ordering::Relaxed) {
|
||||
let show_deferred_viewport = self.show_deferred_viewport.clone();
|
||||
ctx.show_viewport_deferred(
|
||||
ui.ctx().show_viewport_deferred(
|
||||
egui::ViewportId::from_hash_of("deferred_viewport"),
|
||||
egui::ViewportBuilder::default()
|
||||
.with_title("Deferred Viewport")
|
||||
|
||||
@@ -27,8 +27,8 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
if let Some(screenshot) = self.screenshot.take() {
|
||||
self.texture = Some(ui.ctx().load_texture(
|
||||
"screenshot",
|
||||
@@ -45,7 +45,7 @@ impl eframe::App for MyApp {
|
||||
|
||||
if ui.button("save to 'top_left.png'").clicked() {
|
||||
self.save_to_file = true;
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(Default::default()));
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Screenshot(Default::default()));
|
||||
}
|
||||
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::RIGHT), |ui| {
|
||||
@@ -54,17 +54,13 @@ impl eframe::App for MyApp {
|
||||
.add(egui::Label::new("hover me!").sense(egui::Sense::hover()))
|
||||
.hovered()
|
||||
{
|
||||
ctx.set_theme(egui::Theme::Dark);
|
||||
ui.ctx().set_theme(egui::Theme::Dark);
|
||||
} else {
|
||||
ctx.set_theme(egui::Theme::Light);
|
||||
ui.ctx().set_theme(egui::Theme::Light);
|
||||
}
|
||||
ctx.send_viewport_cmd(
|
||||
egui::ViewportCommand::Screenshot(Default::default()),
|
||||
);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Screenshot(Default::default()));
|
||||
} else if ui.button("take screenshot!").clicked() {
|
||||
ctx.send_viewport_cmd(
|
||||
egui::ViewportCommand::Screenshot(Default::default()),
|
||||
);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Screenshot(Default::default()));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -101,7 +97,7 @@ impl eframe::App for MyApp {
|
||||
}
|
||||
});
|
||||
|
||||
ctx.request_repaint();
|
||||
ui.request_repaint();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show_inside(ui, |ui| {
|
||||
let label_text = if self.has_next {
|
||||
"When this window is closed the next will be opened after a short delay"
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
|
||||
|
||||
use eframe::{CreationContext, NativeOptions, egui};
|
||||
use egui::{Button, CentralPanel, Context, UserAttentionType};
|
||||
use egui::{Button, CentralPanel, UserAttentionType};
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
@@ -55,12 +55,12 @@ impl Application {
|
||||
}
|
||||
|
||||
impl eframe::App for Application {
|
||||
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
if let Some(request_at) = self.request_at
|
||||
&& request_at < SystemTime::now()
|
||||
{
|
||||
self.request_at = None;
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(self.attention));
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(self.attention));
|
||||
if self.auto_reset {
|
||||
self.auto_reset = false;
|
||||
self.reset_at = Some(SystemTime::now() + Self::attention_reset_timeout());
|
||||
@@ -71,12 +71,12 @@ impl eframe::App for Application {
|
||||
&& reset_at < SystemTime::now()
|
||||
{
|
||||
self.reset_at = None;
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(
|
||||
UserAttentionType::Reset,
|
||||
));
|
||||
}
|
||||
|
||||
CentralPanel::default().show(ctx, |ui| {
|
||||
CentralPanel::default().show_inside(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Attention type:");
|
||||
@@ -131,6 +131,6 @@ impl eframe::App for Application {
|
||||
});
|
||||
});
|
||||
|
||||
ctx.request_repaint_after(Self::repaint_max_timeout());
|
||||
ui.request_repaint_after(Self::repaint_max_timeout());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user