Tramway SDK
Classes | Typedefs | Enumerations | Functions | Variables
tram::GUI Namespace Reference

Classes

struct  FrameObject
 

Typedefs

typedef uint32_t font_t
 
typedef uint32_t glyph_t
 

Enumerations

enum  orientation : uint32_t {
  TEXT_LEFT , TEXT_CENTER , TEXT_RIGHT , TEXT_JUSTIFIED ,
  LINE_LOW , LINE_NORMAL , LINE_HIGH , FRAME_LEFT ,
  FRAME_RIGHT , FRAME_TOP , FRAME_BOTTOM , FRAME_LEFT_INV ,
  FRAME_RIGHT_INV , FRAME_TOP_INV , FRAME_BOTTOM_INV , FRAME_INSET
}
 
enum  widget : glyph_t {
  WIDGET_TOP_LEFT = 0 , WIDGET_TOP_MIDDLE = 1 , WIDGET_TOP_RIGHT = 2 , WIDGET_MIDDLE_LEFT = 3 ,
  WIDGET_MIDDLE_MIDDLE = 4 , WIDGET_MIDDLE_RIGHT = 5 , WIDGET_BOTTOM_LEFT = 6 , WIDGET_BOTTOM_MIDDLE = 7 ,
  WIDGET_BOTTOM_RIGHT = 8 , WIDGET_LEFT = 0 , WIDGET_MIDDLE = 1 , WIDGET_RIGHT = 2 ,
  WIDGET_BUTTON = 0 , WIDGET_BUTTON_PRESSED = 9 , WIDGET_BUTTON_SELECTED_ENABLED = 18 , WIDGET_BUTTON_SELECTED_DISABLED = 27 ,
  WIDGET_BUTTON_DISABLED = 36 , WIDGET_BUTTON_PRESSED_DISABLED = 45 , WIDGET_WINDOW = 54 , WIDGET_REVERSE_WINDOW = 63 ,
  WIDGET_SELECT_BOX = 72 , WIDGET_SELECT_BOX_PRESSED = 81 , WIDGET_SELECT_BOX_SELECTED = 90 , WIDGET_TEXT_BOX = 99 ,
  WIDGET_TEXT_BOX_DISABLED = 108 , WIDGET_BORDER = 117 , WIDGET_SCROLL_BAR_TRACK_VERTICAL = 126 , WIDGET_SCROLL_BAR_TRACK_HORIZONTAL = 129 ,
  WIDGET_DIVIDER_HORIZONTAL = 132 , WIDGET_DIVIDER_VERTICAL = 135 , WIDGET_SLIDER_TRACK_VERTICAL = 138 , WIDGET_SLIDER_TRACK_HORIZONTAL = 138 ,
  WIDGET_SCROLL_BAR_VERTICAL = 144 , WIDGET_SCROLL_BAR_HORIZONTAL = 147 , WIDGET_TAB = 150 , WIDGET_PROGESS_BAR = 153 ,
  WIDGET_RADIO_BUTTON = 156 , WIDGET_CHECK_BUTTON = 162 , WIDGET_SLIDER_VERTICAL = 168 , WIDGET_SLIDER_HORIZONTAL = 174 ,
  WIDGET_BUTTON_UP = 180 , WIDGET_BUTTON_DOWN = 186 , WIDGET_BUTTON_LEFT = 192 , WIDGET_BUTTON_RIGHT = 198 ,
  WIDGET_BUTTON_EXIT = 204 , WIDGET_BUTTON_HELP = 210 , WIDGET_BUTTON_2_WINDOW = 216 , WIDGET_BUTTON_1_WINDOW = 222 ,
  WIDGET_DEFAULT = 255
}
 

Functions

void SetColor (vec3 color)
 
void SetScaling (uint32_t scale)
 
uint32_t GetScaling ()
 
void Init ()
 Performs initialization of the GUI system. More...
 
void UpdateDrawListFonts ()
 Submits registered fonts to the renderer. More...
 
void Update ()
 Submits all of the glyphs for rendering. More...
 
font_t RegisterFont (Render::Sprite *sprite)
 Registers a font. More...
 
void SetGlyph (float x, float y, float z, float w, float h, float tex_x, float tex_y, float tex_w, float tex_h, const vec3 &color, font_t font)
 Adds a glyph to rendering list. More...
 
uint32_t GlyphWidth (font_t font, glyph_t glyph)
 
uint32_t GlyphHeight (font_t font, glyph_t glyph)
 
uint32_t GlyphBorderV (font_t font, glyph_t glyph)
 
void DrawGlyph (font_t font, glyph_t glyph, uint32_t x, uint32_t y, uint32_t w=0, uint32_t h=0)
 
void Glyph (font_t font, glyph_t glyph)
 
