Skip to main content

Ui

Struct Ui 

Source
pub struct Ui {
    pub res: Resources,
    pub nodes: Vec<Node>,
    pub screen: [i32; 2],
    pub sounds: Vec<usize>,
    /* private fields */
}
Expand description

The interface: the element tree, the resources it uses, and the state of the pointer and the keyboard.

Fields§

§res: Resources

The sprite sheets, fonts, element descriptions and strings, loaded once.

§nodes: Vec<Node>

Every element. A NodeId is an index into this list.

§screen: [i32; 2]

The screen’s size in pixels.

§sounds: Vec<usize>

UserInterface::Play requests (sound slots: 4 button down, 5 button up/click, 3 drop), drained by the application.

Implementations§

Source§

impl Ui

Source

pub fn has_animations(&self) -> bool

True if the current tree contains an animated image with frames and a positive frame rate.

Source

pub fn update(&mut self, dt: f32)

Select each animated image’s frame at the supplied elapsed time in seconds. The game’s UI step: each element’s own update (AnimatedImageElement::Update, the containers’ wheel) by dt seconds.

Source

pub fn update_animations(&mut self, elapsed_seconds: f32)

The viewer’s preview: every animation at elapsed_seconds.

Source

pub fn animation_info(&self) -> Option<(usize, usize, i32)>

Current frame, frame count, and frame rate for the first animated image in the tree.

Source

pub fn set_animation_frame(&mut self, frame: usize)

Select the same frame in every animated image, wrapping each image’s own frame count.

Source§

impl Ui

Source

pub fn add_tab(&mut self, parent: NodeId, header: NodeId, content: NodeId)

Runtime UI::TabElement::AddTab: retain header/content order and select the first tab.

Source§

impl Ui

Source

pub fn set_value(&mut self, id: NodeId, value: f32)

Set the value of a slider, scroll bar or progress bar.

Source

pub fn value(&self, id: NodeId) -> Option<f32>

The value of a slider, scroll bar or progress bar.

Source

pub fn set_slider_range(&mut self, id: NodeId, range: [f32; 2])

Set the smallest and the largest value of a slider.

Source

pub fn set_table_child(&mut self, table: NodeId, index: usize, child: NodeId)

UI::TableElement::SetChild(child, index): put child in cell index (row-major).

Source

pub fn set_images(&mut self, id: NodeId, sprite: SpriteRef)

UI::ImageElement::SetSprite on every image inside id.

Source

pub fn set_spinner_range(&mut self, id: NodeId, min: i32, max: i32)

The range of the spinner’s number edit, its current value clamped to it.

Original: SpinnerElement::SetMinMax, Runtime 0x1800da5b0.

Source

pub fn spinner_range(&self, id: NodeId) -> Option<(i32, i32)>

The range of a spinner’s number edit.

Source

pub fn checked(&self, id: NodeId) -> bool

Whether a check control is checked.

Source

pub fn set_checked(&mut self, id: NodeId, value: bool)

Check or clear a check box.

Source

pub fn set_choices(&mut self, id: NodeId, choices: Vec<String>)

Set the choices of a combo box.

Source

pub fn set_choices_with_icons( &mut self, id: NodeId, choices: Vec<String>, icons: Vec<Option<SpriteRef>>, )

ComboElement::AddItem for each item, its text and sprite.

Source

pub fn set_graph( &mut self, id: NodeId, y_range: f32, x_divisions: i32, series: Vec<(u32, Vec<i32>)>, )

GraphElement::SetYRange, SetXDivisions, RemoveGraphs then AddGraph and AddGraphPoint for each (colour, points).

Source

pub fn set_label_sprite_color(&mut self, id: NodeId, color: u32)

LabelElement::SetSpriteColor.

Source§

impl Ui

Source

pub fn instantiate_dialog(&mut self, reference: &str) -> Option<DialogInstance>

Build a dialog from its resource, for example Dialog/MainMenu.rsc:resource.

Source

pub fn descendant(&self, root: NodeId, node: NodeId) -> bool

Whether node is root or inside it.

Source§

impl Ui

Resolve the link fragment index supplied by Event::Link to its document target.

Source§

impl Ui

Source

pub fn draw(&self, root: NodeId) -> Vec<Quad>

The quads that draw root and its children, in drawing order, then the open combo lists and the tooltip.

Source§

impl Ui

Source

pub fn focused(&self) -> Option<NodeId>

The element that has the keyboard focus.

Source

pub fn pointer(&self) -> (i32, i32)

The pointer in UI units, as last moved.

Source

pub fn pointer_over_interactive(&self) -> bool

Whether the current pointer target is a control that consumes pointer input.

Source

pub fn cursor_index(&self, id: NodeId, x: i32, y: i32) -> i32

DialogInstance::GetMouseCursorIndex: the cursor index of id, unless one of its visible children holds (x, y), then that child’s, the last such child winning.

Source

pub fn text_edit_focused(&self) -> bool

Whether key input should be reserved for an active text edit control.

Source

pub fn drain_events(&mut self) -> Vec<Event>

The events since the last call, in order. (A click is returned by pointer_button instead.)

Source

pub fn set_shortcut(&mut self, id: NodeId, key: u32)

Set the key that clicks an element: an upper-case character code, or 13 (Enter) or 27 (Escape).

Source

pub fn clear_input(&mut self)

Forget the pointer, the focus and the pending events, for example when the window loses the focus.

Source

pub fn pointer_move(&mut self, x: i32, y: i32, root: NodeId)

Move the pointer to (x, y) over the tree at root.

Source

pub fn pointer_button(&mut self, down: bool, root: NodeId) -> Option<Event>

