A collection of common widgets, such as buttons, sliders, and scroll bars.
More...
Detailed Description
A collection of common widgets, such as buttons, sliders, and scroll bars.
This file contains some common widgets that will be widely useful.
FlatUI is structured to be very compositional, meaning that no one widget will always be universally useful for every UI. This means that these widgets are intended for the average UI, but may not be sufficient for custom use cases that extend beyond the scope of these widgets. Therefore these widgets may also serve as building blocks, or as examples, to easily build your own specialized widgets.
Enumerations
enum
flatui::ButtonProperty {
kButtonPropertyDisabled = 1,
kButtonPropertyImageLeft = 2,
kButtonPropertyImageRight = 4
}
Specifies the button properties used in common widgets.
More...
Functions
The bitwise OR operator for ButtonProperties.
More...
The bitwise OR assignment operator for ButtonProperties.
More...
Some of the widgets provide user feedback by rendering a transparent background color to signal that the user is hovering over or clicking/touching/interacting with the widget.
More...
A simple button showing clickable text.
More...
Event
flatui::ImageButton (const fplbase::Texture &texture, float size, const Margin &margin, const char *id)
A simple button showing a clickable image.
More...
Event
flatui::ToggleImageButton (const fplbase::Texture &up_texture, const fplbase::Texture &down_texture, float size, const Margin &margin, const char *id)
A button showing a different image when clicked or not.
More...
Event
flatui::TextButton (const fplbase::Texture &texture, const Margin &texture_margin, const char *text, float size, const Margin &margin, const ButtonProperty property)
A simple button showing clickable text with an image shown beside it.
More...
Event
flatui::CheckBox (const fplbase::Texture &texture_checked, const fplbase::Texture &texture_unchecked, const char *label, float size, const Margin &margin, bool *is_checked)
A checkbox with a label next to it.
More...
Event
flatui::Slider (const fplbase::Texture &tex_bar, const fplbase::Texture &tex_knob, const mathfu::vec2 &size, float bar_height, const char *id, float *slider_value)
A clider to change a numeric value.
More...
Event
flatui::ScrollBar (const fplbase::Texture &tex_background, const fplbase::Texture &tex_foreground, const mathfu::vec2 &size, float bar_size, const char *id, float *scroll_value)
A scrollbar to indicate position in a scroll view.
More...
Sets a background color of the widget based on the event status.
More...
Enumeration Type Documentation
Specifies the button properties used in common widgets.
kButtonPropertyDisabled disables buttons (CheckEvent() calls will be skipped). kButtonPropertyImageLeft shows the specified image to the left of the text label in a TextButton. kButtonPropertyImageRight shows the specified image to the right of the text label in a TextButton.
Function Documentation
Event flatui::CheckBox
(
const fplbase::Texture &
texture_checked,
const fplbase::Texture &
texture_unchecked,
const char *
label,
float
size,
const Margin &
margin,
bool *
is_checked
)
A checkbox with a label next to it.
- Parameters
-
[in] texture_checked A const reference to the Texture for when the box is checked.
[in] texture_unchecked A const reference to the Texture for when the box is unchecked.
[in] label A C-string to be used as the label that appears next to the checkbox.
[in] size A float corresponding to the size of the checkbox and label.
[in] margin A
Margin around the checkbox.
[in,out] is_checked A pointer to a bool determining if the checkbox is checked or not. It will capture the output of the kEventWentUp as well.
- Returns
- Returns the Event type for the checkbox.
void flatui::EventBackground
(
Event
event )
Sets a background color of the widget based on the event status.
If the event is kEventIsDown, the background color used will be the click_color. If the event is kEventHover, the background color used will be hover_color.
- Parameters
-
[in] event The Event type used to determine the background color.
Event flatui::ImageButton
(
const fplbase::Texture &
texture,
float
size,
const Margin &
margin,
const char *
id
)
A simple button showing a clickable image.
- Note
- Uses the colors that are set via
SetHoverClickColor.
- Parameters
-
[in] texture The Texture of the image to display.
[in] size A float indicating the vertical height.
[in] margin A
Margin around the
texture.
[in] id A C-string to uniquely identify the button.
- Returns
- Returns the Event type for the button.
ButtonProperty flatui::operator|
(
ButtonProperty
a,
ButtonProperty
b
)
inline
The bitwise OR operator for ButtonProperties.
E.g. c = a | b;
- Parameters
-
[in] a The first ButtonProperty whose int value should be used in the bitwise OR.
[in] b The second ButtonProperty whose int value should be used in the bitwise OR.
- Returns
- Returns a new ButtonProperty that is formed from the result of the bitwise OR of the two input ButtonProperties'
int values.
ButtonProperty flatui::operator|=
(
ButtonProperty &
a,
const ButtonProperty &
b
)
inline
The bitwise OR assignment operator for ButtonProperties.
E.g. a |= b;
- Parameters
-
[in] a The modifiable ButtonProperty lvalue whose int value should be used in the bitwise OR. It also captures the return value of the function.
[in] b The second ButtonProperty whose int value is used in the bitwise OR.
- Returns
- Returns a new ButtonProperty that is formed from the result of the bitwise OR of the two input ButtonProperties'
int values.
Event flatui::ScrollBar
(
const fplbase::Texture &
tex_background,
const fplbase::Texture &
tex_foreground,
const mathfu::vec2 &
size,
float
bar_size,
const char *
id,
float *
scroll_value
)
A scrollbar to indicate position in a scroll view.
- Note
- The background and foreground Textures must be a ninepatch texture.
- Parameters
-
[in] tex_background A const Texture reference for the background.
[in] tex_foreground A const Texture reference for the foreground.
[in] size A const vec2 reference to specify the whole size, including the margin, and the relative size of the scroll bar.
[in] bar_size A float corresponding to the size of the scroll bar.
[in] id A C-string to uniquely identify the scroll bar.
[out] scroll_value A pointer to a float between 0.0 and 1.0 inclusive, which contains the position of the slider.
- Returns
- Returns the Event type for the scroll bar.
void flatui::SetHoverClickColor
(
const mathfu::vec4 &
hover_color,
const mathfu::vec4 &
click_color
)
Some of the widgets provide user feedback by rendering a transparent background color to signal that the user is hovering over or clicking/touching/interacting with the widget.
Be default, these are a dark grey and a medium grey, respectively. Both are semi-transparent.
- Parameters
-
[in] hover_color A const vec4 reference to the RGBA color values to use when hovering over a widget.
[in] click_color A const vec4 reference to the RGBA color values to use when clicking on a widget.
Event flatui::Slider
(
const fplbase::Texture &
tex_bar,
const fplbase::Texture &
tex_knob,
const mathfu::vec2 &
size,
float
bar_height,
const char *
id,
float *
slider_value
)
A clider to change a numeric value.
- Parameters
-
[in] tex_bar The Texture for the slider. Typically this is a bar of some kind as a ninepatch texture.
[in] tex_knob The Texture for the knob to move on top of the tex_bar.
[in] size A const vec2 reference to specify the whole size, including the margin, and relative size of the slider.
[in] bar_height A float corresponding the the Y ratio of the bar (usually 0.5).
[in] id A C-string to uniquely identify the slider.
[out] slider_value A pointer to a float between 0.0 and 1.0 inclusive, which contains the position of the slider.
Event flatui::TextButton
(
const char *
text,
float
size,
const Margin &
margin
)
A simple button showing clickable text.
- Note
- Uses the colors that are set via
SetHoverClickColor.
- Parameters
-
[in] text A C-string of text to display on the button.
[in] size A float indicating the vertical height.
[in] margin A
Margin that should be placed around the text.
- Returns
- Returns the Event type for the button.
Event flatui::TextButton
(
const fplbase::Texture &
texture,
const Margin &
texture_margin,
const char *
text,
float
size,
const Margin &
margin,
const ButtonProperty
property
)
A simple button showing clickable text with an image shown beside it.
- Note
- Uses the colors that are set via
SetHoverClickColor.
- Parameters
-
[in] texture The Texture of the image to display beside the button.
[in] texture_margin The
Margin around the
texture.
[in] text A C-string of text to display on the button.
[in] size A float indicating the vertical height.
[in] margin A
Margin that should be placed around the text.
[in] property A ButtonProperty enum corresponding to where the image should be placed, relative to the button.
- Returns
- Returns the Event type for the button.
Event flatui::ToggleImageButton
(
const fplbase::Texture &
up_texture,
const fplbase::Texture &
down_texture,
float
size,
const Margin &
margin,
const char *
id
)
A button showing a different image when clicked or not.
- Parameters
-
[in] up_texture The Texture of the image to display if not clicked.
[in] down_texture The Texture of the image to display if clicked.
[in] size A float indicating the vertical height.
[in] margin A
Margin around the
texture.
[in] id A C-string to uniquely identify the button.
- Returns
- Returns the Event type for the button.