Move egui layer to a separate DebugGuiStack structure
This commit is contained in:
parent
3f367e19ac
commit
92c0278ef0
5 changed files with 104 additions and 9 deletions
50
src/core/debug_gui.rs
Normal file
50
src/core/debug_gui.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use vulkano_util::renderer::VulkanoWindowRenderer;
|
||||
use winit::{event_loop::EventLoopWindowTarget, window::WindowId};
|
||||
|
||||
use crate::modules::graphics::egui::{Gui, GuiConfig};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DebugGuiStack {
|
||||
guis: HashMap<WindowId, Gui>,
|
||||
}
|
||||
|
||||
impl DebugGuiStack {
|
||||
pub fn add_gui<T>(
|
||||
&mut self,
|
||||
window_id: WindowId,
|
||||
event_loop: &EventLoopWindowTarget<T>,
|
||||
renderer: &VulkanoWindowRenderer,
|
||||
is_overlay: bool,
|
||||
allow_srgb_render_target: bool,
|
||||
) where
|
||||
T: Clone + Send + Sync,
|
||||
{
|
||||
let gui = Gui::new(
|
||||
event_loop,
|
||||
renderer.surface().clone(),
|
||||
renderer.graphics_queue().clone(),
|
||||
renderer.swapchain_format(),
|
||||
GuiConfig {
|
||||
is_overlay,
|
||||
allow_srgb_render_target,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
self.guis.insert(window_id, gui);
|
||||
}
|
||||
|
||||
pub fn remove_gui(&mut self, window_id: WindowId) {
|
||||
self.guis.remove(&window_id).unwrap();
|
||||
}
|
||||
|
||||
pub fn get(&mut self, window_id: WindowId) -> Option<&Gui> {
|
||||
self.guis.get(&window_id)
|
||||
}
|
||||
|
||||
pub fn get_mut(&mut self, window_id: WindowId) -> Option<&mut Gui> {
|
||||
self.guis.get_mut(&window_id)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue