1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 21:00:03 -04:00

eframe: rename quit/exit to "close" (#1943)

Since https://github.com/emilk/egui/pull/1919 we can continue
the application after closing the native window. It therefore makes
more sense to call `frame.close()` to close the native window,
instead of `frame.quit()`.
This commit is contained in:
Emil Ernerfeldt
2022-08-20 16:08:59 +02:00
committed by GitHub
parent 2453756782
commit 127931ba45
8 changed files with 59 additions and 41 deletions

View File

@@ -115,7 +115,7 @@ pub fn handle_app_output(
app_output: epi::backend::AppOutput,
) {
let epi::backend::AppOutput {
quit: _,
close: _,
window_size,
window_title,
decorated,
@@ -183,8 +183,8 @@ pub struct EpiIntegration {
pub egui_ctx: egui::Context,
pending_full_output: egui::FullOutput,
egui_winit: egui_winit::State,
/// When set, it is time to quit
quit: bool,
/// When set, it is time to close the native window.
close: bool,
can_drag_window: bool,
}
@@ -228,7 +228,7 @@ impl EpiIntegration {
egui_ctx,
egui_winit,
pending_full_output: Default::default(),
quit: false,
close: false,
can_drag_window: false,
}
}
@@ -243,17 +243,17 @@ impl EpiIntegration {
self.egui_ctx.clear_animations();
}
/// If `true`, it is time to shut down.
pub fn should_quit(&self) -> bool {
self.quit
/// If `true`, it is time to close the native window.
pub fn should_close(&self) -> bool {
self.close
}
pub fn on_event(&mut self, app: &mut dyn epi::App, event: &winit::event::WindowEvent<'_>) {
use winit::event::{ElementState, MouseButton, WindowEvent};
match event {
WindowEvent::CloseRequested => self.quit = app.on_exit_event(),
WindowEvent::Destroyed => self.quit = true,
WindowEvent::CloseRequested => self.close = app.on_close_event(),
WindowEvent::Destroyed => self.close = true,
WindowEvent::MouseInput {
button: MouseButton::Left,
state: ElementState::Pressed,
@@ -285,8 +285,8 @@ impl EpiIntegration {
let mut app_output = self.frame.take_app_output();
app_output.drag_window &= self.can_drag_window; // Necessary on Windows; see https://github.com/emilk/egui/pull/1108
self.can_drag_window = false;
if app_output.quit {
self.quit = app.on_exit_event();
if app_output.close {
self.close = app.on_close_event();
}
handle_app_output(window, self.egui_ctx.pixels_per_point(), app_output);
}

View File

@@ -373,7 +373,7 @@ mod glow_integration {
gl_window.swap_buffers().unwrap();
}
let control_flow = if integration.should_quit() {
let control_flow = if integration.should_close() {
EventResult::Exit
} else if repaint_after.is_zero() {
EventResult::RepaintAsap
@@ -426,7 +426,7 @@ mod glow_integration {
self.gl_window.resize(**new_inner_size);
}
winit::event::WindowEvent::CloseRequested
if self.integration.should_quit() =>
if self.integration.should_close() =>
{
return EventResult::Exit
}
@@ -435,7 +435,7 @@ mod glow_integration {
self.integration.on_event(self.app.as_mut(), &event);
if self.integration.should_quit() {
if self.integration.should_close() {
EventResult::Exit
} else {
// TODO(emilk): ask egui if the event warrants a repaint
@@ -624,7 +624,7 @@ mod wgpu_integration {
integration.post_rendering(app.as_mut(), window);
let control_flow = if integration.should_quit() {
let control_flow = if integration.should_close() {
EventResult::Exit
} else if repaint_after.is_zero() {
EventResult::RepaintAsap
@@ -690,7 +690,7 @@ mod wgpu_integration {
.on_window_resized(new_inner_size.width, new_inner_size.height);
}
winit::event::WindowEvent::CloseRequested
if self.integration.should_quit() =>
if self.integration.should_close() =>
{
return EventResult::Exit
}
@@ -698,7 +698,7 @@ mod wgpu_integration {
};
self.integration.on_event(self.app.as_mut(), &event);
if self.integration.should_quit() {
if self.integration.should_close() {
EventResult::Exit
} else {
// TODO(emilk): ask egui if the event warrants a repaint