Struct nannou_conrod::Ui [−][src]
pub struct Ui {
pub image_map: ImageMap,
// some fields omitted
}
Expand description
A handle to the Ui
for a specific window.
Fields
image_map: ImageMap
Implementations
Generate a new, unique widget::Id
into a Placeholder node within the widget graph. This
should only be called once for each unique widget needed to avoid unnecessary bloat within
the Ui
’s internal widget graph.
When using this method, be sure to store the returned widget::Id
somewhere so that it can
be re-used on next update.
Panics if adding another node would exceed the maximum capacity for node indices.
Produces the type that may be used to generate new unique widget::Id
s.
Handle a raw UI input event and update the Ui state accordingly.
This method drives the Ui forward and interprets input into higher-level events (like clicks and drags) for widgets.
Note: By default, this will be called automatically by the nannou App
, so most of the
time you should not need to call this (otherwise received inputs may double up). This
method is particularly useful in the case that automatic input handling has been disabled,
as this can be used to manually submit inputs.
Check the given raw event for a valid conrod Input
and if there is one, call
self.handle_input(input)
.
Returns false
in the case that no Input
could be parsed, or if there was no Window
for the Ui
’s associated window::Id
.
Returns a context upon which UI widgets can be instantiated.
The UiCell simply acts as a wrapper around the Ui for the period over which widgets are instantiated. Once the UiCell is dropped, it does some cleanup and sorting that is required after widget instantiation.
Mutable access to the Ui
’s font map.
This allows for adding and removing fonts to the UI.
Mutable access to the Ui
’s Theme
.
This allows for making changes to the active theme.
The first of the Primitives
yielded by Ui::draw
will always be a Rectangle
the size
of the window in which the Ui is instantiated.
This method sets the colour with which this Rectangle
is drawn (the default being
color::TRANSPARENT
).
Draws the current state of the Ui
to the given Frame
.
The Ui
will automatically draw to its associated window within the given Frame
.
If you require more control over where the Ui
is drawn within the Frame
, the draw
method offers more flexibility.
This has no effect if the window originally associated with the Ui
no longer exists.
pub fn draw_to_frame_if_changed(
&self,
app: &App,
frame: &Frame<'_>
) -> Result<bool, DrawToFrameError>
pub fn draw_to_frame_if_changed(
&self,
app: &App,
frame: &Frame<'_>
) -> Result<bool, DrawToFrameError>
Draws the current state of the Ui
to the given Frame
but only if the Ui
has changed
since last time either draw_to_frame
or draw_to_frame_if_changed
was called.
The Ui
will automatically draw to its associated window within the given Frame
.
If you require more control over where the Ui
is drawn within the Frame
, the draw
method offers more flexibility.
This has no effect if the window originally associated with the Ui
no longer exists.
Returns true
if the call resulted in re-drawing the Ui
due to changes.
Methods from Deref<Target = Ui>
Returns a input::Widget
for the given widget
The Rect for the widget at the given index.
Returns None
if there is no widget for the given index.
The absolute width of the widget at the given index.
Returns None
if there is no widget for the given index.
The absolute height of the widget at the given index.
Returns None
if there is no widget for the given index.
The absolute dimensions for the widget at the given index.
Returns None
if there is no widget for the given index.
The coordinates for the widget at the given index.
Returns None
if there is no widget for the given index.
The kid_area
of the widget at the given index.
Returns None
if there is no widget for the given index.
An index to the previously updated widget if there is one.
Borrow the Ui’s widget_graph
.
Borrow the Ui’s set of updated widgets.
This set indicates which widgets have been instantiated since the beginning of the most
recent Ui::set_widgets
call.
Borrow the Ui’s set of updated widgets.
This set indicates which widgets have were instantiated during the previous call to
Ui::set_widgets
.
Get an immutable reference to global input. Handles aggregation of events and providing them to Widgets
Can be used to access the current input state, e.g. which widgets are currently capturing inputs.
Get the centred xy coords for some given Dimension
s, Position
and alignment.
If getting the xy for a specific widget, its widget::Id
should be specified so that we
can also consider the scroll offset of the scrollable parent widgets.
The place_on_kid_area
argument specifies whether or not Place Position variants
should target a Widget’s kid_area
, or simply the Widget’s total area.
Tells the Ui
that it needs to re-draw everything. It does this by setting the redraw
count to num_redraw_frames
. See the docs for set_num_redraw_frames
, SAFE_REDRAW_COUNT
or draw_if_changed
for more info on how/why the redraw count is used.
Draw the Ui
in it’s current state.
NOTE: If you don’t need to redraw your conrod GUI every frame, it is recommended to use the
Ui::draw_if_changed
method instead.
Same as the Ui::draw
method, but only draws if the redraw_count
is greater than 0.
The redraw_count
is set to SAFE_REDRAW_COUNT
whenever a Widget
indicates that it
needs to be re-drawn.
It can also be triggered manually by the user using the Ui::needs_redraw
method.
This method is generally preferred over Ui::draw
as it requires far less CPU usage, only
redrawing to the screen if necessary.
Note that when Ui::needs_redraw
is triggered, it sets the redraw_count
to 3 by default.
This ensures that conrod is drawn to each buffer in the case that there is buffer swapping
happening. Let us know if you need finer control over this and we’ll expose a way for you
to set the redraw count manually.
Returns if the redraw_count is greater than 0 and thus draw_if_changed would draw
See Ui::draw_if_changed
for when this is triggered
The Rect that bounds the kids of the widget with the given index.
The Rect that represents the maximum fully visible area for the widget with the given index, including consideration of cropped scroll area.
Otherwise, return None if the widget is not visible.
Get mouse cursor state.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: Component + Float,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: Component + Float,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
Mutably borrows from an owned value. Read more
Convert into T with values clamped to the color defined bounds Read more
Convert into T. The resulting color might be invalid in its color space Read more
Convert into T, returning ok if the color is inside of its defined range,
otherwise an OutOfBounds
error is returned which contains the unclamped color. Read more