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
impl State
pub fn new() -> State
pub fn query<E>(&mut self, entity: Entity) -> Option<&mut E>where
E: EventHandler,
Sourcepub fn add_stylesheet(&mut self, path: &str) -> Result<(), Error>
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");
pub fn add_theme(&mut self, theme: &str)
Sourcepub fn add_style_rule(&mut self, style_rule: StyleRule)
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)))
pub fn add_font(&mut self, _name: &str, _path: &str)
pub fn reload_styles(&mut self) -> Result<(), Error>
Sourcepub fn insert_event(&mut self, event: Event)
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));
pub fn capture(&mut self, entity: Entity)
pub fn release(&mut self, id: Entity)
pub fn set_focus(&mut self, entity: Entity)
pub fn remove(&mut self, entity: Entity)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more