diff options
Diffstat (limited to 'src/displayapp/screens/FlashLight.cpp')
| -rw-r--r-- | src/displayapp/screens/FlashLight.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp index 3493381..954551c 100644 --- a/src/displayapp/screens/FlashLight.cpp +++ b/src/displayapp/screens/FlashLight.cpp @@ -4,27 +4,34 @@ using namespace Pinetime::Applications::Screens; -namespace { - void event_handler(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<FlashLight*>(obj->user_data); - screen->OnClickEvent(obj, event); +namespace Pinetime { + namespace Applications { + namespace Screens { + namespace FlashLightData { + Levels brightnessLevel = Levels::High; + } + } } +} - typedef Pinetime::Controllers::BrightnessController::Levels Levels; +using namespace Pinetime::Applications::Screens::FlashLightData; - Levels brightnessLevel = Levels::High; + +void FlashLight::EventHandler(lv_obj_t* obj, lv_event_t event) { + auto* screen = static_cast<FlashLight*>(obj->user_data); + screen->OnClickEvent(obj, event); } FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app, System::SystemTask& systemTask, - Controllers::BrightnessController& brightnessController) + Controllers::BrightnessController& brightnessController, + lv_color_t color) : Screen(app), systemTask {systemTask}, - brightnessController {brightnessController} + brightnessController {brightnessController}, + color {color} { - systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); - flashLight = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(flashLight, Symbols::highlight); @@ -46,10 +53,11 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app, lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP); lv_obj_set_size(backgroundAction, 240, 240); lv_obj_set_pos(backgroundAction, 0, 0); - lv_label_set_text(backgroundAction, ""); + lv_label_set_text_static(backgroundAction, ""); lv_obj_set_click(backgroundAction, true); backgroundAction->user_data = this; - lv_obj_set_event_cb(backgroundAction, event_handler); + lv_obj_set_event_cb(backgroundAction, EventHandler); + systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); } FlashLight::~FlashLight() { @@ -76,21 +84,21 @@ void FlashLight::Update(bool on, Controllers::BrightnessController::Levels level isOn = on; if (isOn) { brightnessController.Backup(); - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color); lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); for (auto & i : indicators) { lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, color); lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); } } else { brightnessController.Restore(); lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color); for (auto & i : indicators) { - lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color); lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_BLACK); - lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color); } } } @@ -100,12 +108,6 @@ void FlashLight::Update(bool on, Controllers::BrightnessController::Levels level } } -void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) { - if (obj == backgroundAction && event == LV_EVENT_CLICKED) { - Update(!isOn, brightnessLevel); - } -} - bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) { using namespace Pinetime::Controllers; |
