[][src]Struct glerminal::menu_systems::Checkbox

pub struct Checkbox {
    pub fg_color_unfocused: [f32; 4],
    pub bg_color_unfocused: [f32; 4],
    pub fg_color_focused: [f32; 4],
    pub bg_color_focused: [f32; 4],
    pub button_press_inputs: Vec<VirtualKeyCode>,
    pub mouse_button_press_inputs: Vec<MouseButton>,
    // some fields omitted
}

Represents a Checkbox that can be checked or unchecked, and it's checked-status can be get with is_checked.

See CheckboxGroup to limit how checkboxes can be checked together.

For example:

use glerminal::menu_systems::Checkbox;

Checkbox::new("Generate world: ")
    .with_prefix("<")
    .with_suffix(">")
    .with_checked_text("O");

// Creates a checbox that looks unchecked:
// Generate world: < >
// And checked:
// Generate world: <O>

Fields

fg_color_unfocused: [f32; 4]

Foreground color for when the checkbox is not focused

bg_color_unfocused: [f32; 4]

Background color for when the checkbox is not focused

fg_color_focused: [f32; 4]

Foreground color for when the checkbox is focused

bg_color_focused: [f32; 4]

Background color for when the checkbox is focused

button_press_inputs: Vec<VirtualKeyCode>

The keyboard inputs that trigger was_just_pressed

mouse_button_press_inputs: Vec<MouseButton>

The mouse inputs that trigger was_just_pressed

Methods

impl Checkbox
[src]

pub fn new<T: Into<String>>(text: T) -> Checkbox
[src]

Intiailizes a Checkbox with the given text and max width

pub fn with_pos(self, pos: (u32, u32)) -> Checkbox
[src]

Sets the initial position

pub fn with_focused(self, focused: bool) -> Checkbox
[src]

Set whether the checkbox is initially focused or not

pub fn with_button_press_inputs(self, buttons: Vec<VirtualKeyCode>) -> Checkbox
[src]

Set the buttons which trigger was_just_pressed

pub fn with_mouse_button_press_inputs(
    self,
    buttons: Vec<MouseButton>
) -> Checkbox
[src]

Set the mouse buttons which trigger was_just_pressed

pub fn was_just_pressed(&self) -> bool
[src]

Returns whether buttons from mouse_button_press_inputs or button_press_inputs were pressed just now.

pub fn with_unfocused_colors(self, colors: ([f32; 4], [f32; 4])) -> Checkbox
[src]

Set the initial colors when it is unfocused

pub fn with_focused_colors(self, colors: ([f32; 4], [f32; 4])) -> Checkbox
[src]

Set the initial colors when it is focused

pub fn set_unfocused_colors(&mut self, colors: ([f32; 4], [f32; 4]))
[src]

Set the colors when it is unfocused

pub fn set_focused_colors(&mut self, colors: ([f32; 4], [f32; 4]))
[src]

Set the colors when it is focused

pub fn with_text<T: Into<String>>(self, text: T) -> Checkbox
[src]

Sets the initial text of the Checkbox

pub fn with_prefix<T: Into<String>>(self, prefix: T) -> Checkbox
[src]

Sets the initial prefix of the Checkbox

pub fn with_suffix<T: Into<String>>(self, suffix: T) -> Checkbox
[src]

Sets the initial suffix of the Checkbox

pub fn with_checked_text<T: Into<String>>(self, checked_text: T) -> Checkbox
[src]

Sets the initial checked-text (text shown in between prefix and suffix) of the Checkbox

pub fn with_checked(self, checked: bool) -> Checkbox
[src]

Set whether the checkbox is initially checked or not

pub fn set_text<T: Into<String>>(&mut self, text: T)
[src]

Sets the text of the Checkbox

pub fn set_prefix<T: Into<String>>(&mut self, prefix: T)
[src]

Sets the prefix of the Checkbox

pub fn set_suffix<T: Into<String>>(&mut self, suffix: T)
[src]

Sets the suffix of the Checkbox

pub fn set_checked_text<T: Into<String>>(self, checked_text: T)
[src]

Sets the checked-text (text shown in between prefix and suffix) of the Checkbox

pub fn get_text(&self) -> String
[src]

Return the current text of the Checkbox

pub fn get_prefix(&self) -> String
[src]

Return the current prefix of the Checkbox

pub fn get_suffix(&self) -> String
[src]

Return the current suffix of the Checkbox

pub fn set_checked(&mut self, checked: bool)
[src]

Sets the checked-status for this checkbox.

pub fn is_checked(&self) -> bool
[src]

Returns whether this checkbox is checked.

Trait Implementations

impl InterfaceItem for Checkbox
[src]

impl Clone for Checkbox
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Checkbox
[src]

Auto Trait Implementations

impl Send for Checkbox

impl Sync for Checkbox

Blanket Implementations

impl<T> InterfaceItemClone for T where
    T: 'static + InterfaceItem + Clone
[src]

impl<T> From for T
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[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> 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> Any for T where
    T: 'static + ?Sized
[src]