[][src]Struct pushrod::widget::push_button_widget::PushButtonWidget

pub struct PushButtonWidget { /* fields omitted */ }

This is the PushButtonWidget, which contains a top-level widget for display, overriding the draw method to draw the base widget and the border for this box.

Example usage:

   let mut button_widget = PushButtonWidget::new(prod.get_factory(),
       "OpenSans-Regular.ttf".to_string(),
       "Button".to_string(),
       20,
       TextJustify::Center,
   );

   button_widget.set_origin(100, 100);
   button_widget.set_size(200, 200);
   button_widget.set_border_color([0.0, 0.0, 0.0, 1.0]);
   button_widget.set_border_thickness(3);
   button_widget.on_clicked(Box::new(|| {
       eprintln!("Button Widget Clicked!");
   }));

   // (OR)

   button_widget.set_border([0.0, 0.0, 0.0, 1.0], 3);

Methods

impl PushButtonWidget[src]

Implementation of the constructor for the PushButtonWidget.

pub fn new(
    factory: &mut GfxFactory,
    font_name: String,
    text: String,
    font_size: u32,
    justify: TextJustify
) -> Self
[src]

pub fn set_text(&mut self, text: String)[src]

Sets the border color for this widget.

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

Sets the color of the text for this Widget.

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

Retrieves the color of the text for this Widget. Defaults to black if not set.

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

Sets the border color for this widget.

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

Retrieves the border color of this widget. Defaults to black color [0.0, 0.0, 0.0, 1.0] if not set.

pub fn set_border_thickness(&mut self, thickness: u8)[src]

Sets the thickness of the border for this widget.

pub fn get_border_thickness(&mut self) -> u8[src]

Retrieves the border thickness of this widget. Defaults to 1 if not set.

pub fn set_border(&mut self, color: Color, thickness: u8)[src]

Helper function that sets both the color of the border and the thickness at the same time.

pub fn on_clicked(&mut self, callback: MutableBlankCallback)[src]

This is the callback that is triggered when a mouse triggers the button_up_inside event of the main PushButtonWidget.

Trait Implementations

impl Widget for PushButtonWidget[src]

Implementation of the PushButtonWidget object with the Widget traits implemented. The base widget is a BoxWidget, which overlays a TextWidget over the top. This Widget responds to the button down/up callbacks internally, and generates an on_clicked callback when appropriate.

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

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

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

Sets the Size for this widget and the base widget, given 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.

fn button_down(&mut self, _: i32, button: Button)[src]

Overrides button down.

fn button_up_inside(&mut self, _: i32, button: Button)[src]

Overrides button up inside, triggering an on_clicked callback.

fn button_up_outside(&mut self, _: i32, button: Button)[src]

Overrides button up outside.

fn draw(&mut self, c: Context, g: &mut G2d, clip: &DrawState)[src]

Draws the contents of the widget in this order:

  • Base widget first
  • Box graphic for the specified width

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 is_invalidated(&mut self) -> bool[src]

Checks to see whether or not the widget needs to be redrawn/refreshed.

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

Retrieves the Point of origin for this object. Defaults to origin (0, 0) if not set. Read more

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

Retrieves the Size bounds for this widget. Defaults to size (0, 0) if not set. Read more

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

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

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

Retrieves the secondary color of this widget. Defaults to black color [0.0, 0.0, 0.0, 1.0] if not set. Read more

fn perform_single_callback(&mut self, callback_id: u32, widget_id: i32)[src]

Performs a callback stored in the CallbackStore for this Widget, but only for the CallbackTypes::SingleCallback enum type. If the callback does not exist, or is not defined properly, it will be silently dropped and ignored. Read more

fn perform_bool_callback(
    &mut self,
    callback_id: u32,
    widget_id: i32,
    flag: bool
)
[src]

Performs a callback stored in the CallbackStore for this Widget, but only for the CallbackTypes::BoolCallback enum type. If the callback does not exist, or is not defined properly, it will be silently dropped and ignored. Read more

