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

pub trait Widget {
    fn draw(&mut self, _canvas: &mut Canvas<Window>);
fn get_config(&mut self) -> &mut WidgetConfig;
fn get_system_properties(&mut self) -> &mut HashMap<i32, String>;
fn get_callbacks(&mut self) -> &mut CallbackRegistry; fn mouse_entered(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn mouse_exited(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn mouse_moved(
        &mut self,
        _widgets: &Vec<WidgetContainer>,
        _points: Vec<i32>
    ) { ... }
fn mouse_scrolled(
        &mut self,
        _widgets: &Vec<WidgetContainer>,
        _points: Vec<i32>
    ) { ... }
fn button_clicked(
        &mut self,
        _button: u8,
        _state: bool,
        _widgets: &Vec<WidgetContainer>
    ) { ... }
fn tick(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn tick_callback(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn mouse_entered_callback(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn mouse_exited_callback(&mut self, _widgets: &Vec<WidgetContainer>) { ... }
fn mouse_moved_callback(
        &mut self,
        _widgets: &Vec<WidgetContainer>,
        _points: Vec<i32>
    ) { ... }
fn mouse_scrolled_callback(
        &mut self,
        _widgets: &Vec<WidgetContainer>,
        _points: Vec<i32>
    ) { ... }
fn button_clicked_callback(
        &mut self,
        _widgets: &Vec<WidgetContainer>,
        _button: u8,
        _state: bool
    ) { ... }
fn set_origin(&mut self, _origin: Vec<i32>) { ... }
fn set_size(&mut self, _size: Vec<u32>) { ... }
fn get_drawing_area(&mut self) -> Rect { ... } }

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_properties!() 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: &mut 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>)). The _canvas is the currently active drawing canvas at the time this function is called. This called during the draw loop of the Engine.

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.

fn get_callbacks(&mut self) -> &mut CallbackRegistry

Retrieves a Callback registry for this Widget.

Loading content...

Provided methods

fn mouse_entered(&mut self, _widgets: &Vec<WidgetContainer>)

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

fn mouse_exited(&mut self, _widgets: &Vec<WidgetContainer>)

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

fn mouse_moved(&mut self, _widgets: &Vec<WidgetContainer>, _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, _widgets: &Vec<WidgetContainer>, _points: Vec<i32>)

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,
    _widgets: &Vec<WidgetContainer>
)

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.

fn tick(&mut self, _widgets: &Vec<WidgetContainer>)

When a timer tick goes by (ie. a frame is displayed on the screen), this function is called. This function implementation is optional.

fn tick_callback(&mut self, _widgets: &Vec<WidgetContainer>)

This calls the on_tick callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_tick callback.

fn mouse_entered_callback(&mut self, _widgets: &Vec<WidgetContainer>)

This calls the on_mouse_entered callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_mouse_entered callback.

fn mouse_exited_callback(&mut self, _widgets: &Vec<WidgetContainer>)

This calls the on_mouse_exited callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_mouse_exited callback.

fn mouse_moved_callback(
    &mut self,
    _widgets: &Vec<WidgetContainer>,
    _points: Vec<i32>
)

This calls the on_mouse_moved callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_mouse_moved callback.

fn mouse_scrolled_callback(
    &mut self,
    _widgets: &Vec<WidgetContainer>,
    _points: Vec<i32>
)

This calls the on_mouse_scrolled callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_mouse_scrolled callback.

fn button_clicked_callback(
    &mut self,
    _widgets: &Vec<WidgetContainer>,
    _button: u8,
    _state: bool
)

This calls the on_button_clicked callback. This is implemented by the default_widget_callbacks! macro, so you do not need to implement it. However, you need to call this function if you wish to honor an on_button_clicked callback.

fn set_origin(&mut self, _origin: Vec<i32>)

Sets the origin of the Widget, adjusting the X and Y coordinates. Automatically sets the invalidate flag to true when adjusted, but only if the new origin is not the same as the previous origin.

fn set_size(&mut self, _size: Vec<u32>)

Sets the size of the Widget, adjusting the width and height. Automatically sets the invalidate flag to true when adjusted, but only if the new size is not the same as the previous size.

fn get_drawing_area(&mut self) -> Rect

Returns a Rect object containing the drawing bounds of this Widget.

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 as a borrowed mutable reference. This code is auto-generated using the default_widget_properties!() 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 as a borrowed mutable reference. This code is auto-generated using the default_widget_properties!() macro.

fn get_callbacks(&mut self) -> &mut CallbackRegistry[src]

This function is a macro-created getter function that returns the Widget's CallbackRegistry object as a borrowed mutable reference. This code is auto-generated using the default_widget_properties!() macro.

fn tick_callback(&mut self, _widgets: &Vec<WidgetContainer>)[src]

This function is a macro-created tick callback override, created by the default_widget_callbacks!() macro.

fn mouse_entered_callback(&mut self, _widgets: &Vec<WidgetContainer>)[src]

This function is a macro-created mouse entered callback override, created by the default_widget_callbacks!() macro.

fn mouse_exited_callback(&mut self, _widgets: &Vec<WidgetContainer>)[src]

This function is a macro-created mouse exited callback override, created by the default_widget_callbacks!() macro.

fn mouse_moved_callback(
    &mut self,
    _widgets: &Vec<WidgetContainer>,
    _points: Vec<i32>
)
[src]

This function is a macro-created mouse moved callback override, created by the default_widget_callbacks!() macro.

fn mouse_scrolled_callback(
    &mut self,
    _widgets: &Vec<WidgetContainer>,
    _points: Vec<i32>
)
[src]

This function is a macro-created mouse scrolled callback override, created by the default_widget_callbacks!() macro.

Loading content...