Struct direct_gui::controls::Button
[−]
[src]
pub struct Button<S> { /* fields omitted */ }
A button widget that can be rendered in multiple ways:
Flat
: using a simpel pixel rectangle algorithm.
Image
: using a spritesheet divided into 3 parts for rendering its state.
Methods
impl<S> Button<S>
[src]
fn pos(&self) -> (i32, i32)
[src]
Retrieve the position.
fn with_pos(self, x: i32, y: i32) -> Self
[src]
Map a position.
fn set_pos(&mut self, x: i32, y: i32)
[src]
Change the position.
fn pressed(&self) -> bool
[src]
Get if the button is currently pressed.
fn with_callback(self, func: fn(_: &mut Button<S>, _: ButtonState)) -> Self
[src]
Set the event to a closure which will be called if the button state changes.
impl Button<Flat>
[src]
impl Button<Image>
[src]
fn new_with_sprite(sprite_ref: SpriteRef) -> Self
[src]
Create a new button with a sprite without text.
The button image needs to be 3 buttons divided vertically: 1. normal state 2. mouse hover state 3. mouse pressed state
+-------+ |Normal | +-------+ | Hover | +-------+ |Pressed| +-------+
Trait Implementations
impl Control for Button<Flat>
[src]
fn update(&mut self, args: &ControlState, _res: &Resources)
[src]
Update the control.
fn draw(&self, buffer: &mut Vec<u32>, buffer_width: usize, _res: &Resources)
[src]
Draw the control on the output buffer.
fn control_type(&self) -> ControlType
[src]
Retrieve what type of control this is.
fn as_any(&self) -> &Any
[src]
For downcasting.
fn as_any_mut(&mut self) -> &mut Any
[src]
For downcasting.
impl Control for Button<Image>
[src]
fn update(&mut self, args: &ControlState, res: &Resources)
[src]
Update the control.
fn draw(&self, buffer: &mut Vec<u32>, buffer_width: usize, res: &Resources)
[src]
Draw the control on the output buffer.
fn control_type(&self) -> ControlType
[src]
Retrieve what type of control this is.
fn as_any(&self) -> &Any
[src]
For downcasting.
fn as_any_mut(&mut self) -> &mut Any
[src]
For downcasting.