Close menu with button
This commit is contained in:
parent
18e3cc7038
commit
39157f2f19
|
@ -249,10 +249,10 @@ void DisplayApp::Refresh() {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::ButtonPushed:
|
case Messages::ButtonPushed:
|
||||||
if (currentApp == Apps::Clock) {
|
if (!currentScreen->OnButtonPushed()) {
|
||||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
if (currentApp == Apps::Clock) {
|
||||||
} else {
|
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||||
if (!currentScreen->OnButtonPushed()) {
|
} else {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
brightnessController.Set(settingsController.GetBrightness());
|
brightnessController.Set(settingsController.GetBrightness());
|
||||||
brightnessController.Backup();
|
brightnessController.Backup();
|
||||||
|
|
|
@ -54,6 +54,10 @@ bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screen->OnTouchEvent(event);
|
return screen->OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Clock::OnButtonPushed() {
|
||||||
|
return screen->OnButtonPushed();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
|
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
|
||||||
return std::make_unique<Screens::WatchFaceDigital>(app,
|
return std::make_unique<Screens::WatchFaceDigital>(app,
|
||||||
dateTimeController,
|
dateTimeController,
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace Pinetime {
|
||||||
~Clock() override;
|
~Clock() override;
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
|
|
|
@ -316,6 +316,27 @@ bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PineTimeStyle::CloseMenu() {
|
||||||
|
settingsController.SaveSettings();
|
||||||
|
lv_obj_set_hidden(btnNextTime, true);
|
||||||
|
lv_obj_set_hidden(btnPrevTime, true);
|
||||||
|
lv_obj_set_hidden(btnNextBar, true);
|
||||||
|
lv_obj_set_hidden(btnPrevBar, true);
|
||||||
|
lv_obj_set_hidden(btnNextBG, true);
|
||||||
|
lv_obj_set_hidden(btnPrevBG, true);
|
||||||
|
lv_obj_set_hidden(btnReset, true);
|
||||||
|
lv_obj_set_hidden(btnRandom, true);
|
||||||
|
lv_obj_set_hidden(btnClose, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PineTimeStyle::OnButtonPushed() {
|
||||||
|
if (!lv_obj_get_hidden(btnClose)) {
|
||||||
|
CloseMenu();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void PineTimeStyle::SetBatteryIcon() {
|
void PineTimeStyle::SetBatteryIcon() {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
||||||
|
@ -532,16 +553,7 @@ void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
}
|
}
|
||||||
if (object == btnClose) {
|
if (object == btnClose) {
|
||||||
settingsController.SaveSettings();
|
CloseMenu();
|
||||||
lv_obj_set_hidden(btnNextTime, true);
|
|
||||||
lv_obj_set_hidden(btnPrevTime, true);
|
|
||||||
lv_obj_set_hidden(btnNextBar, true);
|
|
||||||
lv_obj_set_hidden(btnPrevBar, true);
|
|
||||||
lv_obj_set_hidden(btnNextBG, true);
|
|
||||||
lv_obj_set_hidden(btnPrevBG, true);
|
|
||||||
lv_obj_set_hidden(btnReset, true);
|
|
||||||
lv_obj_set_hidden(btnRandom, true);
|
|
||||||
lv_obj_set_hidden(btnClose, true);
|
|
||||||
}
|
}
|
||||||
if (object == btnSet) {
|
if (object == btnSet) {
|
||||||
lv_obj_set_hidden(btnSet, true);
|
lv_obj_set_hidden(btnSet, true);
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace Pinetime {
|
||||||
~PineTimeStyle() override;
|
~PineTimeStyle() override;
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
|
@ -96,6 +97,7 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
|
||||||
void SetBatteryIcon();
|
void SetBatteryIcon();
|
||||||
|
void CloseMenu();
|
||||||
|
|
||||||
lv_task_t* taskRefresh;
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user