GUI
|
Manages creating widgets and events and provides rutines governing GUI mechanisms. More...
#include <GUISystem.h>
Public Types | |
typedef std::map< EventType, CreateEventObject > | Map |
Public Member Functions | |
GUISystem () | |
Constructor. More... | |
~GUISystem () | |
Destructor. More... | |
void | setRenderer (Renderer *renderer) |
Sets Renderer object to be used. More... | |
Renderer * | getRenderer () |
Returns associated Renderer object. More... | |
void | render () |
Renders the gui. More... | |
void | addEventType (EventType eventType, CreateEventObject createFunc) |
Affililate event identifier with creating function. More... | |
void | handleEvents () |
Calls functions associated with events. More... | |
void | mouseAxes (int x, int y) |
Updates gui state. To be called when mouse is moved. More... | |
void | mouseButtonUp () |
Updates gui state. To be called when mouse button is released. More... | |
void | mouseButtonDown () |
Updates gui state. To be called when mouse is pressed. More... | |
void | keyChar (int unichar) |
Updates gui state. To be called when a character is typed or repeated. More... | |
void | keyDown (int keyCode) |
Updates gui state. To be called when a key is pressed. More... | |
Handle< Button > | addButton (int x, int y, int w, int h, std::string text) |
Creates Button widget and assings it to the gui. More... | |
Handle< TextField > | addTextField (int x, int y, int w, int h, std::string text) |
Creates TextField widget and assings it to the gui. More... | |
Handle< EditBox > | addEditBox (int x, int y, int w, int h, bool multiline=false) |
Creates EditBox widget and assings it to the gui. More... | |
Handle< Scrollbar > | addScrollbar (int x, int y, int w, int h) |
Creates Scrollbar widget and assings it to the gui. More... | |
Handle< Widget > | addWidget (CreateWidget createWidget, bool setEventQueue) |
Generic function for adding custom widgets. More... | |
Event | createEvent (EventType eventType) |
Creates an event that can be emitted. More... | |
EventObject * | createEventObject () |
Creates an EventObject object. More... | |
EventObject * | createMouseEvent () |
Creates an MouseEvent object with default values. More... | |
EventObject * | createKeyboardEvent () |
Creates an KeyboardEvent object. More... | |
Public Attributes | |
int | mouseX |
Mouse x coordinate. More... | |
int | mouseY |
Mouse y coordinate. More... | |
Private Attributes | |
Renderer * | renderer |
std::forward_list< Widget * > | widgets |
Map | createEvtObjFuncs |
EventQueue | eventQueue |
Widget * | focus |
Manages creating widgets and events and provides rutines governing GUI mechanisms.
Definition at line 23 of file GUISystem.h.
typedef std::map<EventType, CreateEventObject> GUISystem::Map |
Definition at line 26 of file GUISystem.h.
GUISystem::GUISystem | ( | ) |
Constructor.
Definition at line 9 of file GUISystem.cpp.
References addEventType(), createEventObject(), createKeyboardEvent(), createMouseEvent(), DISPLAY_CLOSE, KEY_DOWN, KEY_PRESS, KEY_UP, MOUSE_BUTTON_DOWN, MOUSE_BUTTON_UP, MOUSE_MOVE, and RESIZE.
GUISystem::~GUISystem | ( | ) |
Destructor.
Definition at line 27 of file GUISystem.cpp.
Handle< Button > GUISystem::addButton | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
std::string | text | ||
) |
Creates Button widget and assings it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
text | Text to be desplayed. |
Definition at line 147 of file GUISystem.cpp.
References EventQueue::addToQueue(), Renderer::color(), Button::downStateColor, eventQueue, Widget::guiSystem, Button::hoverStateColor, renderer, EventEmitter::setQueue(), Button::textColor, Button::upStateColor, and widgets.
Handle< EditBox > GUISystem::addEditBox | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
bool | multiline = false |
||
) |
Creates EditBox widget and assings it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
multiline | Are multiple lines allowed. |
Definition at line 180 of file GUISystem.cpp.
References EventQueue::addToQueue(), EditBox::backgroundColor, Renderer::color(), EditBox::cursorColor, eventQueue, EditBox::frameColor, Widget::guiSystem, renderer, EditBox::setMultiline(), EventEmitter::setQueue(), EditBox::textColor, and widgets.
void GUISystem::addEventType | ( | EventType | eventType, |
CreateEventObject | createFunc | ||
) |
Affililate event identifier with creating function.
eventType | Event type identifier |
createFunc | Function returning EventObject* pointer. |
Definition at line 271 of file GUISystem.cpp.
References createEvtObjFuncs.
Handle< Scrollbar > GUISystem::addScrollbar | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Creates Scrollbar widget and assings it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
Definition at line 201 of file GUISystem.cpp.
References EventQueue::addToQueue(), Scrollbar::backgroundColor, Renderer::color(), eventQueue, Scrollbar::frameColor, Widget::guiSystem, renderer, EventEmitter::setQueue(), and widgets.
Handle< TextField > GUISystem::addTextField | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
std::string | text | ||
) |
Creates TextField widget and assings it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
text | Text to be desplayed. |
Definition at line 165 of file GUISystem.cpp.
References EventQueue::addToQueue(), Renderer::color(), eventQueue, Widget::guiSystem, renderer, EventEmitter::setQueue(), TextField::textColor, and widgets.
Handle< Widget > GUISystem::addWidget | ( | CreateWidget | createWidget, |
bool | setEventQueue | ||
) |
Generic function for adding custom widgets.
createWidget | X Function creating widget. |
setEventQueue | If true, sets widget's addToQueue function. |
Definition at line 217 of file GUISystem.cpp.
References EventQueue::addToQueue(), eventQueue, Widget::guiSystem, EventEmitter::setQueue(), and widgets.
Creates an event that can be emitted.
eventType | Type of event |
Definition at line 233 of file GUISystem.cpp.
References createEvtObjFuncs.
EventObject * GUISystem::createEventObject | ( | ) |
Creates an EventObject object.
Definition at line 248 of file GUISystem.cpp.
EventObject * GUISystem::createKeyboardEvent | ( | ) |
Creates an KeyboardEvent object.
Definition at line 264 of file GUISystem.cpp.
EventObject * GUISystem::createMouseEvent | ( | ) |
Creates an MouseEvent object with default values.
Definition at line 255 of file GUISystem.cpp.
References MouseEvent::mouseX, mouseX, MouseEvent::mouseY, and mouseY.
|
inline |
Returns associated Renderer object.
Definition at line 50 of file GUISystem.h.
References addButton(), addEditBox(), addEventType(), addScrollbar(), addTextField(), addWidget(), createEvent(), createEventObject(), createKeyboardEvent(), createMouseEvent(), handleEvents(), keyChar(), keyDown(), mouseAxes(), mouseButtonDown(), mouseButtonUp(), render(), and renderer.
void GUISystem::handleEvents | ( | ) |
Calls functions associated with events.
Definition at line 49 of file GUISystem.cpp.
References EventQueue::empty(), eventQueue, and EventQueue::getNextEvent().
void GUISystem::keyChar | ( | int | unichar | ) |
Updates gui state. To be called when a character is typed or repeated.
Definition at line 131 of file GUISystem.cpp.
References focus, and Widget::keyChar().
void GUISystem::keyDown | ( | int | keyCode | ) |
Updates gui state. To be called when a key is pressed.
Definition at line 139 of file GUISystem.cpp.
References focus, and Widget::keyDown().
void GUISystem::mouseAxes | ( | int | x, |
int | y | ||
) |
Updates gui state. To be called when mouse is moved.
Definition at line 62 of file GUISystem.cpp.
References mouseX, mouseY, Widget::STATE_HOVER, Widget::STATE_UP, and widgets.
void GUISystem::mouseButtonDown | ( | ) |
Updates gui state. To be called when mouse is pressed.
Definition at line 101 of file GUISystem.cpp.
References focus, Widget::focusIn(), Widget::focusOut(), mouseX, mouseY, Widget::STATE_DOWN, Widget::stateChange(), and widgets.
void GUISystem::mouseButtonUp | ( | ) |
Updates gui state. To be called when mouse button is released.
Definition at line 90 of file GUISystem.cpp.
References Widget::STATE_UP, and widgets.
void GUISystem::render | ( | ) |
Renders the gui.
Definition at line 37 of file GUISystem.cpp.
References Renderer::clear(), renderer, Renderer::setTarget(), and widgets.
void GUISystem::setRenderer | ( | Renderer * | renderer | ) |
Sets Renderer object to be used.
renderer | Renderer* pointer |
Definition at line 32 of file GUISystem.cpp.
References renderer.
|
private |
Definition at line 188 of file GUISystem.h.
|
private |
Definition at line 189 of file GUISystem.h.
|
private |
Definition at line 191 of file GUISystem.h.
int GUISystem::mouseX |
Mouse x coordinate.
Definition at line 177 of file GUISystem.h.
int GUISystem::mouseY |
Mouse y coordinate.
Definition at line 181 of file GUISystem.h.
|
private |
Definition at line 186 of file GUISystem.h.
|
private |
Definition at line 187 of file GUISystem.h.