* Boot splash and more - Added developer sdkconfig - Refactored the way FreeRTOS includes are included - Improved Gui/Loader logic - Implemented boot app with splash screen * Updated naming for Gui and Loader services * Renamed Screenshot service methods * Renames * Service renames
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include "Check.h"
|
|
#include "TactilityConfig.h"
|
|
#include "service/gui/Gui_i.h"
|
|
#include "lvgl/LvglKeypad.h"
|
|
#include "lvgl/LvglSync.h"
|
|
|
|
namespace tt::service::gui {
|
|
|
|
extern Gui* gui;
|
|
|
|
static void show_keyboard(lv_event_t* event) {
|
|
lv_obj_t* target = lv_event_get_current_target_obj(event);
|
|
keyboardShow(target);
|
|
lv_obj_scroll_to_view(target, LV_ANIM_ON);
|
|
}
|
|
|
|
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
|
|
keyboardHide();
|
|
}
|
|
|
|
bool keyboardIsEnabled() {
|
|
return !lvgl::keypad_is_available() || TT_CONFIG_FORCE_ONSCREEN_KEYBOARD;
|
|
}
|
|
|
|
void keyboardShow(lv_obj_t* textarea) {
|
|
lock();
|
|
|
|
if (gui->keyboard) {
|
|
lv_obj_clear_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
|
|
lv_keyboard_set_textarea(gui->keyboard, textarea);
|
|
}
|
|
|
|
unlock();
|
|
}
|
|
|
|
void keyboardHide() {
|
|
lock();
|
|
|
|
if (gui->keyboard) {
|
|
lv_obj_add_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
|
|
unlock();
|
|
}
|
|
|
|
void keyboardAddTextArea(lv_obj_t* textarea) {
|
|
lock();
|
|
tt_check(lvgl::lock(0), "lvgl should already be locked before calling this method");
|
|
|
|
if (keyboardIsEnabled()) {
|
|
lv_obj_add_event_cb(textarea, show_keyboard, LV_EVENT_FOCUSED, nullptr);
|
|
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_DEFOCUSED, nullptr);
|
|
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_READY, nullptr);
|
|
}
|
|
|
|
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
|
|
lv_group_add_obj(gui->keyboard_group, textarea);
|
|
|
|
lvgl::keypad_activate(gui->keyboard_group);
|
|
|
|
lvgl::unlock();
|
|
unlock();
|
|
}
|
|
|
|
} // namespace
|