[][src]Struct pushrod::widget::timer_widget::TimerWidget

pub struct TimerWidget { /* fields omitted */ }

This is the TimerWidget. It contains no base widget, it only contains a start and end time,

Methods

impl TimerWidget[src]

Implementation of the constructor for the TimerWidget. Timer widgets are not accessible on the screen, so they have an origin of 0x0 and width of 0x0.

The timer provides a simple way to call a callback function after a certain amount of time has passed. Upon instantiation, the timer is enabled.

Here are a few limitations of the timer as it currently stands:

  • Timer cannot be paused; it is enabled or disabled, and the timer resets when enabled.
  • Timer is called when the screen refreshes, so slower FPS settings will affect the timer.

pub fn new() -> Self[src]

Constructor, creates a new TimerWidget struct with an empty timeout function.

pub fn set_enabled(&mut self, enabled: bool)[src]

Enables or disables the timer. When disabled, the timer will not initiate the callback function. When re-enabled, the initiation time resets, so the timer will reset back to zero, effectively resetting the entire timer.

pub fn on_timeout(&mut self, timeout_function: Box<dyn Fn()>)[src]

Sets the closure function for the timer when a timeout has been triggered. This closure needs to be Boxed.

pub fn set_timeout(&mut self, timeout: u64)[src]

Sets the timeout in milliseconds for this timer. Will trigger a call to the function set in on_timeout when triggered, and will continue to call that function until this timer is disabled by using self.set_enabled(false).

Trait Implementations

impl Widget for TimerWidget[src]

Implementation of the TimerWidget object with the Widget traits implemented.

Example usage:

   let mut timer_widget = TimerWidget::new();

   timer_widget.set_timeout(60000);
   timer_widget.on_timeout(Box::new( || eprintln!("Timer triggered.") ));
   timer_widget.set_enabled(true);

fn is_invalidated(&mut self) -> bool[src]

Timer is always invalidated, this way, the tick function is always called on each screen refresh.

fn get_origin(&mut self) -> Point[src]

Origin is always set to X/Y at points 0x0.

fn get_size(&mut self) -> Size[src]

Size is always unsized, as timers are invisible.

fn mouse_entered(&mut self, _widget_id: i32)[src]

Mouse entered callback is disabled.

fn mouse_exited(&mut self, _widget_id: i32)[src]

Mouse exited callback is disabled.

fn mouse_scrolled(&mut self, _widget_id: i32, _point: Point)[src]

Mouse scrolled callback is disabled.

fn draw(&mut self, _context: Context, _graphics: &mut G2d)[src]

Does not draw anything - only calls the timer tick() function to increment the timer.

fn invalidate(&mut self)[src]

Indicates that a widget needs to be redrawn/refreshed.

fn clear_invalidate(&mut self)[src]

Clears the invalidation flag.

fn set_origin(&mut self, x: i32, y: i32)[src]

Sets the Point of origin for this widget, given the X and Y origin points. Invalidates the widget afterward.

fn set_size(&mut self, w: i32, h: i32)[src]

Sets the Size for this widget, given a width and height. Invalidates the widget afterward.

fn set_color(&mut self, color: Color)[src]

Sets the color for this widget. Invalidates the widget afterward.

fn get_color(&mut self) -> Color[src]

Retrieves the color of this widget. Defaults to white color [1.0; 4] if not set. Read more

fn set_autoclip(&mut self, clip: bool)[src]

fn get_autoclip(&mut self) -> bool[src]

Auto Trait Implementations

impl !Send for TimerWidget

impl !Sync for TimerWidget

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> Erased for T