* SdCard HAL refactored (#135) - Refactor SdCard HAL - introduce Lockable * Screenshot and FatFS improvements (#136) - Fix screenshots on ESP32 - Improve Screenshot service - Convert Screenshot app to class-based instead of structs - Screenshot app now automatically updates when task is finished - Enable FatFS long filename support * Re-use common log messages (#138) For consistency and binary size reduction * Toolbar spinner should get margin to the right * More TactilityC features (#139) * Rewrote Loader - Simplified Loader by removing custom threa - Created DispatcherThread - Move auto-starting apps to Boot app - Fixed Dispatcher bug where it could get stuck not processing new messages * Hide AP settings if the AP is not saved * Missing from previous commit * Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED * Refactored files app and created InputDialog (#140) - Changed Files app so that it has a View and State - Files app now allows for long-pressing on files to perform actions - Files app now has rename and delete actions - Created InputDialog app - Improved AlertDialog app layout
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#include "Check.h"
|
|
#include "Log.h"
|
|
#include "service/gui/Gui_i.h"
|
|
#include "lvgl/LvglSync.h"
|
|
#include "lvgl/Statusbar.h"
|
|
#include "lvgl/Style.h"
|
|
|
|
namespace tt::service::gui {
|
|
|
|
#define TAG "gui"
|
|
|
|
static lv_obj_t* create_app_views(Gui* gui, lv_obj_t* parent, app::AppContext& app) {
|
|
lvgl::obj_set_style_bg_blacken(parent);
|
|
|
|
lv_obj_t* vertical_container = lv_obj_create(parent);
|
|
lv_obj_set_size(vertical_container, LV_PCT(100), LV_PCT(100));
|
|
lv_obj_set_flex_flow(vertical_container, LV_FLEX_FLOW_COLUMN);
|
|
lvgl::obj_set_style_no_padding(vertical_container);
|
|
lvgl::obj_set_style_bg_blacken(vertical_container);
|
|
|
|
// TODO: Move statusbar into separate ViewPort
|
|
app::Flags flags = app.getFlags();
|
|
if (flags.showStatusbar) {
|
|
lvgl::statusbar_create(vertical_container);
|
|
}
|
|
|
|
lv_obj_t* child_container = lv_obj_create(vertical_container);
|
|
lv_obj_set_width(child_container, LV_PCT(100));
|
|
lv_obj_set_flex_grow(child_container, 1);
|
|
|
|
if (keyboardIsEnabled()) {
|
|
gui->keyboard = lv_keyboard_create(vertical_container);
|
|
lv_obj_add_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
|
|
} else {
|
|
gui->keyboard = nullptr;
|
|
}
|
|
|
|
return child_container;
|
|
}
|
|
|
|
void redraw(Gui* gui) {
|
|
tt_assert(gui);
|
|
|
|
// Lock GUI and LVGL
|
|
lock();
|
|
|
|
if (lvgl::lock(1000)) {
|
|
lv_obj_clean(gui->lvgl_parent);
|
|
|
|
ViewPort* view_port = gui->app_view_port;
|
|
if (view_port != nullptr) {
|
|
app::AppContext& app = view_port->app;
|
|
lv_obj_t* container = create_app_views(gui, gui->lvgl_parent, app);
|
|
view_port_show(view_port, container);
|
|
} else {
|
|
TT_LOG_W(TAG, "nothing to draw");
|
|
}
|
|
|
|
// Unlock GUI and LVGL
|
|
lvgl::unlock();
|
|
} else {
|
|
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
|
}
|
|
|
|
unlock();
|
|
}
|
|
|
|
} // namespace
|