screens: Remove displayapp parameter from screen

The DisplayApp class isn't used in the Screen base class and most
screens, so requiring it is pointless.

In this commit, DisplayApp pointers were added to screens which use it
and the explicit Screen constructor was removed in those screens.
This commit is contained in:
Riku Isokoski 2023-02-22 22:05:37 +02:00
parent e2d4084701
commit 7c7a8602c4
30 changed files with 44 additions and 29 deletions

View File

@ -23,7 +23,7 @@ ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp* app,
const Pinetime::Controllers::Battery& batteryController,
const Pinetime::Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController)
: Screen(app),
: app {app},
settingsController {settingsController},
batteryController {batteryController},
bleController {bleController},

View File

@ -25,6 +25,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override;
private:
DisplayApp* app;
auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;

View File

@ -26,7 +26,7 @@ Clock::Clock(DisplayApp* app,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::FS& filesystem)
: Screen(app),
: app {app},
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},

View File

@ -36,6 +36,7 @@ namespace Pinetime {
bool OnButtonPushed() override;
private:
DisplayApp* app;
Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController;
const Controllers::Ble& bleController;

View File

@ -2,8 +2,8 @@
using namespace Pinetime::Applications::Screens;
Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::DisplayApp* app, lv_obj_t* labelText)
: Screen(app), labelText {labelText}, pageIndicator(screenID, numScreens) {
Label::Label(uint8_t screenID, uint8_t numScreens, lv_obj_t* labelText)
: labelText {labelText}, pageIndicator(screenID, numScreens) {
pageIndicator.Create();
}

View File

@ -10,7 +10,7 @@ namespace Pinetime {
class Label : public Screen {
public:
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
Label(uint8_t screenID, uint8_t numScreens, lv_obj_t* labelText);
~Label() override;
private:

View File

@ -17,7 +17,7 @@ List::List(uint8_t screenID,
DisplayApp* app,
Controllers::Settings& settingsController,
std::array<Applications, MAXLISTITEMS>& applications)
: Screen(app), settingsController {settingsController}, pageIndicator(screenID, numScreens) {
: app {app}, settingsController {settingsController}, pageIndicator(screenID, numScreens) {
// Set the background to Black
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0));

View File

@ -31,6 +31,7 @@ namespace Pinetime {
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private:
DisplayApp* app;
Controllers::Settings& settingsController;
Pinetime::Applications::Apps apps[MAXLISTITEMS];

View File

@ -16,7 +16,7 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::MotorController& motorController,
System::SystemTask& systemTask,
Modes mode)
: Screen(app),
: app {app},
notificationManager {notificationManager},
alertNotificationService {alertNotificationService},
motorController {motorController},

View File

@ -69,6 +69,7 @@ namespace Pinetime {
};
private:
DisplayApp* app;
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController;

View File

@ -50,9 +50,11 @@ namespace Pinetime {
}
public:
explicit Screen(DisplayApp* app) : app {app} {
explicit Screen(DisplayApp* app) {
}
explicit Screen() = default;
virtual ~Screen() = default;
static void RefreshTaskCallback(lv_task_t* task);
@ -77,7 +79,6 @@ namespace Pinetime {
}
protected:
DisplayApp* app;
bool running = true;
};
}

View File

@ -19,7 +19,7 @@ namespace Pinetime {
uint8_t initScreen,
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
: Screen(app),
: app {app},
initScreen {initScreen},
screens {std::move(screens)},
mode {mode},
@ -102,6 +102,7 @@ namespace Pinetime {
}
private:
DisplayApp* app;
uint8_t initScreen = 0;
const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
ScreenListModes mode = ScreenListModes::UpDown;

View File

@ -38,7 +38,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
Pinetime::Drivers::WatchdogView& watchdog,
Pinetime::Controllers::MotionController& motionController,
const Pinetime::Drivers::Cst816S& touchPanel)
: Screen(app),
: app {app},
dateTimeController {dateTimeController},
batteryController {batteryController},
brightnessController {brightnessController},
@ -94,7 +94,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
BootloaderVersion::VersionString());
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(0, 5, app, label);
return std::make_unique<Screens::Label>(0, 5, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@ -173,7 +173,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
touchPanel.GetFwVersion(),
TARGET_DEVICE_NAME);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(1, 5, app, label);
return std::make_unique<Screens::Label>(1, 5, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@ -204,7 +204,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
mon.frag_pct,
static_cast<int>(mon.free_biggest_size));
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(2, 5, app, label);
return std::make_unique<Screens::Label>(2, 5, label);
}
bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
@ -265,7 +265,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
}
lv_table_set_cell_value(infoTask, i + 1, 3, buffer);
}
return std::make_unique<Screens::Label>(3, 5, app, infoTask);
return std::make_unique<Screens::Label>(3, 5, infoTask);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@ -282,5 +282,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(4, 5, app, label);
return std::make_unique<Screens::Label>(4, 5, label);
}

