[][src]Struct conrod_core::Ui

pub struct Ui {
    pub theme: Theme,
    pub window: Id,
    pub fonts: Map,
    pub win_w: f64,
    pub win_h: f64,
    // some fields omitted
}

Ui is the most important type within Conrod and is necessary for rendering and maintaining widget state.

Ui Handles the following:

Fields

theme: Theme

The theme used to set default styling for widgets.

window: Id

An index into the root widget of the graph, representing the entire window.

fonts: Map

Manages all fonts that have been loaded by the user.

win_w: f64

Window width.

win_h: f64

Window height.

Implementations

impl Ui[src]

pub fn widget_input(&self, widget: Id) -> Widget<'_>[src]

Returns a input::Widget for the given widget

pub fn rect_of(&self, id: Id) -> 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: Id) -> Option<Scalar>[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: Id) -> Option<Scalar>[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: Id) -> Option<Dimensions>[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: Id) -> Option<Point>[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: Id) -> 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<Id>[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) -> &FnvHashSet<Id>[src]

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) -> &FnvHashSet<Id>[src]

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 widget_id_generator(&mut self) -> Generator<'_>[src]

Produces a type that may be used to generate new unique widget::Ids.

See the widget::id::Generator docs for details on how to use this correctly.

pub fn scroll_widget(&mut self, widget_id: Id, offset: [Scalar; 2])[src]

Scroll the widget at the given index by the given offset amount.

The produced Scroll event will be applied upon the next call to Ui::set_widgets.

pub fn handle_event(&mut self, event: Input)[src]

Handle raw window events and update the Ui state accordingly.

This occurs within several stages:

  1. Convert the user's given event to a RawEvent so that the Ui may use it.
  2. Interpret the RawEvent for higher-level Events such as DoubleClick, WidgetCapturesKeyboard, etc.
  3. Update the Ui's global_input State accordingly, depending on the RawEvent.
  4. Store newly produced event::Uis within the global_input so that they may be filtered and fed to Widgets next time Ui::set_widget is called.

This method drives the Ui forward, and is what allows for using conrod's Ui with any window event stream.

The given event must implement the ToRawEvent trait so that it can be converted to a RawEvent that can be used by the Ui.

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 keyboard_capture(&mut self, idx: Id)[src]

Set keyboard capturing widget

pub fn calc_xy(
    &self,
    maybe_id: Option<Id>,
    maybe_parent_id: Option<Id>,
    x_position: Position,
    y_position: Position,
    dim: Dimensions,
    place_on_kid_area: bool
) -> Point
[src]

Get the centred xy coords for some given Dimensions, 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 set_widgets(&mut self) -> UiCell<'_>[src]

A function within which all widgets are instantiated by the user, normally situated within the "update" stage of an event loop.

pub fn set_num_redraw_frames(&mut self, num_frames: u8)[src]

Set the number of frames that the Ui should draw in the case that needs_redraw is called. The default is 3 (see the SAFE_REDRAW_COUNT docs for details).

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 clear_with(&mut self, color: Color)[src]

The first of the Primitives yielded by Ui::draw or Ui::draw_if_changed will always be a Rectangle the size of the window in which conrod is hosted.

This method sets the colour with which this Rectangle is drawn (the default being conrod::color::TRANSPARENT.

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 has_changed(&self) -> bool[src]

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

pub fn kids_bounding_box(&self, id: Id) -> Option<Rect>[src]

The Rect that bounds the kids of the widget with the given index.

pub fn visible_area(&self, id: Id) -> 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.

Trait Implementations

impl<'a> AsRef<Ui> for UiCell<'a>[src]

impl Debug for Ui[src]

Auto Trait Implementations

impl !RefUnwindSafe for Ui

impl Send for Ui

impl !Sync for Ui

impl Unpin for Ui

impl !UnwindSafe for Ui

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.