[][src]Struct glerminal::menu_systems::TextItem

pub struct TextItem {
    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>,
    pub max_width: u32,
    // some fields omitted
}

Represents a simple text item that by default can not be selected, but optionally can be selected and pressed like a button.

Example:

use glerminal::menu_systems::TextItem;

TextItem::new("Just a text label");
TextItem::new("A button that can be pressed").with_is_button(true);

Fields

fg_color_unfocused: [f32; 4]

Foreground color for when the button is not focused

bg_color_unfocused: [f32; 4]

Background color for when the button is not focused

fg_color_focused: [f32; 4]

Foreground color for when the button is focused

bg_color_focused: [f32; 4]

Background color for when the button 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

max_width: u32

The max width the text maximally cuts at

Methods

impl TextItem
[src]

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

Intiailizes a TextItem with the given text and gets the initial max width from the text width If the text might get bigger, use with_max_width or set_max_width.

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

Sets the initial position

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

Set whether the checkbox is initially focused or not

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

Set the buttons which trigger was_just_pressed

pub fn with_mouse_button_press_inputs(
    self,
    buttons: Vec<MouseButton>
) -> TextItem
[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])) -> TextItem
[src]

Set the initial colors when it is unfocused

pub fn with_focused_colors(self, colors: ([f32; 4], [f32; 4])) -> TextItem
[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_max_width(self, max_width: u32) -> TextItem
[src]

Sets the initial max width of the TextItem

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

Sets the initial text of the TextItem

pub fn with_is_button(self, is_button: bool) -> TextItem
[src]

Set whether this TextItem can be focused and used as a button

pub fn set_is_button(&mut self, is_button: bool)
[src]

Set whether this TextItem can be focused and used as a button

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

Sets the text of the TextItem

pub fn set_max_width(&mut self, max_width: u32)
[src]

Set the max width of the TextItem. This should ideally not be called, unless necessary.

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

Return the current text of the TextItem

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

Can this TextItem be focused and pressed like a button

Trait Implementations

impl InterfaceItem for TextItem
[src]

impl Clone for TextItem
[src]

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

Performs copy-assignment from source. Read more

impl Debug for TextItem
[src]

Auto Trait Implementations

impl Send for TextItem

impl Sync for TextItem

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]