Struct thyme::PersistentState

source ·
pub struct PersistentState {
    pub is_open: bool,
    pub expanded: bool,
    pub resize: Point,
    pub moved: Point,
    pub scroll: Point,
    pub base_time_millis: u32,
    pub characters: Vec<char>,
    pub text: Option<String>,
    pub timer: u32,
}
Expand description

The internal state stored by Thyme for a given Widget that persists between frames.

Note that Thyme will generally be able to automatically generate unique IDs for many widgets such as buttons. But, if you want to access this data for a particular widget you will need to specify a known ID for that widget.

Example

fn reset_window_state(ui: &mut Frame, window_id: &str) {
    ui.modify(window_id, |state| {
        state.resize = Point::default();
        state.moved = Point::default();
        state.is_open = true;
    });
}

Fields§

§is_open: bool

Whether the widget will be shown. Defaults to true.

§expanded: bool

Whether a tree or similar widget is expanded, showing all children, or not

§resize: Point

An amount, in logical pixels that the widget has been resized by. Default to zero.

§moved: Point

An amount, in logical pizels that the widget has been moved by. Defaults to zero.

§scroll: Point

An amount, in logical pixels that the internal content has been scrolled by. Defaults to zero.

§base_time_millis: u32

The “zero” time for timed images associated with this widget. Defaults to zero, which is the internal Context init time.

§characters: Vec<char>

Any characters that have been sent to this widget from the keyboard. Defaults to empty. Widgets should typically drain this list as they work with input.

§text: Option<String>

The text for this widget, overriding default text. Defaults to None.

§timer: u32

A timer in milliseconds, allowing the widget to easily store a particular relevant time - for delayed actions, for example

Trait Implementations§

source§

impl Clone for PersistentState

source§

fn clone(&self) -> PersistentState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PersistentState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PersistentState

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for PersistentState

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for PersistentState

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,