mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-11-27 19:22:01 +03:00
Screens::Label is now a subclass of Screen.
This commit is contained in:
parent
f5328ec9eb
commit
6c678e872d
@ -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());
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -98,17 +98,17 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
|
||||
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
|
||||
batteryPercent, brightness, resetReason);
|
||||
|
||||
return std::unique_ptr<Screen>(new Screens::Label2(app, t1));
|
||||
return std::unique_ptr<Screen>(new Screens::Label(app, t1));
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> 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<Screen>(new Screens::Label2(app, t2));
|
||||
return std::unique_ptr<Screen>(new Screens::Label(app, t2));
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
strncpy(t3, "Hello from\nthe developper!", 27);
|
||||
return std::unique_ptr<Screen>(new Screens::Label2(app, t3));
|
||||
return std::unique_ptr<Screen>(new Screens::Label(app, t3));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user