Tramway SDK v0.1.1
gui.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_FRAMEWORK_GUI_H
4#define TRAM_SDK_FRAMEWORK_GUI_H
5
6#include <framework/ui.h>
7
8namespace tram::Render {
9 class Sprite;
10}
11
12namespace tram::GUI {
13
14typedef uint32_t font_t;
15typedef uint32_t glyph_t;
16
17enum orientation : uint32_t {
22
26
38};
39
42 WIDGET
43};
44
45void Init();
46void Update();
48
49void SetScaling(uint32_t);
50uint32_t GetScaling();
51
52bool ClickHandled();
53
54void Begin();
55void End();
56
57void FillFrame(glyph_t glyph);
59void NewLine(uint32_t line = LINE_NORMAL);
60
61bool CheckBox(bool& selected, const char* text, bool enabled = true);
62bool RadioButton(uint32_t index, uint32_t& selected, const char* text, bool enabled = true);
63bool Button(const char* text, bool enabled = true, uint32_t width = 0);
64bool Slider(float& value, bool enabled = true, uint32_t width = 0);
65
66void Glyph(glyph_t glyph);
67void Text(const char* text, uint32_t orientation = TEXT_LEFT);
68bool TextBox(char* text, uint32_t length, bool enabled = true, uint32_t w = 0, uint32_t h = 0);
69void TextBox(const char* text, uint32_t w = 0, uint32_t h = 0);
70
75
77
78void PopFrameKeepCursor(bool = false, bool = true);
79void PushFrameRelative(uint32_t orientation, uint32_t offset);
80void PushFrameRelativeKeepCursor(uint32_t orientation, uint32_t offset, bool = false, bool = true);
81void PushFrame(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
82void PopFrame();
83
84
85
86
87void SetSelectedText(char* text);
88
99
103
141};
142
143}
144
145#endif // TRAM_SDK_FRAMEWORK_GUI_H
Sprite resource.
Definition: sprite.h:23
Immediate mode GUI system.
void HorizontalDivider()
Draws a horizontal divider.
Definition: gui.cpp:831
bool Slider(float &value, bool enabled, uint32_t width)
Draws a horizontal slider.
Definition: gui.cpp:771
void RestoreColor(GlyphType type)
Restores previous glyph color.
Definition: gui.cpp:138
bool RadioButton(uint32_t index, uint32_t &selected, const char *text, bool enabled)
Draws a radio button.
Definition: gui.cpp:703
void Update()
Submits all of the glyphs for rendering.
Definition: gui.cpp:253
void PushFrameRelativeKeepCursor(uint32_t orientation, uint32_t offset, bool keep_x, bool keep_y)
Pushes a frame, but keeps the cursor in place.
Definition: gui.cpp:609
void Text(const char *text, uint32_t orientation)
Draws text on the screen.
Definition: gui.cpp:472
orientation
Definition: gui.h:17
@ TEXT_RIGHT
Definition: gui.h:20
@ FRAME_RIGHT
Definition: gui.h:28
@ TEXT_LEFT
Definition: gui.h:18
@ LINE_LOW
Definition: gui.h:23
@ FRAME_CENTER_VERTICAL
Definition: gui.h:36
@ TEXT_JUSTIFIED
Definition: gui.h:21
@ FRAME_TOP
Definition: gui.h:29
@ FRAME_BOTTOM
Definition: gui.h:30
@ FRAME_RIGHT_INV
Definition: gui.h:32
@ LINE_NORMAL
Definition: gui.h:24
@ FRAME_CENTER_HORIZONTAL
Definition: gui.h:37
@ FRAME_INSET
Definition: gui.h:35
@ FRAME_TOP_INV
Definition: gui.h:33
@ LINE_HIGH
Definition: gui.h:25
@ TEXT_CENTER
Definition: gui.h:19
@ FRAME_BOTTOM_INV
Definition: gui.h:34
@ FRAME_LEFT_INV
Definition: gui.h:31
@ FRAME_LEFT
Definition: gui.h:27
void RestoreFont(GlyphType type)
Restores previous glyph font.
Definition: gui.cpp:147
void SetFont(font_t font, GlyphType type)
Sets the font.
Definition: gui.cpp:129
void SetSelectedText(char *text)
Sets the text which is selected in a textbox.
Definition: gui.cpp:79
void Init()
Performs initialization of the GUI system.
Definition: gui.cpp:206
bool TextBox(char *text, uint32_t length, bool enabled, uint32_t w, uint32_t h)
Draws a textbox.
Definition: gui.cpp:858
bool Button(const char *text, bool enabled, uint32_t width)
Draws a button.
Definition: gui.cpp:662
void PushFrameRelative(uint32_t orientation, uint32_t offset)
Pushes a frame releative to the previous.
Definition: gui.cpp:546
void PopFrameKeepCursor(bool keep_x, bool keep_y)
Definition: gui.cpp:617
widget
Definition: gui.h:89
@ WIDGET_BUTTON_1_WINDOW
Definition: gui.h:139
@ WIDGET_DIVIDER_HORIZONTAL
Definition: gui.h:120
@ WIDGET_RIGHT
Definition: gui.h:102
@ WIDGET_WINDOW
Definition: gui.h:110
@ WIDGET_BOTTOM_MIDDLE
Definition: gui.h:97
@ WIDGET_BUTTON_HELP
Definition: gui.h:137
@ WIDGET_TEXT_BOX
Definition: gui.h:115
@ WIDGET_TOP_LEFT
Definition: gui.h:90
@ WIDGET_SCROLL_BAR_TRACK_HORIZONTAL
Definition: gui.h:119
@ WIDGET_CHECK_BUTTON
Definition: gui.h:129
@ WIDGET_BORDER
Definition: gui.h:117
@ WIDGET_MIDDLE
Definition: gui.h:101
@ WIDGET_BUTTON_DISABLED
Definition: gui.h:108
@ WIDGET_SLIDER_TRACK_HORIZONTAL
Definition: gui.h:123
@ WIDGET_SCROLL_BAR_HORIZONTAL
Definition: gui.h:125
@ WIDGET_SCROLL_BAR_TRACK_VERTICAL
Definition: gui.h:118
@ WIDGET_MIDDLE_LEFT
Definition: gui.h:93
@ WIDGET_TOP_RIGHT
Definition: gui.h:92
@ WIDGET_SELECT_BOX
Definition: gui.h:112
@ WIDGET_SLIDER_HORIZONTAL
Definition: gui.h:131
@ WIDGET_BUTTON_PRESSED
Definition: gui.h:105
@ WIDGET_TEXT_BOX_DISABLED
Definition: gui.h:116
@ WIDGET_BUTTON_DOWN
Definition: gui.h:133
@ WIDGET_BOTTOM_RIGHT
Definition: gui.h:98
@ WIDGET_BUTTON_SELECTED_ENABLED
Definition: gui.h:106
@ WIDGET_SLIDER_TRACK_VERTICAL
Definition: gui.h:122
@ WIDGET_REVERSE_WINDOW
Definition: gui.h:111
@ WIDGET_BUTTON_SELECTED_DISABLED
Definition: gui.h:107
@ WIDGET_BUTTON_LEFT
Definition: gui.h:134
@ WIDGET_MIDDLE_MIDDLE
Definition: gui.h:94
@ WIDGET_SLIDER_VERTICAL
Definition: gui.h:130
@ WIDGET_DIVIDER_VERTICAL
Definition: gui.h:121
@ WIDGET_BUTTON_2_WINDOW
Definition: gui.h:138
@ WIDGET_DEFAULT
Definition: gui.h:140
@ WIDGET_TAB
Definition: gui.h:126
@ WIDGET_BUTTON_UP
Definition: gui.h:132
@ WIDGET_BUTTON
Definition: gui.h:104
@ WIDGET_LEFT
Definition: gui.h:100
@ WIDGET_BUTTON_PRESSED_DISABLED
Definition: gui.h:109
@ WIDGET_SELECT_BOX_PRESSED
Definition: gui.h:113
@ WIDGET_SCROLL_BAR_VERTICAL
Definition: gui.h:124
@ WIDGET_TOP_MIDDLE
Definition: gui.h:91
@ WIDGET_PROGESS_BAR
Definition: gui.h:127
@ WIDGET_BUTTON_EXIT
Definition: gui.h:136
@ WIDGET_MIDDLE_RIGHT
Definition: gui.h:95
@ WIDGET_SELECT_BOX_SELECTED
Definition: gui.h:114
@ WIDGET_BUTTON_RIGHT
Definition: gui.h:135
@ WIDGET_RADIO_BUTTON
Definition: gui.h:128
@ WIDGET_BOTTOM_LEFT
Definition: gui.h:96
bool ClickHandled()
Definition: gui.cpp:633
uint32_t GetScaling()
Returns the scaling factor.
Definition: gui.cpp:182
void SetColor(Render::color_t color, GlyphType type)
Sets the color.
Definition: gui.cpp:118
void PopFrame()
Removes a frame from the frame stack.
Definition: gui.cpp:602
void NewLine(uint32_t line)
Draws a new line.
Definition: gui.cpp:814
font_t RegisterFont(Render::Sprite *sprite)
Registers a font.
Definition: gui.cpp:307
void End()
Ends the GUI commands for the frame.
Definition: gui.cpp:976
void SetGlyphDefaults(Render::color_t color, font_t font, GlyphType type)
Overrides glyph default colors and fonts.
Definition: gui.cpp:159
void FillFrame(glyph_t glyph)
Fills the frame with a glyph.
Definition: gui.cpp:845
void PushFrame(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Pushes a frame.
Definition: gui.cpp:523
void SetScaling(uint32_t scale)
Sets the scaling factor.
Definition: gui.cpp:176
bool CheckBox(bool &selected, const char *text, bool enabled)
Draws a checkbox.
Definition: gui.cpp:737
void Glyph(font_t font, glyph_t glyph)
Draws a glyph from a font.
Definition: gui.cpp:405
uint32_t font_t
Definition: gui.h:14
GlyphType
Definition: gui.h:40
@ WIDGET
Definition: gui.h:42
@ TEXT
Definition: gui.h:41
void Begin()
Begins the GUI commands for the frame.
Definition: gui.cpp:946
uint32_t glyph_t
Definition: gui.h:15
High-level Render system API.
Definition: gui.h:8
vec3 color_t
Definition: render.h:16