mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-18 12:04:03 -04:00
* Timers now are Application thread safe * Timers now have consistent API independend of Application (no more c style timers) * Timers can have either: callback or override onTimer() method - this way we can create more complicated timers or just use existing ones * gui::Timer added via adapter class GuiTimer to decouple sys::Timer with gui::Timer * Fixed race in wrapper * Updated docs * fixed using std and cpp_freertos and DataReceivedHandler hidden in Application.hpp
74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
/*
|
|
* Window.cpp
|
|
*
|
|
* Created on: 6 mar 2019
|
|
* Author: robert
|
|
*/
|
|
#include <algorithm>
|
|
// gui
|
|
#include "../Common.hpp"
|
|
#include "../core/BoundingBox.hpp"
|
|
#include "../core/DrawCommand.hpp"
|
|
#include "Window.hpp"
|
|
#include <InputEvent.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
Window::Window(std::string name) : Item(), refreshMode{RefreshModes::GUI_REFRESH_FAST}, name{name}
|
|
{}
|
|
|
|
void Window::onBeforeShow(ShowMode mode, SwitchData *data)
|
|
{}
|
|
|
|
void Window::onClose()
|
|
{}
|
|
|
|
void Window::getRefreshArea(RefreshModes &mode, uint16_t &x, uint16_t &y, uint16_t &w, uint16_t &h)
|
|
{
|
|
x = widgetArea.x;
|
|
y = widgetArea.y;
|
|
w = widgetArea.w;
|
|
h = widgetArea.h;
|
|
mode = refreshMode;
|
|
}
|
|
|
|
bool Window::handleSwitchData(SwitchData *data)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
std::list<DrawCommand *> Window::buildDrawList()
|
|
{
|
|
|
|
std::list<DrawCommand *> commands;
|
|
std::list<DrawCommand *> childrenCommands = Item::buildDrawList();
|
|
|
|
DrawCommand *clearCommand = new DrawCommand();
|
|
clearCommand->id = DrawCommandID::GUI_DRAW_CLEAR;
|
|
|
|
commands.push_back(clearCommand);
|
|
|
|
if (!childrenCommands.empty()) {
|
|
commands.splice(commands.end(), childrenCommands);
|
|
}
|
|
|
|
return commands;
|
|
}
|
|
|
|
bool Window::onInput(const InputEvent &inputEvent)
|
|
{
|
|
if (focusItem != nullptr && focusItem->onInput(inputEvent)) {
|
|
return true;
|
|
}
|
|
if (inputCallback != nullptr && inputCallback(*this, inputEvent)) {
|
|
return true;
|
|
}
|
|
if (handleNavigation(inputEvent)) {
|
|
return true;
|
|
}
|
|
return inputEvent.state == InputEvent::State::keyReleasedShort &&
|
|
inputEvent.keyCode == gui::KeyCode::KEY_ENTER && onActivated(nullptr);
|
|
}
|
|
|
|
} /* namespace gui */
|