Skip to main content

TestHost

Struct TestHost 

Source
pub struct TestHost<W: View> { /* private fields */ }
Expand description

A screen hosted for tests.

Implementations§

Source§

impl<W: View> TestHost<W>

Source

pub fn new(vm: W::Vm) -> Self

The screen with vm, sized 427 × 240 (a common GUI size) — not opened yet (see Self::open).

Source

pub fn size(&mut self, w: f32, h: f32) -> &mut Self

Changes the GUI size.

Source

pub fn open(&mut self) -> &mut Self

Opens the screen (on_open) and draws a frame.

Source

pub fn close(&mut self) -> &mut Self

Closes the screen (on_close).

Source

pub fn frame(&mut self) -> &mut Self

Draws a frame (queued updates, bindings, layout).

Source

pub fn event(&mut self, raw: &str) -> bool

Sends a raw host event (click:X:Y, key:K:M, …), then a frame; returns whether the screen consumed it.

Source

pub fn click_path(&mut self, path: &[u16]) -> bool

Clicks (and releases) the middle of the widget at content path.

Source

pub fn click_id(&mut self, id: &str) -> bool

Clicks the widget tagged id.

Source

pub fn move_to(&mut self, x: f32, y: f32) -> &mut Self

Moves the cursor.

Source

pub fn drag(&mut self, points: &[(f32, f32)]) -> bool

A mouse drag: the button goes down at the first point, moves through the others and comes up at the last; returns whether the press was consumed.

Source

pub fn scroll(&mut self, dy: f32) -> bool

Mouse wheel (positive = up).

Source

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

A key press (GLFW code, see yog_api::ui::event::keys).

Source

pub fn key_mods(&mut self, key: i32, mods: i32) -> bool

Source

pub fn type_text(&mut self, text: &str) -> &mut Self

Types text into the focused text box.

Source

pub fn type_into(&mut self, id: &str, text: &str) -> &mut Self

Clicks the text box id and types text at its end.

Source

pub fn vm(&self) -> &W::Vm

Source

pub fn vm_mut(&mut self) -> &mut W::Vm

The view model, for arranging state; the bindings update at the next frame.

Source

pub fn handle(&self) -> ScreenHandle<W::Vm>

A handle like the one register() returns.

Source

pub fn root(&self) -> &Widget

The content tree.

Source

pub fn ui(&self) -> &UiRoot

The whole laid-out screen (content is child 0).

Source

pub fn path(&self, id: &str) -> Vec<u16>

Content path of the widget tagged id; panics when there’s none.

Source

pub fn widget(&self, id: &str) -> Option<&Widget>

Source

pub fn text_at(&self, path: &[u16]) -> Option<String>

The text of a label, button or text box.

Source

pub fn text(&self, id: &str) -> Option<String>

The text of the widget tagged id.

Source

pub fn is_visible(&self, id: &str) -> bool

The widget id is visible (it and every ancestor).

Source

pub fn state(&self, id: &str) -> StateFlags

Source

pub fn node(&self, id: &str) -> Option<&LayoutNode>

Source

pub fn rect(&self, id: &str) -> Option<Rect>

Source

pub fn scroll_offset(&self, i: usize) -> f32

Scroll offset of scroller i.

Source

pub fn requests(&self) -> &[String]

Requests made so far: close, navigate:<id>, back.

Source

pub fn closed(&self) -> bool

The screen asked to close.

Auto Trait Implementations§

§

impl<W> !RefUnwindSafe for TestHost<W>

§

impl<W> !UnwindSafe for TestHost<W>

§

impl<W> Freeze for TestHost<W>
where Host<W>: Freeze,

§

impl<W> Send for TestHost<W>
where Host<W>: Send,

§

impl<W> Sync for TestHost<W>
where Host<W>: Sync,

§

impl<W> Unpin for TestHost<W>
where Host<W>: Unpin,

§

impl<W> UnsafeUnpin for TestHost<W>
where Host<W>: UnsafeUnpin,

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.