View File

@ -34,6 +34,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override;
private:
DisplayApp* app;
Pinetime::Controllers::DateTime& dateTimeController;
const Pinetime::Controllers::Battery& batteryController;
Pinetime::Controllers::BrightnessController& brightnessController;

View File

@ -32,7 +32,7 @@ Tile::Tile(uint8_t screenID,
const Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
std::array<Applications, 6>& applications)
: Screen(app),
: app {app},
dateTimeController {dateTimeController},
pageIndicator(screenID, numScreens),
statusIcons(batteryController, bleController) {

View File

@ -36,6 +36,7 @@ namespace Pinetime {
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
private:
DisplayApp* app;
Controllers::DateTime& dateTimeController;
lv_task_t* taskUpdate;

View File

@ -26,7 +26,7 @@
using namespace Pinetime::Applications::Screens;
Weather::Weather(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::WeatherService& weather)
: Screen(app),
: app {app},
weatherService(weather),
screens {app,
0,
@ -97,7 +97,7 @@ std::unique_ptr<Screen> Weather::CreateScreenTemperature() {
}
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
}
std::unique_ptr<Screen> Weather::CreateScreenAir() {
@ -130,7 +130,7 @@ std::unique_ptr<Screen> Weather::CreateScreenAir() {
}
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
}
std::unique_ptr<Screen> Weather::CreateScreenClouds() {
@ -159,7 +159,7 @@ std::unique_ptr<Screen> Weather::CreateScreenClouds() {
}
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
}
std::unique_ptr<Screen> Weather::CreateScreenPrecipitation() {
@ -188,7 +188,7 @@ std::unique_ptr<Screen> Weather::CreateScreenPrecipitation() {
}
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
}
std::unique_ptr<Screen> Weather::CreateScreenHumidity() {
@ -217,5 +217,5 @@ std::unique_ptr<Screen> Weather::CreateScreenHumidity() {
}
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
}

View File

@ -23,6 +23,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override;
private:
DisplayApp* app;
bool running = true;
Controllers::WeatherService& weatherService;

View File

@ -34,7 +34,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
Controllers::MotorController& motorController,
Pinetime::Controllers::Settings& settingsController,
const Controllers::Ble& bleController)
: Screen(app),
: app {app},
dateTimeController {dateTimeController},
brightness {brightness},
motorController {motorController},

View File

@ -32,6 +32,7 @@ namespace Pinetime {
void UpdateScreen();
private:
DisplayApp* app;
Controllers::DateTime& dateTimeController;
Controllers::BrightnessController& brightness;
Controllers::MotorController& motorController;

View File

@ -35,7 +35,7 @@ namespace {
}
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app),
: app {app},
checkboxList(
0,
1,

View File

@ -19,6 +19,7 @@ namespace Pinetime {
~SettingBluetooth() override;
private:
DisplayApp* app;
CheckboxList checkboxList;
};
}

View File

@ -18,7 +18,7 @@ namespace {
constexpr std::array<uint16_t, 6> SettingDisplay::options;
SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
: app {app}, settingsController {settingsController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);

View File

@ -20,6 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
DisplayApp* app;
static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};
Controllers::Settings& settingsController;

View File

@ -15,7 +15,7 @@ bool SettingSetDateTime::OnTouchEvent(Pinetime::Applications::TouchEvents event)
SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::DateTime& dateTimeController,
Pinetime::Controllers::Settings& settingsController)
: Screen(app),
: app {app},
dateTimeController {dateTimeController},
settingsController {settingsController},
screens {app,

View File

@ -20,6 +20,7 @@ namespace Pinetime {
void Quit();
private:
DisplayApp* app;
Controllers::DateTime& dateTimeController;
Controllers::Settings& settingsController;

View File

@ -22,7 +22,7 @@ auto SettingWatchFace::CreateScreenList() const {
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::Settings& settingsController,
Pinetime::Controllers::FS& filesystem)
: Screen(app),
: app {app},
settingsController {settingsController},
filesystem {filesystem},
screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {

View File

@ -25,6 +25,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override;
private:
DisplayApp* app;
auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;

View File

@ -19,7 +19,7 @@ auto Settings::CreateScreenList() const {
}
Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app),
: app {app},
settingsController {settingsController},
screens {app, settingsController.GetSettingsMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
}

View File

@ -20,6 +20,7 @@ namespace Pinetime {
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private:
DisplayApp* app;
auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;