[][src]Struct pushrod_widgets::caches::WidgetCache

pub struct WidgetCache { /* fields omitted */ }

This is the WidgetCache store structure.

Implementations

impl WidgetCache[src]

This is the WidgetCache that is used to store Widget references in a drawing tree by ID.

pub fn new(w: u32, h: u32) -> Self[src]

Creates a new WidgetCache, adding the BaseWidget to the top level of the Window, with the name root as the root Widget. This Widget can be modified like any other - its properties can be changed, background color, border color, etc. can all be manipulated just like any other Widget. Its ID is 0.

pub fn id_at_point(&self, x: u32, y: u32) -> u32[src]

Retrieves the ID of the widget at the X/Y coordinates given.

Follows the following rules:

  • If the object is hidden, any objects underneath that object are short-circuited
  • If an object is visible, it walks the object's children to see if they are within the same given coordinates

The found ID is then returned having met all of those criteria. If no ID was found, a 0 value (root level widget) is returned.

pub fn get(&self, widget_id: u32) -> RefMut<Box<dyn Widget>>[src]

Retrieves the Widget stored by its RefMut<Box> reference. This is a mutable reference to the Widget, allowing for its properties and other accessors to be immutably changed.

pub fn get_mut(&mut self, widget_id: u32) -> RefMut<Box<dyn Widget>>[src]

Retrieves the Widget stored by its RefMut<Box> reference. This is a mutable reference to the Widget, allowing for its properties and other accessors to be mutably changed.

pub fn get_parent_of(&self, widget_id: u32) -> u32[src]

Retrieves the parent ID of the widget ID specified. If the widget is a top level widget (meaning there are no additional parents), a 0 will be returned.

pub fn get_children_of(&self, widget_id: u32) -> Vec<u32>[src]

Retrieves a list of children for the specified widget ID. The child listing will always return a Vec - if any widgets have been added to this Widget as a parent, those IDs will be returned here. If this widget has no children, an empty Vec will be returned.

pub fn add(
    &mut self,
    widget: Box<dyn Widget>,
    widget_name: String,
    parent_id: u32
) -> u32
[src]

Adds a new Widget to the cache, with the given mutable Widget, a name for the Widget, and the Widget's parent ID.

pub fn add_vec(
    &mut self,
    widgets: Vec<Box<dyn Widget>>,
    parent_id: u32
) -> Vec<u32>
[src]

Adds a list of Widgets, storing the IDs resulting from each add, to the parent ID.

pub fn size(&self) -> u32[src]

Retrieves the total number of Widgets in the cache.

pub fn set_hidden(&mut self, widget_id: u32, state: bool)[src]

Sets the Widget ID's PROPERTY_HIDDEN value to true/false based on the state specified. Walks the child IDs of each of the Widget's children and hides their IDs. Does not allow for the root ID (widget_id == 0) to be hidden.

pub fn invalidated(&self) -> bool[src]

Determines whether any of the Widgets in the cache have indicated that they need to be redrawn.

pub fn needs_layout(&self) -> bool[src]

Determines whether any of the Widgets in the cache have indicated that they need to extend a layout to the WidgetCache.

pub fn refresh(&mut self, c: &mut Canvas<Window>)[src]

Redraws the screen, redrawing any Widgets that have been invalidated, and copying their Textures to the screen if necessary. If none of the Widgets have been invalidated, the screen already contains the main Texture with all of the objects, so it does not make sense to run this method if the screen does not need refreshing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.