![]() |
Gamedev Framework (gf)
0.2.0
A C++11 framework for 2D games
|
An immediate mode user interface class. More...
#include <gf/UI.h>

Public Member Functions | |
| UI (const UIRenderer &renderer, const UILayout &layout) | |
| Constructor. More... | |
| void | update (const Event &event) |
| Update the internal state with an event. More... | |
| void | clear () |
| Clear the internal state for this frame. More... | |
| bool | beginScrollArea (const std::string &name, const RectF &area, float *scroll) |
| Define the main widget. More... | |
| void | endScrollArea () |
| End the main widget. More... | |
| void | indent () |
| Increase the indent size. More... | |
| void | unindent () |
| Decrease the indent size. More... | |
| void | separator () |
| Add an invisible separator. More... | |
| void | separatorLine () |
| Add a separator line. More... | |
| bool | button (const std::string &text, bool enabled=true) |
| Add a button. More... | |
| bool | item (const std::string &text, bool enabled=true) |
| Add an item. More... | |
| bool | check (const std::string &text, bool checked, bool enabled=true) |
| Add a checkbox. More... | |
| bool | collapse (const std::string &text, bool checked, bool enabled=true) |
| Add a disclosure widget. More... | |
| void | label (const std::string &text) |
| Add a label. More... | |
| void | value (const std::string &text) |
| Add a value. More... | |
| bool | slider (const std::string &text, float *val, float vmin, float vmax, float vinc, bool enabled=true) |
| Add a slider. More... | |
| bool | cycle (const std::vector< std::string > &choices, std::size_t choice, bool enabled=true) |
| Add a cycle. More... | |
| virtual void | draw (RenderTarget &target, RenderStates states) override |
| Draw the object to a render target. More... | |
Public Member Functions inherited from gf::Drawable | |
| virtual | ~Drawable () |
| Virtual desctructor. More... | |
An immediate mode user interface class.
The result of the previous code is given in the following figure.
| gf::UI::UI | ( | const UIRenderer & | renderer, |
| const UILayout & | layout | ||
| ) |
Constructor.
| renderer | A renderer for user interface |
| layout | A layout for user interface |
| bool gf::UI::beginScrollArea | ( | const std::string & | name, |
| const RectF & | area, | ||
| float * | scroll | ||
| ) |
Define the main widget.
A scroll area is the main widget. It is the container for the other widgets. It may have a scrollbar on the right side if the widgets are too high.
| name | The name of the scroll area |
| area | The area of the scroll area |
| scroll | A pointer to the value of the scroll |
| bool gf::UI::button | ( | const std::string & | text, |
| bool | enabled = true |
||
| ) |
Add a button.
| text | The text on the button |
| enabled | True if the button can be pressed |
| bool gf::UI::check | ( | const std::string & | text, |
| bool | checked, | ||
| bool | enabled = true |
||
| ) |
Add a checkbox.
| text | The text of the checkbox |
| checked | True if the checkbox is checked |
| enabled | True if the checkbox can be checked |
| void gf::UI::clear | ( | ) |
Clear the internal state for this frame.
This function must be called at the beginning of every frame, before any other call to any function.
| bool gf::UI::collapse | ( | const std::string & | text, |
| bool | checked, | ||
| bool | enabled = true |
||
| ) |
Add a disclosure widget.
| text | The text of the widget |
| checked | True if the widget is expanded |
| enabled | True if the widget if enabled |
| bool gf::UI::cycle | ( | const std::vector< std::string > & | choices, |
| std::size_t | choice, | ||
| bool | enabled = true |
||
| ) |
Add a cycle.
| choices | The possible values of the cycles |
| choice | The current value of the cycle |
| enabled | True if the cycle is enabled |
|
overridevirtual |
Draw the object to a render target.
This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.
| target | Render target to draw to |
| states | Current render states |
Implements gf::Drawable.
| void gf::UI::endScrollArea | ( | ) |
End the main widget.
| void gf::UI::indent | ( | ) |
Increase the indent size.
After this call, all the widgets will be indented. It is possible to call this function multiple times.
| bool gf::UI::item | ( | const std::string & | text, |
| bool | enabled = true |
||
| ) |
Add an item.
| text | The text on the item |
| enabled | True if the item can be pressed |
| void gf::UI::label | ( | const std::string & | text | ) |
Add a label.
A label is a left aligned text
| text | The text of the label |
| void gf::UI::separator | ( | ) |
Add an invisible separator.
| void gf::UI::separatorLine | ( | ) |
Add a separator line.
| bool gf::UI::slider | ( | const std::string & | text, |
| float * | val, | ||
| float | vmin, | ||
| float | vmax, | ||
| float | vinc, | ||
| bool | enabled = true |
||
| ) |
Add a slider.
| text | The text of the slider |
| val | A pointer to the value of the slider |
| vmin | The minimum value of the slider |
| vmax | The maximum value of the slider |
| vinc | The increment of the slider |
| enabled | True if the slider is enabled |
| void gf::UI::unindent | ( | ) |
Decrease the indent size.
After this call, all the widgets will be unindented. It is possible to call this function multiple times.
| void gf::UI::update | ( | const Event & | event | ) |
Update the internal state with an event.
This function must be called for every event that occur in a frame.
| event | An event |
| void gf::UI::value | ( | const std::string & | text | ) |
1.8.8