Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Core/GUI.cpp
- Committer:
- duncanFrance
- Date:
- 2016-05-22
- Revision:
- 16:e9a771ecfdbe
- Parent:
- 12:63db16fea709
- Child:
- 18:d849f3ada858
File content as of revision 16:e9a771ecfdbe:
#include "GUI.h" GUI::GUI(GraphicsContext* context) : _context(context), _rootWindow(context) {} GraphicsContext* GUI::getGraphicsContext() { return _context; } Window* GUI::rootWindow() { 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::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(); }