From 6c678e872d51247f5e47730218598209e96bdd0a Mon Sep 17 00:00:00 2001 From: JF Date: Fri, 14 Aug 2020 10:05:44 +0200 Subject: [PATCH] Screens::Label is now a subclass of Screen. --- src/DisplayApp/Screens/Label.cpp | 17 ++------------- src/DisplayApp/Screens/Label.h | 30 ++++----------------------- src/DisplayApp/Screens/SystemInfo.cpp | 6 +++--- 3 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/DisplayApp/Screens/Label.cpp b/src/DisplayApp/Screens/Label.cpp index ba35279d..780ee88e 100644 --- a/src/DisplayApp/Screens/Label.cpp +++ b/src/DisplayApp/Screens/Label.cpp @@ -3,26 +3,13 @@ using namespace Pinetime::Applications::Screens; - -Label::Label(const char* text) : text{text} { - -} - -Label::~Label() { - -} - -void Label::Refresh() { - -} - -void Label::Show() { +Label::Label(Pinetime::Applications::DisplayApp *app, const char *text) : Screen(app), text{text} { label = lv_label_create(lv_scr_act(), NULL); lv_label_set_align(label, LV_LABEL_ALIGN_LEFT); lv_obj_set_size(label, 240, 240); lv_label_set_text(label, text); } -void Label::Hide() { +Label::~Label() { lv_obj_clean(lv_scr_act()); } diff --git a/src/DisplayApp/Screens/Label.h b/src/DisplayApp/Screens/Label.h index 9d91974d..3e7b3797 100644 --- a/src/DisplayApp/Screens/Label.h +++ b/src/DisplayApp/Screens/Label.h @@ -7,33 +7,11 @@ namespace Pinetime { namespace Applications { namespace Screens { - class Label { + + class Label : public Screen { public: - Label() = default; - explicit Label(const char* text); - ~Label(); - void Refresh(); - - void Hide(); - void Show(); - private: - lv_obj_t * label = nullptr; - const char* text = nullptr; - }; - - class Label2 : public Screen { - public: - Label2(DisplayApp* app, const char* text) : Screen(app), text{text} { - label = lv_label_create(lv_scr_act(), NULL); - lv_label_set_align(label, LV_LABEL_ALIGN_LEFT); - lv_obj_set_size(label, 240, 240); - lv_label_set_text(label, text); - } - - ~Label2() override { - lv_obj_clean(lv_scr_act()); - } - + Label(DisplayApp* app, const char* text); + ~Label() override; bool Refresh() override {return false;} private: diff --git a/src/DisplayApp/Screens/SystemInfo.cpp b/src/DisplayApp/Screens/SystemInfo.cpp index e146e2e6..b355f419 100644 --- a/src/DisplayApp/Screens/SystemInfo.cpp +++ b/src/DisplayApp/Screens/SystemInfo.cpp @@ -98,17 +98,17 @@ std::unique_ptr SystemInfo::CreateScreen1() { uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds, batteryPercent, brightness, resetReason); - return std::unique_ptr(new Screens::Label2(app, t1)); + return std::unique_ptr(new Screens::Label(app, t1)); } std::unique_ptr SystemInfo::CreateScreen2() { auto& bleAddr = bleController.Address(); sprintf(t2, "BLE MAC: \n %2x:%2x:%2x:%2x:%2x:%2x", bleAddr[5], bleAddr[4], bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0]); - return std::unique_ptr(new Screens::Label2(app, t2)); + return std::unique_ptr(new Screens::Label(app, t2)); } std::unique_ptr SystemInfo::CreateScreen3() { strncpy(t3, "Hello from\nthe developper!", 27); - return std::unique_ptr(new Screens::Label2(app, t3)); + return std::unique_ptr(new Screens::Label(app, t3)); }