pub struct DebugUi { /* private fields */ }Expand description
An immediate-mode debug UI: each frame, code calls a window and its widgets, and each widget says what was done to it. It keeps what lasts from frame to frame: which widget is held, which text field has the keyboard, the windows’ places and which tree nodes are open.
Each frame: DebugUi::frame takes the frame’s input, its windows are
filled with Frame::window, and Frame::finish pushes what they
draw into a UiList (RenderFrame::ui), after the game’s UI and in
front of it.
Implementations§
Source§impl DebugUi
impl DebugUi
Sourcepub fn new(
font: Handle<Font>,
metrics: impl TextMetrics + 'static,
white: Handle<Texture>,
) -> Self
pub fn new( font: Handle<Font>, metrics: impl TextMetrics + 'static, white: Handle<Texture>, ) -> Self
A debug UI that draws its text in font, measured by metrics
(for a font loaded in the game, FontMetrics of a copy of it), and
its boxes with white, a texture whose texels are white.
Sourcepub fn set_font(
&mut self,
font: Handle<Font>,
metrics: impl TextMetrics + 'static,
)
pub fn set_font( &mut self, font: Handle<Font>, metrics: impl TextMetrics + 'static, )
Draws with another font from the next frame: after the font was reloaded, say.
Sourcepub fn style_mut(&mut self) -> &mut Style
pub fn style_mut(&mut self) -> &mut Style
Its look, to change: its scale, the settings’ UI scale, among it.
Sourcepub fn wants_mouse(&self) -> bool
pub fn wants_mouse(&self) -> bool
Whether the pointer is the debug UI’s: over a window it drew in the last frame, or holding one of its widgets. The game should then leave the mouse alone. A press on a window is the debug UI’s until its release, wherever the pointer goes, and one that started outside every window the game’s, over a window or not.
Sourcepub fn is_over(&self, at: Vec2) -> bool
pub fn is_over(&self, at: Vec2) -> bool
Whether at, in the output’s pixels as nadir_input::Input::pointer
gives them, is over a window or an open combo’s list drawn in the
last frame, by the space that frame was laid out in.
DebugUi::wants_mouse is where the pointer was when the last frame
ended. This is for an engine that feeds the game’s input an event at
a time and decides at each press, or each turn of the wheel, whether
the game sees it: then a press in the frame the pointer comes over a
window is the UI’s, and one in the frame it leaves the game’s.
Sourcepub fn wants_keyboard(&self) -> bool
pub fn wants_keyboard(&self) -> bool
Whether a text field drawn in the last frame has the keyboard: the game should then leave the keys alone.
Sourcepub fn places(&self) -> impl ExactSizeIterator<Item = WindowPlace<'_>> + '_
pub fn places(&self) -> impl ExactSizeIterator<Item = WindowPlace<'_>> + '_
Every window known, drawn or not, each with its place: for saving them. A window’s name is its explicit ID or its title.
Sourcepub fn set_place(&mut self, title: &str, rect: Rect, collapsed: bool)
pub fn set_place(&mut self, title: &str, rect: Rect, collapsed: bool)
Places the window named by title (its explicit ID after ##, or
the whole title) at rect, collapsed or not, now or when it first
shows: for restoring a saved place. A rect with an edge that is not
finite is ignored, and one smaller than the style’s min_size is
made that large. A window is kept on screen when it is drawn, not
moved where it is placed.
Sourcepub fn places_revision(&self) -> u64
pub fn places_revision(&self) -> u64
A number that changes when the user collapses or opens a window, or ends a move or a resize that left it elsewhere: the places then differ from those saved.
Sourcepub fn frame(
&mut self,
input: &mut DebugInput,
virtual_resolution: UVec2,
output_size: UVec2,
) -> Frame<'_>
pub fn frame( &mut self, input: &mut DebugInput, virtual_resolution: UVec2, output_size: UVec2, ) -> Frame<'_>
Starts a frame: takes the frame’s events from input (see
DebugInput) and lays the UI out at the style’s scale for an
output of output_size pixels over a virtual image of
virtual_resolution, as UiSpace::new places it. The frame ends
when the Frame is dropped, finished or not.