Struct conrod::Ui [−] [src]

pub struct Ui<C, W = ()> where W: CustomWidget {
    pub theme: Theme,
    pub mouse: Mouse,
    pub keys_just_pressed: Vec<Key>,
    pub keys_just_released: Vec<Key>,
    pub text_just_entered: Vec<String>,
    pub character_cache: C,
    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

The theme used to set default styling for widgets.

mouse

The latest received mouse state.

keys_just_pressed

Keys that have been pressed since the end of the last render cycle.

keys_just_released

Keys that have been released since the end of the last render cycle.

text_just_entered

Text that has been entered since the end of the last render cycle.

character_cache

Cache for character textures, used for label width calculation and glyph rendering.

win_w

Window width.

win_h

Window height.

Methods

impl<C, W> Ui<C, W> where W: CustomWidget

fn new(character_cache: C, theme: Theme) -> Ui<C, W>

Constructor for a UiContext.

fn widget_size(&self, ui_id: UiId) -> Dimensions

Return the dimensions of a Canvas.

fn canvas_size(&self, id: CanvasId) -> Dimensions

Return the dimensions of a Canvas.

fn handle_event<E: GenericEvent>(&mut self, event: &E)

Handle game events and update the state.

fn get_character(&mut self, size: FontSize, ch: char) -> &Character<C> where C: CharacterCache

Return a reference to a Character from the GlyphCache.

fn get_character_w(&mut self, size: FontSize, ch: char) -> f64 where C: CharacterCache

Return the width of a 'Character'.

fn flush_input(&mut self)

Flush all stored keys.

fn get_mouse_state(&self, ui_id: UiId) -> Mouse

Return the current mouse state. If the Ui has been captured and the given ui_id doesn't match the captured ui_id, return the captured mouse state.

fn get_pressed_keys(&self, ui_id: UiId) -> &[Key]

Return the vector of recently pressed keys.

fn get_entered_text(&self, ui_id: UiId) -> &[String]

Return the vector of recently entered text.

fn get_widget_mut(&mut self, ui_id: UiId, default: WidgetKind<W>) -> &mut WidgetKind<W>

Return a mutable reference to the widget that matches the given ui_id

fn update_canvas(&mut self, id: CanvasId, kind: CanvasKind, xy: Point, padding: Padding, maybe_new_element: Option<Element>)

Update the given canvas.

fn update_widget(&mut self, ui_id: UiId, kind: WidgetKind<W>, xy: Point, depth: Depth, maybe_new_element: Option<Element>) where W: Debug

Update the given widget at the given UiId.

fn get_xy(&self, position: Position, dim: Dimensions, h_align: HorizontalAlign, v_align: VerticalAlign) -> Point

Get the centred xy coords for some given Dimensions, Position and alignment.

fn mouse_captured_by(&mut self, ui_id: UiId)

Indicate that the widget with the given UiId has captured the mouse.

fn mouse_uncaptured_by(&mut self, ui_id: UiId)

Indicate that the widget is no longer capturing the mouse.

fn keyboard_captured_by(&mut self, ui_id: UiId)

Indicate that the widget with the given UiId has captured the keyboard.

fn keyboard_uncaptured_by(&mut self, ui_id: UiId)

Indicate that the widget is no longer capturing the keyboard.

fn draw<G>(&mut self, graphics: &mut G) where C: CharacterCache, G: Graphics<Texture=C>

Draw the Ui in it's current state. - The order of drawing is as follows: 1. Canvas splits. 2. Widgets on Canvas splits. 3. Floating Canvasses. 4. Widgets on Floating Canvasses. - Widgets are sorted by capturing and then render depth (depth first). - Construct the elmesque Renderer for rendering the elm Elements. - Render all widgets.