void DrawBox (font_t font, glyph_t glyph, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 Draws a glyph box. More...
 
uint32_t TextWidth (font_t font, const char *text)
 
void Text (font_t font, const char *text, uint32_t orientation)
 
void DrawBoxHorizontal (font_t font, glyph_t glyph, uint32_t x, uint32_t y, uint32_t w)
 
void PushFrame (uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 
void PushFrameRelative (uint32_t orientation, uint32_t offset)
 
void PopFrame ()
 
bool CursorOver (uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 
bool ClickHandled ()
 
bool Clicked ()
 
bool Button (const char *text, bool enabled, uint32_t width)
 
bool RadioButton (uint32_t index, uint32_t &selected, const char *text, bool enabled)
 
bool CheckBox (bool &selected, const char *text, bool enabled)
 
bool Slider (float &value, bool enabled, uint32_t width)
 
void NewLine (uint32_t line)
 
void HorizontalDivider ()
 
void FillFrame (font_t font, glyph_t glyph)
 
bool TextBox (char *text, uint32_t length, bool enabled, uint32_t w, uint32_t h)
 
void TextBox (const char *text, uint32_t w, uint32_t h)
 
void Begin ()
 
void End ()
 

Variables

Stack< FrameObjectframe_stack ("GUI Frame stack", 100)
 
Render::Spritefonts [16] = {nullptr}
 
Render::vertexarray_t glyphvertices_vertex_array = {.generic = 0}
 
Render::drawlistentry_t glyphvertices_entry
 
std::vector< Render::SpriteVertexglyphvertices
 
bool mouse_click_not_handled = true
 

Typedef Documentation

◆ font_t

typedef uint32_t tram::GUI::font_t

◆ glyph_t

typedef uint32_t tram::GUI::glyph_t

Enumeration Type Documentation

◆ orientation

enum tram::GUI::orientation : uint32_t
Enumerator
TEXT_LEFT 
TEXT_CENTER 
TEXT_RIGHT 
TEXT_JUSTIFIED 
LINE_LOW 
LINE_NORMAL 
LINE_HIGH 
FRAME_LEFT 
FRAME_RIGHT 
FRAME_TOP 
FRAME_BOTTOM 
FRAME_LEFT_INV 
FRAME_RIGHT_INV 
FRAME_TOP_INV 
FRAME_BOTTOM_INV 
FRAME_INSET 

◆ widget

Enumerator
WIDGET_TOP_LEFT 
WIDGET_TOP_MIDDLE 
WIDGET_TOP_RIGHT 
WIDGET_MIDDLE_LEFT 
WIDGET_MIDDLE_MIDDLE 
WIDGET_MIDDLE_RIGHT 
WIDGET_BOTTOM_LEFT 
WIDGET_BOTTOM_MIDDLE 
WIDGET_BOTTOM_RIGHT 
WIDGET_LEFT 
WIDGET_MIDDLE 
WIDGET_RIGHT 
WIDGET_BUTTON 
WIDGET_BUTTON_PRESSED 
WIDGET_BUTTON_SELECTED_ENABLED 
WIDGET_BUTTON_SELECTED_DISABLED 
WIDGET_BUTTON_DISABLED 
WIDGET_BUTTON_PRESSED_DISABLED 
WIDGET_WINDOW 
WIDGET_REVERSE_WINDOW 
WIDGET_SELECT_BOX 
WIDGET_SELECT_BOX_PRESSED 
WIDGET_SELECT_BOX_SELECTED 
WIDGET_TEXT_BOX 
WIDGET_TEXT_BOX_DISABLED 
WIDGET_BORDER 
WIDGET_SCROLL_BAR_TRACK_VERTICAL 
WIDGET_SCROLL_BAR_TRACK_HORIZONTAL 
WIDGET_DIVIDER_HORIZONTAL 
WIDGET_DIVIDER_VERTICAL 
WIDGET_SLIDER_TRACK_VERTICAL 
WIDGET_SLIDER_TRACK_HORIZONTAL 
WIDGET_SCROLL_BAR_VERTICAL 
WIDGET_SCROLL_BAR_HORIZONTAL 
WIDGET_TAB 
WIDGET_PROGESS_BAR 
WIDGET_RADIO_BUTTON 
WIDGET_CHECK_BUTTON 
WIDGET_SLIDER_VERTICAL 
WIDGET_SLIDER_HORIZONTAL 
WIDGET_BUTTON_UP 
WIDGET_BUTTON_DOWN 
WIDGET_BUTTON_LEFT 
WIDGET_BUTTON_RIGHT 
WIDGET_BUTTON_EXIT 
WIDGET_BUTTON_HELP 
WIDGET_BUTTON_2_WINDOW 
WIDGET_BUTTON_1_WINDOW 
WIDGET_DEFAULT 

Function Documentation

◆ Begin()

void tram::GUI::Begin ( )

◆ Button()

bool tram::GUI::Button ( const char *  text,
bool  enabled,
uint32_t  width 
)

◆ CheckBox()

bool tram::GUI::CheckBox ( bool &  selected,
const char *  text,
bool  enabled 
)

◆ Clicked()

bool tram::GUI::Clicked ( )

◆ ClickHandled()

bool tram::GUI::ClickHandled ( )

◆ CursorOver()

bool tram::GUI::CursorOver ( uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h 
)

◆ DrawBox()

void tram::GUI::DrawBox ( font_t  font,
glyph_t  glyph,
uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h 
)

Draws a glyph box.

◆ DrawBoxHorizontal()

void tram::GUI::DrawBoxHorizontal ( font_t  font,
glyph_t  glyph,
uint32_t  x,
uint32_t  y,
uint32_t  w 
)

◆ DrawGlyph()

void tram::GUI::DrawGlyph ( font_t  font,
glyph_t  glyph,
uint32_t  x,
uint32_t  y,
uint32_t  w = 0,
uint32_t  h = 0 
)

◆ End()

void tram::GUI::End ( )

◆ FillFrame()

void tram::GUI::FillFrame ( font_t  font,
glyph_t  glyph 
)

◆ GetScaling()

uint32_t tram::GUI::GetScaling ( )

◆ Glyph()

void tram::GUI::Glyph ( font_t  font,
glyph_t  glyph 
)

◆ GlyphBorderV()

uint32_t tram::GUI::GlyphBorderV ( font_t  font,
glyph_t  glyph 
)

◆ GlyphHeight()

uint32_t tram::GUI::GlyphHeight ( font_t  font,
glyph_t  glyph 
)

◆ GlyphWidth()

uint32_t tram::GUI::GlyphWidth ( font_t  font,
glyph_t  glyph 
)

◆ HorizontalDivider()

void tram::GUI::HorizontalDivider ( )

◆ Init()

void tram::GUI::Init ( )

Performs initialization of the GUI system.

Render system must be initialized first.

◆ NewLine()

void tram::GUI::NewLine ( uint32_t  line)

◆ PopFrame()

void tram::GUI::PopFrame ( )

◆ PushFrame()

void tram::GUI::PushFrame ( uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h 
)

◆ PushFrameRelative()

void tram::GUI::PushFrameRelative ( uint32_t  orientation,
uint32_t  offset 
)

◆ RadioButton()

bool tram::GUI::RadioButton ( uint32_t  index,
uint32_t &  selected,
const char *  text,
bool  enabled 
)

◆ RegisterFont()

font_t tram::GUI::RegisterFont ( Render::Sprite sprite)

Registers a font.

Returns
Font handle that can be used with all of the GUI widget functions.

◆ SetColor()

void tram::GUI::SetColor ( vec3  color)

◆ SetGlyph()

void tram::GUI::SetGlyph ( float  x,
float  y,
float  z,
float  w,
float  h,
float  tex_x,
float  tex_y,
float  tex_w,
float  tex_h,
const vec3 color,
font_t  font 
)

Adds a glyph to rendering list.

Triangularizes a glyph from its params and then it get sent off to rendering via the glyph rendering list.

◆ SetScaling()

void tram::GUI::SetScaling ( uint32_t  scale)

◆ Slider()

bool tram::GUI::Slider ( float &  value,
bool  enabled,
uint32_t  width 
)

◆ Text()

void tram::GUI::Text ( font_t  font,
const char *  text,
uint32_t  orientation 
)

◆ TextBox() [1/2]

bool tram::GUI::TextBox ( char *  text,
uint32_t  length,
bool  enabled,
uint32_t  w,
uint32_t  h 
)

◆ TextBox() [2/2]

void tram::GUI::TextBox ( const char *  text,
uint32_t  w,
uint32_t  h 
)

◆ TextWidth()

uint32_t tram::GUI::TextWidth ( font_t  font,
const char *  text 
)

◆ Update()

void tram::GUI::Update ( )

Submits all of the glyphs for rendering.

◆ UpdateDrawListFonts()

void tram::GUI::UpdateDrawListFonts ( )

Submits registered fonts to the renderer.

Variable Documentation

◆ fonts

Render::Sprite* tram::GUI::fonts[16] = {nullptr}

◆ frame_stack

Stack< FrameObject > tram::GUI::frame_stack("GUI Frame stack", 100) ( "GUI Frame stack"  ,
100   
)

◆ glyphvertices

std::vector<Render::SpriteVertex> tram::GUI::glyphvertices

◆ glyphvertices_entry

Render::drawlistentry_t tram::GUI::glyphvertices_entry

◆ glyphvertices_vertex_array

Render::vertexarray_t tram::GUI::glyphvertices_vertex_array = {.generic = 0}

◆ mouse_click_not_handled

bool tram::GUI::mouse_click_not_handled = true