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;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
Label::Label(Pinetime::Applications::DisplayApp *app, const char *text) : Screen(app), text{text} {
|
||||||
Label::Label(const char* text) : text{text} {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Label::~Label() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Label::Refresh() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Label::Show() {
|
|
||||||
label = lv_label_create(lv_scr_act(), NULL);
|
label = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_label_set_align(label, LV_LABEL_ALIGN_LEFT);
|
lv_label_set_align(label, LV_LABEL_ALIGN_LEFT);
|
||||||
lv_obj_set_size(label, 240, 240);
|
lv_obj_set_size(label, 240, 240);
|
||||||
lv_label_set_text(label, text);
|
lv_label_set_text(label, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::Hide() {
|
Label::~Label() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,33 +7,11 @@
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
class Label {
|
|
||||||
|
class Label : public Screen {
|
||||||
public:
|
public:
|
||||||
Label() = default;
|
Label(DisplayApp* app, const char* text);
|
||||||
explicit Label(const char* text);
|
~Label() override;
|
||||||
~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());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Refresh() override {return false;}
|
bool Refresh() override {return false;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -98,17 +98,17 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
|
||||||
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
|
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
|
||||||
batteryPercent, brightness, resetReason);
|
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() {
|
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
||||||
auto& bleAddr = bleController.Address();
|
auto& bleAddr = bleController.Address();
|
||||||
sprintf(t2, "BLE MAC: \n %2x:%2x:%2x:%2x:%2x:%2x",
|
sprintf(t2, "BLE MAC: \n %2x:%2x:%2x:%2x:%2x:%2x",
|
||||||
bleAddr[5], bleAddr[4], bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0]);
|
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() {
|
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||||
strncpy(t3, "Hello from\nthe developper!", 27);
|
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 a new issue