Files
MuditaOS/module-apps/apps-common/windows/BrightnessWindow.cpp
Mateusz Grzegorzek 58dd02cff1 [BH-861] Cleanup Application split - part I
1. Prepare Pure and Bell specific `Application`
   classes and add them to `app` target:

- `products/BellHybrid/apps/Application.cpp`
- `products/PurePhone/apps/Application.cpp`

2. Update `CMakeLists.txt` files.
3. Move `ApplicationBell` implementation to Bell-specific
   `Application` class and remove `ApplicationBell` files.
4. Change Bell apps parent classes from `ApplicationBell`
  to Bell-specific `Application` class.
5. Rename `Application` to `ApplicationCommon` in the rest of the files.
2021-09-13 11:58:10 +02:00

85 lines
2.3 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <module-gui/gui/input/InputEvent.hpp>
#include <module-gui/gui/widgets/Arc.hpp>
#include "BrightnessWindow.hpp"
namespace gui
{
BrightnessWindow::BrightnessWindow(app::ApplicationCommon *app, const std::string &name) : AppWindow(app, name)
{
buildInterface();
}
void BrightnessWindow::addBox()
{
border = new Rect(this,
0,
style::window::brightness::box::top_offset,
style::window::brightness::box::width,
style::window::brightness::box::height);
border->setEdges(RectangleEdge::Top);
}
void BrightnessWindow::addBrightnessText()
{
brightnessText = new BrightnessBox(
this, style::window::brightness::title::left_offset, style::window::brightness::title::top_offset);
}
void BrightnessWindow::addBrightnessBar()
{
brightnessBar = new HBarGraph(this,
style::window::brightness::bar::left_offset + 20,
style::window::brightness::bar::top_offset,
style::window::brightness::bar::brightness_levels);
}
void BrightnessWindow::buildInterface()
{
AppWindow::buildInterface();
addBox();
addBrightnessText();
addBrightnessBar();
}
void BrightnessWindow::rebuild()
{}
void BrightnessWindow::destroyInterface()
{
erase();
}
BrightnessWindow::~BrightnessWindow()
{
destroyInterface();
}
void BrightnessWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{}
bool BrightnessWindow::onInput(const gui::InputEvent &inputEvent)
{
if (!inputEvent.isShortRelease()) {
return false;
}
int update = brightnessBar->getValue();
if (inputEvent.is(gui::KeyCode::KEY_VOLUP)) {
update++;
}
if (inputEvent.is(gui::KeyCode::KEY_VOLDN)) {
update--;
}
if (update >= 0) {
brightnessBar->setValue(update);
}
return AppWindow::onInput(inputEvent);
}
} // namespace gui