Skip to main content

DebugUi

Struct DebugUi 

Source
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

Source

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.

Source

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.

Source

pub fn style(&self) -> &Style

Its look.

Source

pub fn style_mut(&mut self) -> &mut Style

Its look, to change: its scale, the settings’ UI scale, among it.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.