Struct nannou::ui::Ui
[−]
[src]
pub struct Ui { pub image_map: Map<Texture2d>, // some fields omitted }
A handle to the Ui
for a specific window.
Fields
image_map: Map<Texture2d>
Methods
impl Ui
[src]
pub const DEFAULT_PENDING_INPUT_LIMIT: usize
DEFAULT_PENDING_INPUT_LIMIT: usize = 1024
The default maximum number of Input
s that a Ui
will store in its pending Input
queue
before Input
s start being ignored.
pub const DEFAULT_FONT_PATH: &'static str
DEFAULT_FONT_PATH: &'static str = "fonts/NotoSans/NotoSans-Regular.ttf"
The path to the default font for the Ui
.
pub fn generate_widget_id(&mut self) -> Id
[src]
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.
pub fn widget_id_generator(&mut self) -> Generator
[src]
Produces the type that may be used to generate new unique widget::Id
s.
pub fn handle_input(&mut self, input: Input)
[src]
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.
pub fn handle_pending_input(&mut self)
[src]
Processes all pending input.
This is automatically called at the beginning of the set_widgets
method, so the user
should never need to call this manually, however the method is exposed for flexibility
just in case.
This has no effect if automatic input handling is disabled.
pub fn set_widgets(&mut self) -> UiCell
[src]
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.
pub fn fonts_mut(&mut self) -> &mut Map
[src]
Mutable access to the Ui
's font map.
This allows for adding and removing fonts to the UI.
pub fn theme_mut(&mut self) -> &mut Theme
[src]
Mutable access to the Ui
's Theme
.
This allows for making changes to the active theme.
pub fn clear_with(&mut self, color: Color)
[src]
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
).
pub fn draw_to_frame(&self, app: &App, frame: &Frame) -> Result<(), DrawError>
[src]
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<(), DrawError>
[src]
&self,
app: &App,
frame: &Frame
) -> Result<(), DrawError>
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.
Methods from Deref<Target = Ui>
pub fn widget_input(&self, widget: NodeIndex<u32>) -> Widget
[src]
Returns a input::Widget
for the given widget
pub fn rect_of(&self, id: NodeIndex<u32>) -> Option<Rect>
[src]
The Rect for the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn w_of(&self, id: NodeIndex<u32>) -> Option<f64>
[src]
The absolute width of the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn h_of(&self, id: NodeIndex<u32>) -> Option<f64>
[src]
The absolute height of the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn wh_of(&self, id: NodeIndex<u32>) -> Option<[f64; 2]>
[src]
The absolute dimensions for the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn xy_of(&self, id: NodeIndex<u32>) -> Option<[f64; 2]>
[src]
The coordinates for the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn kid_area_of(&self, id: NodeIndex<u32>) -> Option<Rect>
[src]
The kid_area
of the widget at the given index.
Returns None
if there is no widget for the given index.
pub fn maybe_prev_widget(&self) -> Option<NodeIndex<u32>>
[src]
An index to the previously updated widget if there is one.
pub fn widget_graph(&self) -> &Graph
[src]
Borrow the Ui's widget_graph
.
pub fn updated_widgets(
&self
) -> &HashSet<NodeIndex<u32>, BuildHasherDefault<FnvHasher>>
[src]
&self
) -> &HashSet<NodeIndex<u32>, BuildHasherDefault<FnvHasher>>
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.
pub fn prev_updated_widgets(
&self
) -> &HashSet<NodeIndex<u32>, BuildHasherDefault<FnvHasher>>
[src]
&self
) -> &HashSet<NodeIndex<u32>, BuildHasherDefault<FnvHasher>>
Borrow the Ui's set of updated widgets.
This set indicates which widgets have were instantiated during the previous call to
Ui::set_widgets
.
pub fn global_input(&self) -> &Global
[src]
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.
pub fn calc_xy(
&self,
maybe_id: Option<NodeIndex<u32>>,
x_position: Position,
y_position: Position,
dim: [f64; 2],
place_on_kid_area: bool
) -> [f64; 2]
[src]
&self,
maybe_id: Option<NodeIndex<u32>>,
x_position: Position,
y_position: Position,
dim: [f64; 2],
place_on_kid_area: bool
) -> [f64; 2]
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.
pub fn needs_redraw(&self)
[src]
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.
pub fn draw(&self) -> Primitives
[src]
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.
pub fn draw_if_changed(&self) -> Option<Primitives>
[src]
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.
pub fn kids_bounding_box(&self, id: NodeIndex<u32>) -> Option<Rect>
[src]
The Rect that bounds the kids of the widget with the given index.
pub fn visible_area(&self, id: NodeIndex<u32>) -> Option<Rect>
[src]
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.
pub fn mouse_cursor(&self) -> MouseCursor
[src]
Get mouse cursor state.