Struct State

Source
pub struct State {
Show 16 fields pub tree: Tree, pub style: Style, pub data: CachedData, pub mouse: MouseState, pub modifiers: ModifiersState, pub hovered: Entity, pub active: Entity, pub captured: Entity, pub focused: Entity, pub event_handlers: HashMap<Entity, Box<dyn EventHandler>, BuildHasherDefault<FnvHasher>>, pub event_queue: VecDeque<Event>, pub fonts: Fonts, pub needs_restyle: bool, pub needs_relayout: bool, pub needs_redraw: bool, pub listeners: HashMap<Entity, Box<dyn Fn(&mut (dyn EventHandler + 'static), &mut State, Entity, &mut Event)>, BuildHasherDefault<FnvHasher>>, /* private fields */
}

Fields§

§tree: Tree§style: Style§data: CachedData§mouse: MouseState§modifiers: ModifiersState§hovered: Entity§active: Entity§captured: Entity§focused: Entity§event_handlers: HashMap<Entity, Box<dyn EventHandler>, BuildHasherDefault<FnvHasher>>§event_queue: VecDeque<Event>§fonts: Fonts§needs_restyle: bool§needs_relayout: bool§needs_redraw: bool§listeners: HashMap<Entity, Box<dyn Fn(&mut (dyn EventHandler + 'static), &mut State, Entity, &mut Event)>, BuildHasherDefault<FnvHasher>>

Implementations§

Source§

impl State

Source

pub fn new() -> State

Source

pub fn query<E>(&mut self, entity: Entity) -> Option<&mut E>
where E: EventHandler,

Source

pub fn add_stylesheet(&mut self, path: &str) -> Result<(), Error>

Adds a stylesheet to the application

This function adds the stylesheet path to the application allowing for hot reloading of syles while the application is running.

§Examples
state.add_stylesheet("path_to_stylesheet.css");
Source

pub fn add_theme(&mut self, theme: &str)

Source

pub fn add_style_rule(&mut self, style_rule: StyleRule)

Adds a style rule to the application

This function adds a style rule to the application allowing for multiple entites to share the same style properties based on the rule selector.

§Examples

Adds a style rule which sets the flex-grow properties of all ‘button’ elements to 1.0:

state.add_style_rule(StyleRule::new(Selector::element("button")).property(Property::FlexGrow(1.0)))
Source

pub fn add_font(&mut self, _name: &str, _path: &str)

Source

pub fn reload_styles(&mut self) -> Result<(), Error>

Source

pub fn insert_event(&mut self, event: Event)

Insert a new event into the application event queue

Inserts a new event into the application event queue that will be processed on the next event loop. If the event unique flag is set to true, only the most recent event of the same type will exist in the queue.

§Examples
state.insert_event(Event::new(WindowEvent::WindowClose));
Source

pub fn capture(&mut self, entity: Entity)

Source

pub fn release(&mut self, id: Entity)

Source

pub fn set_focus(&mut self, entity: Entity)

Source

pub fn remove(&mut self, entity: Entity)

Source

pub fn apply_animations(&mut self) -> bool

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl !Send for State

§

impl !Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> Node for T
where T: 'static,