GUI
|
Manages creating widgets and events and provides routines governing GUI mechanisms. More...
#include <GUISystem.h>
Public Types | |
typedef std::map< EventType, CreateEventObject > | Map |
Public Member Functions | |
GUISystem () | |
~GUISystem () | |
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) |
Affiliates event identifier with creating function. More... | |
void | handleEvents () |
Calls functions associated with events. More... | |
void | mouseMove (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 assigns it to the gui. More... | |
Handle< TextField > | addTextField (int x, int y, int w, int h, std::string text) |
Creates TextField widget and assigns it to the gui. More... | |
Handle< EditBox > | addEditBox (int x, int y, int w, int h, bool multiline=false) |
Creates EditBox widget and assigns it to the gui. More... | |
Handle< Scrollbar > | addScrollbar (int x, int y, int w, int h) |
Creates Scrollbar widget and assigns 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... | |
Event | cloneEvent (const Event &event) |
Creates a copy of an Event object. More... | |
EventObject * | createNull (EventObject *obj=NULL) |
Returns null pointer. More... | |
EventObject * | createEventObject (EventObject *obj=NULL) |
Creates an EventObject object. More... | |
EventObject * | createMouseEvent (EventObject *obj=NULL) |
Creates an MouseEvent object with default values. More... | |
EventObject * | createKeyboardEvent (EventObject *obj=NULL) |
Creates an KeyboardEvent object. More... | |
Public Attributes | |
int | mouseX |
int | mouseY |
Mouse x coordinate. More... | |
Private Attributes | |
Renderer * | renderer |
Mouse y coordinate. More... | |
std::forward_list< Widget * > | widgets |
Map | createEvtObjFuncs |
EventQueue | eventQueue |
Widget * | focus |
Manages creating widgets and events and provides routines governing GUI mechanisms.
Definition at line 32 of file GUISystem.h.
typedef std::map<EventType, CreateEventObject> gui::GUISystem::Map |
Definition at line 35 of file GUISystem.h.
GUISystem::GUISystem | ( | ) |
Definition at line 15 of file GUISystem.cpp.
References addEventType(), createKeyboardEvent(), createMouseEvent(), createNull(), gui::DISPLAY_CLOSE, gui::KEY_DOWN, gui::KEY_PRESS, gui::KEY_UP, gui::MOUSE_BUTTON_DOWN, gui::MOUSE_BUTTON_UP, gui::MOUSE_MOVE, and gui::RESIZE.
GUISystem::~GUISystem | ( | ) |
Definition at line 33 of file GUISystem.cpp.
Creates Button widget and assigns it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
text | Text to be displayed |
Definition at line 156 of file GUISystem.cpp.
References gui::EventQueue::addToQueue(), gui::Renderer::color(), gui::Button::downStateColor, eventQueue, gui::EventEmitter::guiSystem, gui::Button::hoverStateColor, renderer, gui::EventEmitter::setQueue(), gui::Button::textColor, gui::Button::upStateColor, and widgets.
Creates EditBox widget and assigns it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
multiline | Are multiple lines allowed. |
Definition at line 189 of file GUISystem.cpp.
References gui::EventQueue::addToQueue(), gui::EditBox::backgroundColor, gui::Renderer::color(), gui::EditBox::cursorColor, eventQueue, gui::EditBox::frameColor, gui::EventEmitter::guiSystem, renderer, gui::EditBox::setMultiline(), gui::EventEmitter::setQueue(), gui::EditBox::textColor, and widgets.
void GUISystem::addEventType | ( | EventType | eventType, |
CreateEventObject | createFunc | ||
) |
Affiliates event identifier with creating function.
eventType | Event type identifier |
createFunc | Function returning EventObject* pointer |
Definition at line 313 of file GUISystem.cpp.
References createEvtObjFuncs.
Creates Scrollbar widget and assigns it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
Definition at line 210 of file GUISystem.cpp.
References gui::EventQueue::addToQueue(), gui::Scrollbar::backgroundColor, gui::Renderer::color(), eventQueue, gui::Scrollbar::frameColor, gui::EventEmitter::guiSystem, renderer, gui::EventEmitter::setQueue(), and widgets.
Creates TextField widget and assigns it to the gui.
x | X coordinate |
y | Y coordinate |
w | Width |
h | Height |
text | Text to be displayed |
Definition at line 174 of file GUISystem.cpp.
References gui::EventQueue::addToQueue(), gui::Renderer::color(), eventQueue, gui::EventEmitter::guiSystem, renderer, gui::EventEmitter::setQueue(), gui::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 226 of file GUISystem.cpp.
References gui::EventQueue::addToQueue(), eventQueue, gui::EventEmitter::guiSystem, gui::EventEmitter::setQueue(), and widgets.
Creates a copy of an Event object.
event | Event object to be copied |
Definition at line 256 of file GUISystem.cpp.
References createEvtObjFuncs, gui::Event::obj, and gui::Event::type.
Creates an event that can be emitted.
eventType | Type of event |
Definition at line 242 of file GUISystem.cpp.
References createEvtObjFuncs.
EventObject * GUISystem::createEventObject | ( | EventObject * | obj = NULL | ) |
Creates an EventObject object.
obj | EventObject to copy. Creates new object when NULL. |
Definition at line 273 of file GUISystem.cpp.
EventObject * GUISystem::createKeyboardEvent | ( | EventObject * | obj = NULL | ) |
Creates an KeyboardEvent object.
obj | EventObject to copy. Creates new object when NULL. |
Definition at line 301 of file GUISystem.cpp.
EventObject * GUISystem::createMouseEvent | ( | EventObject * | obj = NULL | ) |
Creates an MouseEvent object with default values.
obj | EventObject to copy. Creates new object when NULL. |
Definition at line 285 of file GUISystem.cpp.
References gui::MouseEvent::mouseX, mouseX, gui::MouseEvent::mouseY, and mouseY.
|
inline |
Returns null pointer.
obj | Irrelevant here |
Used for registering event types with no own properties.
Definition at line 171 of file GUISystem.h.
References createEventObject(), createKeyboardEvent(), and createMouseEvent().
|
inline |
Returns associated Renderer object.
Definition at line 52 of file GUISystem.h.
References addButton(), addEditBox(), addEventType(), addScrollbar(), addTextField(), addWidget(), cloneEvent(), createEvent(), handleEvents(), keyChar(), keyDown(), mouseButtonDown(), mouseButtonUp(), mouseMove(), render(), and renderer.
void GUISystem::handleEvents | ( | ) |
Calls functions associated with events.
Definition at line 55 of file GUISystem.cpp.
References gui::EventQueue::empty(), eventQueue, and gui::EventQueue::getNextEvent().
void GUISystem::keyChar | ( | int | unichar | ) |
Updates gui state. To be called when a character is typed or repeated.
Definition at line 140 of file GUISystem.cpp.
References focus, and gui::Widget::keyChar().
void GUISystem::keyDown | ( | int | keyCode | ) |
Updates gui state. To be called when a key is pressed.
Definition at line 148 of file GUISystem.cpp.
References focus, and gui::Widget::keyDown().
void GUISystem::mouseButtonDown | ( | ) |
Updates gui state. To be called when mouse is pressed.
Definition at line 108 of file GUISystem.cpp.
References focus, gui::Widget::focusIn(), gui::Widget::focusOut(), mouseX, mouseY, gui::Widget::STATE_DOWN, gui::Widget::stateChange(), and widgets.
void GUISystem::mouseButtonUp | ( | ) |
Updates gui state. To be called when mouse button is released.
Definition at line 94 of file GUISystem.cpp.
References mouseX, mouseY, gui::Widget::STATE_HOVER, gui::Widget::STATE_UP, and widgets.
void GUISystem::mouseMove | ( | int | x, |
int | y | ||
) |
Updates gui state. To be called when mouse is moved.
Definition at line 66 of file GUISystem.cpp.
References mouseX, mouseY, gui::Widget::STATE_HOVER, gui::Widget::STATE_UP, and widgets.
void GUISystem::render | ( | ) |
Renders the gui.
Definition at line 43 of file GUISystem.cpp.
References gui::Renderer::clear(), renderer, gui::Renderer::setTarget(), and widgets.
void GUISystem::setRenderer | ( | Renderer * | renderer | ) |
Sets Renderer object to be used.
renderer | Renderer* pointer |
Definition at line 38 of file GUISystem.cpp.
References renderer.
|
private |
Definition at line 204 of file GUISystem.h.
|
private |
Definition at line 205 of file GUISystem.h.
|
private |
Definition at line 207 of file GUISystem.h.
int gui::GUISystem::mouseX |
Definition at line 196 of file GUISystem.h.
int gui::GUISystem::mouseY |
Mouse x coordinate.
Definition at line 197 of file GUISystem.h.
|
private |
Mouse y coordinate.
Definition at line 202 of file GUISystem.h.
|
private |
Definition at line 203 of file GUISystem.h.