~aleteoryx/muditaos

ref: 87ed83ca5ce1209cd4591fc58d16e441928b147c muditaos/module-apps/application-bell-alarm/windows/BellAlarmWindow.cpp -rw-r--r-- 1.7 KiB
87ed83ca — Mateusz Grzegorzek [BH-701] Use TimeSetFmtSpinner in Alarm app 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BellAlarmWindow.hpp"

#include <apps-common/widgets/BellBaseLayout.hpp>
#include <apps-common/widgets/TimeSetFmtSpinner.hpp>
#include <data/BellAlarmStyle.hpp>
#include <module-gui/gui/input/InputEvent.hpp>

namespace gui
{
    BellAlarmWindow::BellAlarmWindow(
        app::Application *app,
        std::unique_ptr<app::bell_alarm::BellAlarmWindowContract::Presenter> &&windowPresenter,
        std::string name)
        : AppWindow(app, std::move(name)), presenter{std::move(windowPresenter)}
    {
        presenter->attach(this);
        buildInterface();
    }

    void BellAlarmWindow::buildInterface()
    {
        AppWindow::buildInterface();

        statusBar->setVisible(false);
        header->setTitleVisibility(true);
        bottomBar->setVisible(false);

        body              = new BellBaseLayout(this, 0, 0, style::window_width, style::window_height);
        timeSetFmtSpinner = new TimeSetFmtSpinner(body->centerBox);
        timeSetFmtSpinner->setFont(bell_alarm_style::time_set_fmt_spinner::font);

        setFocusItem(body);
    }

    bool BellAlarmWindow::onInput(const InputEvent &inputEvent)
    {
        if (body->onInput(inputEvent)) {
            return true;
        }
        if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
            presenter->saveData();
            application->returnToPreviousWindow();
            return true;
        }
        return AppWindow::onInput(inputEvent);
    }

    void BellAlarmWindow::rebuild()
    {
        erase();
        buildInterface();
    }
} /* namespace gui */