summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Tile.cpp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2020-10-04 10:21:22 (GMT)
committerGitHub <noreply@github.com>2020-10-04 10:21:22 (GMT)
commit39954bbd3afb592a0c3109e3479594183e8d0778 (patch)
tree58efd04aa38b8dc7989c51fe3c9cdb9a3fb46a54 /src/displayapp/screens/Tile.cpp
parent5adc97702c326d0252df6da75ce4ac244a4b3553 (diff)
parent6c86d1d9d706706fcb6f214aba8259e61ed68755 (diff)
Merge pull request #68 from Avamander/patch-1
Rename folders to follow a consistent style
Diffstat (limited to 'src/displayapp/screens/Tile.cpp')
-rw-r--r--src/displayapp/screens/Tile.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
new file mode 100644
index 0000000..deb8847
--- /dev/null
+++ b/src/displayapp/screens/Tile.cpp
@@ -0,0 +1,62 @@
+#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <libs/lvgl/src/lv_font/lv_font.h>
+#include <libs/lvgl/lvgl.h>
+
+#include "Tile.h"
+#include "displayapp/DisplayApp.h"
+#include "Symbols.h"
+#include "../../Version.h"
+
+using namespace Pinetime::Applications::Screens;
+
+extern lv_font_t jetbrains_mono_bold_20;
+
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
+ Tile* screen = static_cast<Tile *>(obj->user_data);
+ uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
+ uint32_t eventData = *eventDataPtr;
+ screen->OnObjectEvent(obj, event, eventData);
+}
+
+Tile::Tile(DisplayApp* app, std::array<Applications, 6>& applications) : Screen(app) {
+ for(int i = 0, appIndex = 0; i < 8; i++) {
+ if(i == 3) btnm_map1[i] = "\n";
+ else if(i == 7) btnm_map1[i] = "";
+ else {
+ btnm_map1[i] = applications[appIndex].icon;
+ apps[appIndex] = applications[appIndex].application;
+ appIndex++;
+ }
+ }
+ modal.reset(new Modal(app));
+
+ btnm1 = lv_btnm_create(lv_scr_act(), NULL);
+ lv_btnm_set_map(btnm1, btnm_map1);
+ lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES);
+
+ btnm1->user_data = this;
+ lv_obj_set_event_cb(btnm1, event_handler);
+}
+
+Tile::~Tile() {
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Tile::Refresh() {
+ return running;
+}
+
+void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) {
+ if(event == LV_EVENT_VALUE_CHANGED) {
+ app->StartApp(apps[buttonId]);
+ running = false;
+ }
+}
+
+bool Tile::OnButtonPushed() {
+ app->StartApp(Apps::Clock);
+ running = false;
+ return true;
+}
+
+