ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::ui Namespace Reference

Namespaces

namespace  detail
 

Classes

class  Button
 An interactive button widget. More...
 
struct  ButtonStyle
 How a button looks. Set on Theme::button for every button, or on Button::style for one button. More...
 
class  Checkbox
 A button that toggles between checked and unchecked. More...
 
struct  CheckboxStyle
 How a checkbox looks. Set on Theme::checkbox for every checkbox, or on Checkbox::checkbox_style for one checkbox. More...
 
class  Choice
 A button that cycles through a list of options, e.g. difficulty or window mode. More...
 
class  Context
 Shared state for the UI system. More...
 
class  FocusManager
 Manages focus navigation for UI widgets. More...
 
struct  FocusRingStyle
 
class  Grid
 Places children in a grid, filling each row left to right, e.g. a level select or a 2 by 2 menu. More...
 
class  Image
 A texture stretched over the widget, e.g. a logo or icon in a layout. More...
 
class  InputBox
 A text input widget. More...
 
struct  InputStyle
 How an input box looks. Set on Theme::input for every input box, or on InputBox::style for one input box. More...
 
class  Label
 A text display widget. More...
 
class  Modal
 A box over the rest of the UI that has to be dealt with first, e.g. a question or a login code. More...
 
struct  ModalStyle
 Look of a Modal and the dimmed screen behind it. More...
 
struct  Navigation
 Action names the UI reads for focus navigation, see asw/modules/action.h. More...
 
class  Panel
 A container widget with a background color or image. More...
 
class  Root
 Root container that manages the UI tree, input, and rendering. More...
 
class  Slider
 A horizontal slider for a value between min and max, e.g. volume. More...
 
struct  SliderStyle
 How a slider looks. Set on Theme::slider for every slider, or on Slider::style for one slider. More...
 
class  Stack
 Places children one after another, top to bottom or left to right. More...
 
struct  Theme
 Theme configuration for UI elements. More...
 
struct  Toast
 A short message shown at the top of the screen, see Root::toast. More...
 
struct  ToastStyle
 The ring drawn around the focused widget during keyboard or controller navigation. More...
 
struct  UIEvent
 Event structure for UI interactions. More...
 
class  VBox
 A vertical stack with padding, for a column of rows. More...
 
class  Widget
 Base class for all UI widgets. More...
 

Typedefs

using WidgetId = uint32_t
 Unique identifier type for widgets.
 

Enumerations

enum class  Direction { Vertical , Horizontal }
 Stack direction. More...
 
enum class  Align { Start , Center , End , Stretch }
 Where children sit across the stack: left to right for a vertical stack, top to bottom for a horizontal one. More...
 
enum class  BoxSide { Left , Right }
 Which side of a checkbox the box is on. More...
 
enum class  Anchor {
  None , TopLeft , Top , TopRight ,
  Left , Center , Right , BottomLeft ,
  Bottom , BottomRight
}
 A point of the parent an anchored widget sits at, see Widget::anchor. More...
 

Functions

bool in_row_with_focusables (const Widget &w)
 Whether a widget sits in a row with other widgets that can take focus: its parent is a horizontal Stack, or a Grid with more than one column, holding another visible, enabled, focusable child.
 
Navigation bind_default_navigation (std::string_view prefix="ui_")
 Bind keyboard and controller actions for UI navigation and return their names. Calling it again replaces the bindings.
 
const asw::Font & pick_font (const asw::Font &own, const Theme &theme)
 The font a widget draws with: its own, or the theme font.
 
void draw_focus_ring (const FocusRingStyle &style, const asw::Quad< float > &bounds)
 Draw a focus ring around a widget.
 

Typedef Documentation

◆ WidgetId

using asw::ui::WidgetId = uint32_t

Unique identifier type for widgets.

Definition at line 39 of file widget.h.

Enumeration Type Documentation

◆ Align

enum class asw::ui::Align
strong

Where children sit across the stack: left to right for a vertical stack, top to bottom for a horizontal one.

Enumerator
Start 
Center 
End 
Stretch 

Children fill the stack across.

Definition at line 30 of file layout.h.

◆ Anchor

enum class asw::ui::Anchor
strong

A point of the parent an anchored widget sits at, see Widget::anchor.

Enumerator
None 
TopLeft 
Top 
TopRight 
Left 
Center 
Right 
BottomLeft 
Bottom 
BottomRight 

Definition at line 24 of file widget.h.

◆ BoxSide

enum class asw::ui::BoxSide
strong

Which side of a checkbox the box is on.

Enumerator
Left 
Right 

Definition at line 58 of file theme.h.

◆ Direction

enum class asw::ui::Direction
strong

Stack direction.

Enumerator
Vertical 
Horizontal 

Definition at line 22 of file layout.h.

Function Documentation

◆ bind_default_navigation()

asw::ui::Navigation asw::ui::bind_default_navigation ( std::string_view prefix = "ui_")

Bind keyboard and controller actions for UI navigation and return their names. Calling it again replaces the bindings.

Binds, for any controller:

  • up, down, left, right: arrow keys, D-pad and left stick
  • next: Tab and right shoulder, prev: left shoulder
  • activate: Return, Space and A
  • back: Escape and B
Parameters
prefixPrefix for the action names, e.g. "ui_" gives "ui_up".
Returns
The action names, to set on Context::navigation.

Definition at line 37 of file navigation.cpp.

◆ draw_focus_ring()

void asw::ui::draw_focus_ring ( const FocusRingStyle & style,
const asw::Quad< float > & bounds )

Draw a focus ring around a widget.

Parameters
styleThe ring style.
boundsThe widget bounds.

Definition at line 5 of file theme.cpp.

◆ in_row_with_focusables()

bool asw::ui::in_row_with_focusables ( const Widget & w)

Whether a widget sits in a row with other widgets that can take focus: its parent is a horizontal Stack, or a Grid with more than one column, holding another visible, enabled, focusable child.

Value widgets (Choice, Slider) use this to leave left and right for moving between the widgets in the row.

Parameters
wThe widget.
Returns
True if left and right should move focus within the row.

Definition at line 138 of file layout.cpp.

◆ pick_font()

const asw::Font & asw::ui::pick_font ( const asw::Font & own,
const Theme & theme )
inline

The font a widget draws with: its own, or the theme font.

Parameters
ownThe widget's font, may be empty.
themeThe theme.
Returns
The font to use, may be empty if neither is set.

Definition at line 304 of file theme.h.