oxide_engine/ui/egui_pass.rs
1//! egui render pass
2//!
3//! Provides helper functions for egui event handling.
4//! Note: Applications should use EguiManager's context directly for rendering
5//! due to wgpu version compatibility.
6
7use super::EguiManager;
8
9/// Handles a winit event and returns true if it was consumed by egui.
10pub fn handle_egui_event(
11 manager: &mut EguiManager,
12 window: &winit::window::Window,
13 event: &winit::event::WindowEvent,
14) -> bool {
15 let response = manager.winit_state.on_window_event(window, event);
16
17 // Check if egui wants to consume input
18 if manager.wants_pointer_input() || manager.wants_keyboard_input() {
19 response.consumed
20 } else {
21 false
22 }
23}
24
25/// Trait for implementing custom egui render passes.
26/// Implement this trait to render egui UI in your application.
27pub trait EguiRender {
28 /// Renders the egui UI. Called between begin_frame and end_frame.
29 fn show(&mut self, ctx: &egui::Context);
30}