1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Reduce indentation and simplify code

This commit is contained in:
Emil Ernerfeldt
2023-11-13 19:22:33 +01:00
parent 337da61c22
commit 719f2f1c63

View File

@@ -517,9 +517,9 @@ mod glow_integration {
) )
}; };
{
// This will only happen if the viewport is sync // This will only happen if the viewport is sync
// That means that the viewport cannot be rendered by itself and needs his parent to be rendered // That means that the viewport cannot be rendered by itself and needs his parent to be rendered
{
let glutin = glutin.borrow(); let glutin = glutin.borrow();
let viewport = &glutin.viewports[&viewport_id]; let viewport = &glutin.viewports[&viewport_id];
if viewport.viewport_ui_cb.is_none() && viewport_id != ViewportId::ROOT { if viewport.viewport_ui_cb.is_none() && viewport_id != ViewportId::ROOT {
@@ -532,16 +532,6 @@ mod glow_integration {
} }
} }
let egui::FullOutput {
platform_output,
textures_delta,
shapes,
viewports: viewports_out,
viewport_commands,
};
let control_flow;
{
let (raw_input, viewport_ui_cb) = { let (raw_input, viewport_ui_cb) = {
let mut glutin = glutin.borrow_mut(); let mut glutin = glutin.borrow_mut();
let viewport = glutin.viewports.get_mut(&viewport_id).unwrap(); let viewport = glutin.viewports.get_mut(&viewport_id).unwrap();
@@ -562,7 +552,9 @@ mod glow_integration {
let full_output = let full_output =
integration.update(app.as_mut(), viewport_ui_cb.as_deref(), raw_input); integration.update(app.as_mut(), viewport_ui_cb.as_deref(), raw_input);
egui::FullOutput { // ------------------------------------------------------------
let egui::FullOutput {
platform_output, platform_output,
textures_delta, textures_delta,
shapes, shapes,
@@ -570,8 +562,6 @@ mod glow_integration {
viewport_commands, viewport_commands,
} = full_output; } = full_output;
// ------------------------------------------------------------
let mut glutin = glutin.borrow_mut(); let mut glutin = glutin.borrow_mut();
let GlutinWindowContext { let GlutinWindowContext {
viewports, viewports,
@@ -676,12 +666,6 @@ mod glow_integration {
} }
} }
control_flow = if integration.should_close() {
EventResult::Exit
} else {
EventResult::Wait
};
integration.maybe_autosave(app.as_mut(), Some(window)); integration.maybe_autosave(app.as_mut(), Some(window));
if window.is_minimized() == Some(true) { if window.is_minimized() == Some(true) {
@@ -690,12 +674,11 @@ mod glow_integration {
crate::profile_scope!("minimized_sleep"); crate::profile_scope!("minimized_sleep");
std::thread::sleep(std::time::Duration::from_millis(10)); std::thread::sleep(std::time::Duration::from_millis(10));
} }
}
glutin.borrow_mut().process_viewport_builders(viewports_out); glutin.process_viewport_builders(viewports_out);
for (viewport_id, command) in viewport_commands { for (viewport_id, command) in viewport_commands {
if let Some(viewport) = glutin.borrow().viewports.get(&viewport_id) { if let Some(viewport) = glutin.viewports.get(&viewport_id) {
if let Some(window) = &viewport.window { if let Some(window) = &viewport.window {
let is_viewport_focused = focused_viewport == Some(viewport_id); let is_viewport_focused = focused_viewport == Some(viewport_id);
egui_winit::process_viewport_commands( egui_winit::process_viewport_commands(
@@ -707,7 +690,11 @@ mod glow_integration {
} }
} }
control_flow if integration.should_close() {
EventResult::Exit
} else {
EventResult::Wait
}
} }
} }