[][src]Trait pushrod_render::render::widget::Widget

pub trait Widget {
    fn draw(&mut self, _canvas: Canvas<Window>);
fn get_config(&mut self) -> &mut WidgetConfig;
fn get_system_properties(&mut self) -> &mut HashMap<i32, String>; fn mouse_entered(&mut self) { ... }
fn mouse_exited(&mut self) { ... }
fn mouse_moved(&mut self, _points: Vec<i32>) { ... }
fn mouse_scrolled(&mut self, _points: Vec<u8>) { ... }
fn button_clicked(&mut self, _button: u8, _state: bool) { ... } }

This trait is shared by all Widget objects that have a presence on the screen. Functions that must be implemented are documented in the trait.

Implementation Notes

If no custom get_config function is defined, and no custom get_system_properties function is defined, you can omit the definition of both, and use the default_widget_property_impl!() macro to auto-generate this code in your impl of this trait. Keep in mind, however, that these automatically generated implementation details could change in future releases of this library, so it is best to use the default implementation if possible.

Required methods

fn draw(&mut self, _canvas: Canvas<Window>)

Draws the widget. If you wish to modify the canvas object, you must declare it as mut in your implementation (ie fn draw(&mut self, mut canvas: Canvas<Window>)).

fn get_config(&mut self) -> &mut WidgetConfig

Retrieves the WidgetConfig object for this Widget.

fn get_system_properties(&mut self) -> &mut HashMap<i32, String>

Retrieves a HashMap containing system properties used by the Pushrod event engine.

Loading content...

Provided methods

fn mouse_entered(&mut self)

When a mouse enters the bounds of the Widget, this function is triggered. This function implementation is optional.

fn mouse_exited(&mut self)

When a mouse exits the bounds of the Widget, this function is triggered. This function implementation is optional.

fn mouse_moved(&mut self, _points: Vec<i32>)

When a mouse moves within the bounds of the Widget, this function is triggered. It contains the X and Y coordinates relative to the bounds of the Widget. The points start at 0x0. This function implementation is optional.

fn mouse_scrolled(&mut self, _points: Vec<u8>)

When a mouse scroll is triggered within the bounds of the Widget, this function is triggered. Movement along the X axis indicate horizontal movement, where the Y axis indicates vertical movement. Positive movement means to the right or down, respectively. Negative movement means to the left or up, respectively. This function implementation is optional.

fn button_clicked(&mut self, _button: u8, _state: bool)

When a mouse button is clicked within (or outside of) the bounds of the Widget, this function is called. If a mouse button is clicked, and the mouse leaves the bounds of the Widget, the mouse release event will still be triggered for the last Widget which received the mouse down state. This prevents Widgets from becoming confused. This behavior is tracked by the main loop, not by the Widget code. Therefore, when a mouse button is released outside of the bounds of this Widget, you must adjust your state accordingly, if you pay attention to the button_clicked function. This function implementation is optional.

Loading content...

Implementors

impl Widget for BaseWidget[src]

Implementation for drawing a BaseWidget, with the Widget trait objects applied.

fn get_config(&mut self) -> &mut WidgetConfig[src]

This function is a macro-created getter function that returns the Widget's configuration object. This code is auto-generated using the default_widget_property_impl!() macro.

fn get_system_properties(&mut self) -> &mut HashMap<i32, String>[src]

This function is a macro-created getter function that returns the Widget's system properties. This code is auto-generated using the default_widget_property_impl!() macro.

Loading content...