[][src]Struct conrod_core::UiCell

pub struct UiCell<'a> { /* fields omitted */ }

A wrapper around the Ui that restricts the user from mutating the Ui in certain ways while in the scope of the Ui::set_widgets function and within Widgets' update methods. Using the UiCell, users may access the Ui immutably (via Deref) however they wish, however they may only mutate the Ui via the &mut self methods provided by the UiCell.

The name came from its likening to a "jail cell for the Ui", as it restricts a user's access to it. However, we realise that the name may also cause ambiguity with the std Cell and RefCell types (which UiCell has nothing to do with). Thus, if you have a better name for this type in mind, please let us know at the github repo via an issue or PR sometime before we hit 1.0.0!

Implementations

impl<'a> UiCell<'a>[src]

pub fn theme(&self) -> &Theme[src]

A reference to the Theme that is currently active within the Ui.

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

A convenience method for borrowing the Font for the given Id if it exists.

pub fn window_dim(&self) -> Dimensions[src]

Returns the dimensions of the window

pub fn global_input(&self) -> &Global[src]

Returns an immutable reference to the input::Global of the Ui.

All coordinates here will be relative to the center of the window.

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

Returns a input::Widget with input events for the widget.

All coordinates in the input::Widget will be relative to the widget at the given index.

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 kids_bounding_box(&self, id: Id) -> Option<Rect>[src]

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

Returns None if the widget has no children or if there's is no widget for the given index.

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

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

The produced Scroll event will be pushed to the pending_scroll_events and will be applied to the widget during the next call to Ui::set_widgets.

pub fn set_mouse_cursor(&mut self, cursor: MouseCursor)[src]

Sets the mouse cursor

Methods from Deref<Target = Ui>

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 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<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 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 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<'a> Debug for UiCell<'a>[src]

impl<'a> Deref for UiCell<'a>[src]

type Target = Ui

The resulting type after dereferencing.

impl<'a> Drop for UiCell<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for UiCell<'a>

impl<'a> Send for UiCell<'a>

impl<'a> !Sync for UiCell<'a>

impl<'a> Unpin for UiCell<'a>

impl<'a> !UnwindSafe for UiCell<'a>

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.