fn perform_point_callback(
    &mut self,
    callback_id: u32,
    widget_id: i32,
    point: Point
)
[src]

Performs a callback stored in the CallbackStore for this Widget, but only for the CallbackTypes::PointCallback enum type. If the callback does not exist, or is not defined properly, it will be silently dropped and ignored. Read more

fn perform_size_callback(
    &mut self,
    callback_id: u32,
    widget_id: i32,
    size: Size
)
[src]

Performs a callback stored in the CallbackStore for this Widget, but only for the CallbackTypes::SizeCallback enum type. If the callback does not exist, or is not defined properly, it will be silently dropped and ignored. Read more

fn perform_button_callback(
    &mut self,
    callback_id: u32,
    widget_id: i32,
    button: Button
)
[src]

fn perform_key_callback(
    &mut self,
    callback_id: u32,
    widget_id: i32,
    key: Key,
    state: ButtonState
)
[src]

Performs a callback stored in the CallbackStore for this Widget, but only for the CallbackTypes::KeyCallback enum type. If the callback does not exist, or is not defined properly, it will be silently dropped and ignored. Read more

fn key_pressed(&mut self, widget_id: i32, key: &Key, state: &ButtonState)[src]

Called when a keyboard event takes place within the bounds of a widget. Includes the widget ID, the key code that was affected, and its state - pressed or released. Read more

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

Called when a mouse enters the bounds of the widget. Includes the widget ID. Only override if you want to signal a mouse enter event. Read more

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

Called when a mouse exits the bounds of the widget. Includes the widget ID. Only override if you want to signal a mouse exit event. Read more

fn mouse_scrolled(&mut self, widget_id: i32, point: Point)[src]

Called when a scroll event is called within the bounds of the widget. Includes the widget ID. Only override if you want to signal a mouse scroll event. Read more

fn mouse_moved(&mut self, widget_id: i32, point: Point)[src]

Called when the mouse pointer is moved inside a widget. Includes the widget ID and point. Only override if you want to track mouse movement. Read more

fn window_resized(&mut self, widget_id: i32, size: Size)[src]

Called when the main window is resized. Includes the widget ID and the new window size. Only override if you want to respond to a window resize (and if the window is resizable.) Read more

fn window_focused(&mut self, widget_id: i32, focused: bool)[src]

Called when a window focus state changes. Includes the widget ID and a focus flag: true when window gains focus, false otherwise. Only override if you want to signal a window focus event. Read more

fn on_key_pressed(&mut self, callback: KeyCallback)[src]

fn on_mouse_entered(&mut self, callback: SingleCallback)[src]

Sets the closure action to be performed when a mouse enters a Widget.

fn on_mouse_exited(&mut self, callback: SingleCallback)[src]

Sets the closure action to be performed when a mouse exits a Widget.

fn on_mouse_scrolled(&mut self, callback: PointCallback)[src]

Sets the closure action to be performed when a mouse scrolls inside a Widget.

fn on_mouse_moved(&mut self, callback: PointCallback)[src]

Sets the closure action to be performed when a mouse moves within a Widget. The mouse point is based on the position within the Widget, not its Point relative to the window. Read more

fn on_window_resized(&mut self, callback: SizeCallback)[src]

Sets the window resize action to be performed when the window is resized.

fn on_focused(&mut self, callback: BoolCallback)[src]

Sets the window focused action to be performed when the window is (un)focused.

fn on_button_down(&mut self, callback: ButtonCallback)[src]

Sets the button click action to be performed when a mouse button is clicked.

fn on_button_up_inside(&mut self, callback: ButtonCallback)[src]

Sets the callback to be performed when a mouse button is released within the same Widget that it was pressed down inside. Read more

fn on_button_up_outside(&mut self, callback: ButtonCallback)[src]

Sets the callback to be performed when a mouse button is released outside of the same Widget that it was pressed down inside. Read more

Auto Trait Implementations

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 = Infallible

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

The type returned in the event of a conversion error.

impl<T> SetParameter for T

default 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