[][src]Struct pushrod::render::widget_cache::WidgetCache

pub struct WidgetCache { /* fields omitted */ }

This is the WidgetCache struct, which contains a list of Widgets that are managed by the Pushrod Engine. Widget IDs are automatically generated by the WidgetCache, which automatically assigns the Widget ID at the time it's added to the cache. Parent IDs must already exist, otherwise, an error is thrown at the time the Widget is attempted to be added. Widget IDs always start at 1.

Methods

impl WidgetCache[src]

This is the WidgetCache implementation. This cache object manages the Widget list for use by the Pushrod Engine.

pub fn new() -> Self[src]

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

This adds a Widget to the render list. It requires that the Widget being added is in a Box, along with a widget_name. Returns the ID of the Widget that was added. Use this ID if you plan on adding further Widgets, with this Widget as the parent. The point of origin (extracted from the Widget's position at creation time) is its physical location inside the Window.

pub fn find_widget(&mut self, x: i32, y: i32) -> i32[src]

This locates the ID of a Widget at a given x and y coordinate. If a Widget could not be found, the top-level Widget (id 0) is returned. This function returns the top-most visible Widget id.

pub fn get_container_by_id(&mut self, id: i32) -> &mut WidgetContainer[src]

Returns a WidgetContainer object by its ID. This is the same Widget ID that is returned when using the add_widget function. There are no bounds checks here, so if the ID does not exist, it will throw an exception at runtime. Be careful: it's better to use the get_container_by_name function to avoid this.

pub fn get_container_by_name(&mut self, name: String) -> &mut WidgetContainer[src]

Returns a WidgetContainer object by the name of the Widget. If the WidgetContainer cannot find the Widget by the name specified, the top-level Widget is returned for safety.

pub fn button_clicked(
    &mut self,
    widget_id: i32,
    button: u8,
    clicks: u8,
    state: bool,
    cache: &[LayoutContainer]
)
[src]

This function calls the button_clicked callback for the Widget specified by widget_id. When state is set to true, this indicates that a mouse button down was detected. When set to false, it indicates that the mouse button was released. When setting the button state to widget_id == -1, the button click message will be sent to all Widgets, so use widget_id == -1 with care.

pub fn mouse_moved(
    &mut self,
    widget_id: i32,
    points: Vec<i32>,
    cache: &[LayoutContainer]
)
[src]

This function calls the mouse_moved callback for the Widget specified by widget_id.

pub fn mouse_scrolled(
    &mut self,
    widget_id: i32,
    points: Vec<i32>,
    cache: &[LayoutContainer]
)
[src]

This function calls the mouse_scrolled callback for the Widget specified by widget_id.

pub fn mouse_exited(&mut self, widget_id: i32, cache: &[LayoutContainer])[src]

This function calls the mouse_exited callback for the Widget specified by widget_id.

pub fn mouse_entered(&mut self, widget_id: i32, cache: &[LayoutContainer])[src]

This function calls the mouse_entered callback for the Widget specified by widget_id.

pub fn tick(&mut self, _cache: &[LayoutContainer])[src]

This function calls the tick method on all registered Widgets in the cache. The purpose for the tick is to indicate that a drawing loop is about to occur, and the Widget can update itself as necessary beforehand.

pub fn other_event(
    &mut self,
    widget_id: i32,
    event: Event,
    cache: &[LayoutContainer]
)
[src]

This function sends all other un-handled events from SDL2 to the currently highlighted Widget.

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

This function performs the draw loop for all of the Widgets stored in the cache. Each Widget receives a mutable reference to the Canvas so that the Widget can be drawn on the screen during the draw loop of the Engine. This draw_loop function automatically clips the screen area so that the Widget cannot draw outside of its bounds. Returns true if the display loop needs to refresh the top-level canvas, false otherwise.

pub fn borrow_cache(&mut self) -> &[WidgetContainer][src]

Returns a borrowed slice of the WidgetContainer Vec object, which can be passed on to Layout objects so that the layout can be computed and performed.

Trait Implementations

impl Default for WidgetCache[src]

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.