~aleteoryx/muditaos

ref: b911ad9044a57a649c91d915cedf16e77c4b5034 muditaos/module-apps/windows/BrightnessWindow.cpp -rw-r--r-- 2.2 KiB
b911ad90 — SP2FET [EGD-5940] Add BT device unpairing 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) 2017-2020, 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::Application *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.isShortPress()) {
            return false;
        }

        if (inputEvent.keyCode == gui::KeyCode::KEY_VOLUP) {
            brightnessBar->update(1);
        }

        if (inputEvent.keyCode == gui::KeyCode::KEY_VOLDN) {
            brightnessBar->update(-1);
        }

        return AppWindow::onInput(inputEvent);
    }
} // namespace gui