M module-apps/application-bell-alarm/ApplicationBellAlarm.cpp => module-apps/application-bell-alarm/ApplicationBellAlarm.cpp +3 -1
@@ 2,6 2,7 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <application-bell-alarm/ApplicationBellAlarm.hpp>
+#include <application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp>
#include <application-bell-alarm/windows/BellAlarmWindow.hpp>
namespace app
@@ 28,7 29,8 @@ namespace app
void ApplicationBellAlarm::createUserInterface()
{
windowsFactory.attach(gui::name::window::main_window, [](Application *app, const std::string &name) {
- return std::make_unique<gui::BellAlarmWindow>(app);
+ auto presenter = std::make_unique<bell_alarm::BellAlarmWindowPresenter>();
+ return std::make_unique<gui::BellAlarmWindow>(app, std::move(presenter));
});
}
M module-apps/application-bell-alarm/CMakeLists.txt => module-apps/application-bell-alarm/CMakeLists.txt +3 -0
@@ 3,8 3,11 @@ add_library(application-bell-alarm)
target_sources(application-bell-alarm
PRIVATE
ApplicationBellAlarm.cpp
+ presenter/BellAlarmWindowPresenter.cpp
windows/BellAlarmWindow.cpp
PRIVATE
+ data/BellAlarmStyle.hpp
+ presenter/BellAlarmWindowPresenter.hpp
windows/BellAlarmWindow.hpp
PUBLIC
include/application-bell-alarm/ApplicationBellAlarm.hpp
A module-apps/application-bell-alarm/data/BellAlarmStyle.hpp => module-apps/application-bell-alarm/data/BellAlarmStyle.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+namespace gui
+{
+ namespace bell_alarm_style
+ {
+ namespace time_set_fmt_spinner
+ {
+ inline constexpr auto font = "gt_pressura_regular_90";
+ } // namespace time_set_fmt_spinner
+ } // namespace bell_alarm_style
+} // namespace gui
A module-apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp => module-apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp +12 -0
@@ 0,0 1,12 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BellAlarmWindowPresenter.hpp"
+
+namespace app::bell_alarm
+{
+ auto BellAlarmWindowPresenter::saveData() -> void
+ {
+ // TODO
+ }
+} // namespace app::bell_alarm
A module-apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp => module-apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp +33 -0
@@ 0,0 1,33 @@
+
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <apps-common/BasePresenter.hpp>
+
+namespace app::bell_alarm
+{
+ class BellAlarmWindowContract
+ {
+ public:
+ class View
+ {
+ public:
+ virtual ~View() noexcept = default;
+ };
+
+ class Presenter : public BasePresenter<BellAlarmWindowContract::View>
+ {
+ public:
+ virtual ~Presenter() noexcept = default;
+ virtual auto saveData() -> void = 0;
+ };
+ };
+
+ class BellAlarmWindowPresenter : public BellAlarmWindowContract::Presenter
+ {
+ public:
+ auto saveData() -> void override;
+ };
+} // namespace app::bell_alarm
M module-apps/application-bell-alarm/windows/BellAlarmWindow.cpp => module-apps/application-bell-alarm/windows/BellAlarmWindow.cpp +24 -1
@@ 3,25 3,48 @@
#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::string name) : AppWindow(app, std::move(name))
+ 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);
}
M module-apps/application-bell-alarm/windows/BellAlarmWindow.hpp => module-apps/application-bell-alarm/windows/BellAlarmWindow.hpp +12 -2
@@ 4,18 4,28 @@
#pragma once
#include <application-bell-alarm/ApplicationBellAlarm.hpp>
+#include <application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp>
#include <apps-common/windows/AppWindow.hpp>
namespace gui
{
- class BellAlarmWindow : public AppWindow
+ class BellBaseLayout;
+ class TimeSetFmtSpinner;
+ class BellAlarmWindow : public AppWindow, public app::bell_alarm::BellAlarmWindowContract::View
{
public:
- explicit BellAlarmWindow(app::Application *app, std::string name = window::name::bellAlarm);
+ explicit BellAlarmWindow(app::Application *app,
+ std::unique_ptr<app::bell_alarm::BellAlarmWindowContract::Presenter> &&windowPresenter,
+ std::string name = window::name::bellAlarm);
void buildInterface() override;
bool onInput(const InputEvent &inputEvent) override;
void rebuild() override;
+
+ private:
+ BellBaseLayout *body{nullptr};
+ TimeSetFmtSpinner *timeSetFmtSpinner{nullptr};
+ std::unique_ptr<app::bell_alarm::BellAlarmWindowContract::Presenter> presenter;
};
} /* namespace gui */
M module-gui/gui/widgets/Spinner.cpp => module-gui/gui/widgets/Spinner.cpp +1 -0
@@ 15,6 15,7 @@ namespace gui
: minValue(minValue), maxValue(maxValue), step(step), currentValue(minValue), boundaries(boundaries)
{
setEditMode(EditMode::Browse);
+ drawUnderline(false);
updateSpinner();
}
M module-gui/gui/widgets/Spinner.hpp => module-gui/gui/widgets/Spinner.hpp +2 -2
@@ 3,11 3,11 @@
#pragma once
-#include "Text.hpp"
+#include "TextFixedSize.hpp"
namespace gui
{
- class Spinner : public Text
+ class Spinner : public TextFixedSize
{
public:
Spinner(int minValue, int maxValue, int step, Boundaries boundaries);
M module-gui/gui/widgets/TextFixedSize.cpp => module-gui/gui/widgets/TextFixedSize.cpp +3 -0
@@ 7,6 7,9 @@
namespace gui
{
+ TextFixedSize::TextFixedSize() : TextFixedSize(nullptr, 0, 0, 0, 0)
+ {}
+
TextFixedSize::TextFixedSize(Item *parent, Position x, Position y, Length w, Length h) : Text(parent, x, y, w, h)
{
setEditMode(EditMode::Edit);
M module-gui/gui/widgets/TextFixedSize.hpp => module-gui/gui/widgets/TextFixedSize.hpp +1 -0
@@ 16,6 16,7 @@ namespace gui
void drawLines() override;
public:
+ TextFixedSize();
TextFixedSize(Item *parent, Position x, Position y, Length w, Length h);
void setLines(unsigned int val);