Press or release the pointer’s button. Returns the click when a button is released over the element it was pressed on.

Source

pub fn wheel(&mut self, delta: i32) -> bool

ContainerElement::Update: the wheel over a container queues 7 frames of scrolling (up for a positive delta), which Ui::update_containers plays out.

Source

pub fn update_containers(&mut self)

ContainerElement::Update, each frame: one queued wheel frame moves the vertical bar a seventh of a third of the view (0.33 / 7), within the content.

Source

pub fn key(&mut self, root: NodeId, key: Key) -> bool

Press a key. Returns whether the interface used it.

Source

pub fn text_input(&mut self, text: &str) -> bool

Type text into the focused edit box. Returns whether it was used.

Source

pub fn hovered_tooltip(&self) -> Option<&str>

The tooltip text of the element under the pointer.

Source

pub fn place_tooltip(&mut self)

Size and place the open tooltip dialog on the pointer (again after the application filled it).

Source

pub fn new_tooltip(&mut self) -> Option<(NodeId, NodeId, Vec<u32>)>

The tooltip dialog opened since the last call: source element, dialog root and the dialog’s controller ids. Application controllers fill it, then call place_tooltip.

Source

pub fn set_parameters(&mut self, id: NodeId, values: &[(usize, &str)])

UI::TextElement::SetParameter on a text or label whose text still holds its template.

Source§

impl Ui

Source

pub fn instantiate(&mut self, reference: &str) -> Option<NodeId>

Build a node tree from an element reference such as Dialog\MainMenu.rsc:main.

Source§

impl Ui

Source

pub fn layout(&mut self, root: NodeId, rect: [i32; 4])

Size and lay out root inside the given rectangle.

Source

pub fn layout_dialog(&mut self, root: NodeId, rect: [i32; 4])

Lay out a dialog’s root element: placed at its own size by its alignment within rect (DialogInstance::ComputeLayout), unlike ordinary groups which fill.

Original: Runtime 0x180116620.

Source§

impl Ui

Source

pub fn query(&self, roots: &[NodeId], query: &Query) -> Vec<NodeId> ⓘ

Every shown element below roots (and the roots themselves) that matches query, in tree order with duplicates removed.

Source

pub fn kind_name(&self, id: NodeId) -> &'static str

A short lower-case name for an element’s kind: group, ribbon, border, image, animation, button, text, label, viewport, list, lines, picture, unsupported, or for a control check, slider, scroll, edit, combo, and so on.

Source

pub fn text_of(&self, id: NodeId) -> String

An element’s text: its own for text, labels and edits, its content’s for a button.

Source

pub fn info(&self, id: NodeId) -> ElementInfo

What a query reports about id.

Source§

impl Ui

Source

pub fn find(&self, root: NodeId, name: &str) -> Option<NodeId>

Depth-first search for a node by element name below root.

Source

pub fn children(&self, id: NodeId) -> Vec<NodeId> ⓘ

Return every node rendered or owned directly below this node, including control and button content that is stored outside Node::children.

Source

pub fn set_text(&mut self, id: NodeId, text: &str)

Replace the text of a Text/Label node, or of a Button’s content.

Source

pub fn set_icon(&mut self, id: NodeId, sprite: SpriteRef)

LabelElement::SetSprite on a label, or on a combo’s label (ComboElement::UpdateText sets the chosen item’s sprite when it has one).

Source

pub fn select_combo_item(&mut self, combo: NodeId, index: usize)

A combo’s item index: the list’s selection, the label’s text and the item’s sprite.

Source

pub fn set_visible(&mut self, id: NodeId, visible: bool)

Show or hide an element.

Source

pub fn group(&mut self) -> NodeId

Add an empty group (built in code, not from a resource).

Source

pub fn ribbon(&mut self, vertical: bool, spacing: i32) -> NodeId

Add an empty ribbon: a row, or a column when vertical.

Source

pub fn text(&mut self, font: &str, text: &str) -> NodeId

Add a text element with a font reference and a text.

Source

pub fn viewport(&mut self) -> NodeId

Add a viewport: space that the application draws into.

Source

pub fn picture(&mut self) -> NodeId

Add a picture: an application texture, drawn letterboxed.

Source

pub fn list(&mut self, font: &str) -> NodeId

A scrolling list using the game font and the White dialog sprite for highlights.

Source

pub fn slider(&mut self, range: [f32; 2]) -> NodeId

Create a simple horizontal slider with a built-in solid track and knob.

Source

pub fn set_list_items(&mut self, id: NodeId, items: Vec<String>)

Set the rows of a list.

Source

pub fn set_list_icons( &mut self, id: NodeId, items: Vec<String>, icons: Vec<Option<SpriteRef>>, )

Self::set_list_items with each item’s sprite.

Source

pub fn list_select(&mut self, id: NodeId, index: Option<usize>)

Select a row of a list, or none.

Source§

impl Ui

Source

pub fn new(archive: Rc<Archive>) -> Ui

An empty interface that reads its resources from archive.

Source

pub fn add(&mut self, node: Node) -> NodeId

Add an element, and return its id.

Source

pub fn add_child(&mut self, parent: NodeId, child: NodeId)

Make child the last child of parent.

Source

pub fn node(&self, id: NodeId) -> &Node

An element.

Source

pub fn node_mut(&mut self, id: NodeId) -> &mut Node

An element, to change it.

Auto Trait Implementations§

§

impl !Send for Ui

§

impl !Sync for Ui

§

impl Freeze for Ui

§

impl RefUnwindSafe for Ui

§

impl Unpin for Ui

§

impl UnsafeUnpin for Ui

§

impl UnwindSafe for Ui

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.