Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Diff: Core/GUI.cpp
- Revision:
- 18:d849f3ada858
- Parent:
- 16:e9a771ecfdbe
--- a/Core/GUI.cpp Sun May 22 16:35:23 2016 +0000 +++ b/Core/GUI.cpp Sat May 28 14:50:14 2016 +0000 @@ -1,7 +1,9 @@ #include "GUI.h" GUI::GUI(GraphicsContext* context) : _context(context), _rootWindow(context) -{} +{ + _context->eventDispatcher()->attachListener(&_rootWindow); +} GraphicsContext* GUI::getGraphicsContext() { return _context; @@ -11,36 +13,8 @@ return &_rootWindow; } -void GUI::queueEvent(const Event e) -{ - Event* qe = _mailbox.alloc(); - qe->type = e.type; - qe->target = e.target; - qe->screenX = e.screenX; - qe->screenY = e.screenY; - _mailbox.put(qe); +void GUI::run() { + _context->eventDispatcher()->pumpEvents(); + _rootWindow.draw(); + } - -void GUI::pumpEvents() -{ - - osEvent oe = _mailbox.get(1); - - if(oe.status == osEventMail) { - - Event* qe = (Event*)oe.value.p; - Event e; - e.target = qe->target; - e.type = qe->type; - e.screenX = qe->screenX; - e.screenY = qe->screenY; - - _context->eventDispatcher()->dispatchEvent(e); - _mailbox.free(qe); - } -} - -void GUI::updateWindow() -{ - _rootWindow.draw(); -} \ No newline at end of file