mirror of
https://github.com/hannobraun/Fornjot
synced 2025-08-19 15:46:14 +00:00
Support clearing the geometry in a window
This commit is contained in:
parent
ebf44582ab
commit
04b890f594
@ -224,6 +224,10 @@ impl Renderer {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_geometry(&mut self) {
|
||||||
|
self.geometries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// Resizes the render surface.
|
/// Resizes the render surface.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -130,6 +130,12 @@ impl WindowHandle {
|
|||||||
window_id: self.id,
|
window_id: self.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Clear the contents of the window
|
||||||
|
pub fn clear(&self) {
|
||||||
|
self.event_loop
|
||||||
|
.send_event(EventLoopEvent::Clear { window_id: self.id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -288,6 +294,22 @@ impl ApplicationHandler<EventLoopEvent> for Viewer {
|
|||||||
|
|
||||||
window.add_displayable(displayable);
|
window.add_displayable(displayable);
|
||||||
}
|
}
|
||||||
|
EventLoopEvent::Clear { window_id } => {
|
||||||
|
let Some(winit_window_id) = self.id_map.get(&window_id) else {
|
||||||
|
unreachable!(
|
||||||
|
"Mappings for all window IDs are created when handling \
|
||||||
|
the `Window` event."
|
||||||
|
);
|
||||||
|
};
|
||||||
|
let Some(window) = self.windows.get_mut(winit_window_id) else {
|
||||||
|
unreachable!(
|
||||||
|
"We never remove any windows, so it's not possible to \
|
||||||
|
have a mapping to an ID, but not a window with that ID."
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,4 +322,7 @@ enum EventLoopEvent {
|
|||||||
displayable: Displayable,
|
displayable: Displayable,
|
||||||
window_id: u64,
|
window_id: u64,
|
||||||
},
|
},
|
||||||
|
Clear {
|
||||||
|
window_id: u64,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,11 @@ impl Window {
|
|||||||
self.should_render = true;
|
self.should_render = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Clear the geometry displayed in the window
|
||||||
|
pub fn clear(&mut self) {
|
||||||
|
self.renderer.clear_geometry();
|
||||||
|
}
|
||||||
|
|
||||||
/// # Draw the window
|
/// # Draw the window
|
||||||
pub fn draw(&mut self) -> bool {
|
pub fn draw(&mut self) -> bool {
|
||||||
let size_is_invalid = {
|
let size_is_invalid = {
|
||||||
|
@ -56,6 +56,17 @@ impl DebugWindow {
|
|||||||
|
|
||||||
window.display_point(point);
|
window.display_point(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)] // occasionally useful for debugging
|
||||||
|
pub fn clear(&self) {
|
||||||
|
let inner = self.inner.lock().unwrap();
|
||||||
|
|
||||||
|
let DebugWindowInner::Initialized { window } = inner.deref() else {
|
||||||
|
panic!("Debug window has not been initialized.");
|
||||||
|
};
|
||||||
|
|
||||||
|
window.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DebugWindowInner {
|
enum DebugWindowInner {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user