mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Add Context::request_repaint_after (#1694)
This commit is contained in:
@@ -24,7 +24,7 @@ fn main() {
|
||||
let mut redraw = || {
|
||||
let mut quit = false;
|
||||
|
||||
let needs_repaint = egui_glium.run(&display, |egui_ctx| {
|
||||
let repaint_after = egui_glium.run(&display, |egui_ctx| {
|
||||
egui::SidePanel::left("my_side_panel").show(egui_ctx, |ui| {
|
||||
if ui
|
||||
.add(egui::Button::image_and_text(
|
||||
@@ -44,9 +44,13 @@ fn main() {
|
||||
|
||||
*control_flow = if quit {
|
||||
glutin::event_loop::ControlFlow::Exit
|
||||
} else if needs_repaint {
|
||||
} else if repaint_after.is_zero() {
|
||||
display.gl_window().window().request_redraw();
|
||||
glutin::event_loop::ControlFlow::Poll
|
||||
} else if let Some(repaint_after_instant) =
|
||||
std::time::Instant::now().checked_add(repaint_after)
|
||||
{
|
||||
glutin::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
|
||||
} else {
|
||||
glutin::event_loop::ControlFlow::Wait
|
||||
};
|
||||
@@ -85,6 +89,11 @@ fn main() {
|
||||
|
||||
display.gl_window().window().request_redraw(); // TODO(emilk): ask egui if the events warrants a repaint instead
|
||||
}
|
||||
glutin::event::Event::NewEvents(glutin::event::StartCause::ResumeTimeReached {
|
||||
..
|
||||
}) => {
|
||||
display.gl_window().window().request_redraw();
|
||||
}
|
||||
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ fn main() {
|
||||
let mut redraw = || {
|
||||
let mut quit = false;
|
||||
|
||||
let needs_repaint = egui_glium.run(&display, |egui_ctx| {
|
||||
let repaint_after = egui_glium.run(&display, |egui_ctx| {
|
||||
egui::SidePanel::left("my_side_panel").show(egui_ctx, |ui| {
|
||||
ui.heading("Hello World!");
|
||||
if ui.button("Quit").clicked() {
|
||||
@@ -25,9 +25,13 @@ fn main() {
|
||||
|
||||
*control_flow = if quit {
|
||||
glutin::event_loop::ControlFlow::Exit
|
||||
} else if needs_repaint {
|
||||
} else if repaint_after.is_zero() {
|
||||
display.gl_window().window().request_redraw();
|
||||
glutin::event_loop::ControlFlow::Poll
|
||||
} else if let Some(repaint_after_instant) =
|
||||
std::time::Instant::now().checked_add(repaint_after)
|
||||
{
|
||||
glutin::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
|
||||
} else {
|
||||
glutin::event_loop::ControlFlow::Wait
|
||||
};
|
||||
@@ -66,7 +70,11 @@ fn main() {
|
||||
|
||||
display.gl_window().window().request_redraw(); // TODO(emilk): ask egui if the events warrants a repaint instead
|
||||
}
|
||||
|
||||
glutin::event::Event::NewEvents(glutin::event::StartCause::ResumeTimeReached {
|
||||
..
|
||||
}) => {
|
||||
display.gl_window().window().request_redraw();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user