mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-22 16:35:06 +00:00
Create wrapper for lv_textare_create to automatically support hardware keyboards
This commit is contained in:
parent
f899ccbf1c
commit
5868ba15c5
@ -55,6 +55,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
|||||||
add_compile_definitions(LV_CONF_PATH="${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h")
|
add_compile_definitions(LV_CONF_PATH="${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h")
|
||||||
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
|
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
|
||||||
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_log_write" APPEND)
|
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_log_write" APPEND)
|
||||||
|
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_textarea_create" APPEND)
|
||||||
else ()
|
else ()
|
||||||
message("Building for sim target")
|
message("Building for sim target")
|
||||||
add_compile_definitions(CONFIG_TT_BOARD_ID="simulator")
|
add_compile_definitions(CONFIG_TT_BOARD_ID="simulator")
|
||||||
|
|||||||
@ -117,7 +117,6 @@ public:
|
|||||||
lv_textarea_set_one_line(speedTextarea, true);
|
lv_textarea_set_one_line(speedTextarea, true);
|
||||||
lv_obj_set_width(speedTextarea, LV_PCT(50));
|
lv_obj_set_width(speedTextarea, LV_PCT(50));
|
||||||
lv_obj_align(speedTextarea, LV_ALIGN_TOP_RIGHT, 0, 40);
|
lv_obj_align(speedTextarea, LV_ALIGN_TOP_RIGHT, 0, 40);
|
||||||
service::gui::keyboardAddTextArea(speedTextarea);
|
|
||||||
|
|
||||||
auto* baud_rate_label = lv_label_create(wrapper);
|
auto* baud_rate_label = lv_label_create(wrapper);
|
||||||
lv_obj_align(baud_rate_label, LV_ALIGN_TOP_LEFT, 0, 50);
|
lv_obj_align(baud_rate_label, LV_ALIGN_TOP_LEFT, 0, 50);
|
||||||
|
|||||||
@ -186,7 +186,6 @@ public:
|
|||||||
lv_obj_set_width(logTextarea, LV_PCT(100));
|
lv_obj_set_width(logTextarea, LV_PCT(100));
|
||||||
lv_obj_add_state(logTextarea, LV_STATE_DISABLED);
|
lv_obj_add_state(logTextarea, LV_STATE_DISABLED);
|
||||||
lv_obj_set_style_margin_ver(logTextarea, 0, 0);
|
lv_obj_set_style_margin_ver(logTextarea, 0, 0);
|
||||||
service::gui::keyboardAddTextArea(logTextarea);
|
|
||||||
|
|
||||||
auto* input_wrapper = lv_obj_create(parent);
|
auto* input_wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_size(input_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
|
lv_obj_set_size(input_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
@ -200,7 +199,6 @@ public:
|
|||||||
lv_textarea_set_placeholder_text(inputTextarea, "Text to send");
|
lv_textarea_set_placeholder_text(inputTextarea, "Text to send");
|
||||||
lv_obj_set_width(inputTextarea, LV_PCT(100));
|
lv_obj_set_width(inputTextarea, LV_PCT(100));
|
||||||
lv_obj_set_flex_grow(inputTextarea, 1);
|
lv_obj_set_flex_grow(inputTextarea, 1);
|
||||||
service::gui::keyboardAddTextArea(inputTextarea);
|
|
||||||
|
|
||||||
auto* terminator_dropdown = lv_dropdown_create(input_wrapper);
|
auto* terminator_dropdown = lv_dropdown_create(input_wrapper);
|
||||||
lv_dropdown_set_options(terminator_dropdown, "\\n\n\\r\\n");
|
lv_dropdown_set_options(terminator_dropdown, "\\n\n\\r\\n");
|
||||||
|
|||||||
@ -48,12 +48,4 @@ bool hardware_keyboard_is_available();
|
|||||||
*/
|
*/
|
||||||
void hardware_keyboard_set_indev(lv_indev_t* device);
|
void hardware_keyboard_set_indev(lv_indev_t* device);
|
||||||
|
|
||||||
/**
|
|
||||||
* Glue code for the on-screen keyboard and the hardware keyboard:
|
|
||||||
* - Attach automatic hide/show parameters for the on-screen keyboard.
|
|
||||||
* - Registers the textarea to the default lv_group_t for hardware keyboards.
|
|
||||||
* @param[in] textarea
|
|
||||||
*/
|
|
||||||
void keyboard_add_textarea(lv_obj_t* textarea);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -154,7 +154,6 @@ public:
|
|||||||
lv_obj_set_height(input_field, LV_PCT(100));
|
lv_obj_set_height(input_field, LV_PCT(100));
|
||||||
lv_textarea_set_placeholder_text(input_field, "Type a message...");
|
lv_textarea_set_placeholder_text(input_field, "Type a message...");
|
||||||
lv_textarea_set_one_line(input_field, true);
|
lv_textarea_set_one_line(input_field, true);
|
||||||
service::gui::keyboardAddTextArea(input_field);
|
|
||||||
|
|
||||||
// Send button
|
// Send button
|
||||||
auto* send_btn = lv_btn_create(input_panel);
|
auto* send_btn = lv_btn_create(input_panel);
|
||||||
|
|||||||
@ -200,7 +200,6 @@ void View::init(lv_obj_t* parent, Mode mode) {
|
|||||||
path_textarea = lv_textarea_create(bottom_wrapper);
|
path_textarea = lv_textarea_create(bottom_wrapper);
|
||||||
lv_textarea_set_one_line(path_textarea, true);
|
lv_textarea_set_one_line(path_textarea, true);
|
||||||
lv_obj_set_flex_grow(path_textarea, 1);
|
lv_obj_set_flex_grow(path_textarea, 1);
|
||||||
service::gui::keyboardAddTextArea(path_textarea);
|
|
||||||
lv_obj_add_event_cb(path_textarea, onPathTextChanged, LV_EVENT_VALUE_CHANGED, this);
|
lv_obj_add_event_cb(path_textarea, onPathTextChanged, LV_EVENT_VALUE_CHANGED, this);
|
||||||
|
|
||||||
select_button = lv_button_create(bottom_wrapper);
|
select_button = lv_button_create(bottom_wrapper);
|
||||||
|
|||||||
@ -106,7 +106,6 @@ public:
|
|||||||
if (parameters->optString(PARAMETER_BUNDLE_KEY_PREFILLED, prefilled)) {
|
if (parameters->optString(PARAMETER_BUNDLE_KEY_PREFILLED, prefilled)) {
|
||||||
lv_textarea_set_text(textarea, prefilled.c_str());
|
lv_textarea_set_text(textarea, prefilled.c_str());
|
||||||
}
|
}
|
||||||
service::gui::keyboardAddTextArea(textarea);
|
|
||||||
|
|
||||||
auto* button_wrapper = lv_obj_create(parent);
|
auto* button_wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_flex_flow(button_wrapper, LV_FLEX_FLOW_ROW);
|
lv_obj_set_flex_flow(button_wrapper, LV_FLEX_FLOW_ROW);
|
||||||
|
|||||||
@ -172,8 +172,6 @@ class NotesApp : public App {
|
|||||||
if (!file::findOrCreateDirectory(context.getPaths()->getDataDirectory(), 0777)) {
|
if (!file::findOrCreateDirectory(context.getPaths()->getDataDirectory(), 0777)) {
|
||||||
TT_LOG_E(TAG, "Failed to find or create path %s", context.getPaths()->getDataDirectory().c_str());
|
TT_LOG_E(TAG, "Failed to find or create path %s", context.getPaths()->getDataDirectory().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
lvgl::keyboard_add_textarea(uiNoteText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
|
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
|
||||||
|
|||||||
@ -271,9 +271,6 @@ void ScreenshotApp::onShow(AppContext& appContext, lv_obj_t* parent) {
|
|||||||
createFilePathWidgets(wrapper);
|
createFilePathWidgets(wrapper);
|
||||||
createTimerSettingsWidgets(wrapper);
|
createTimerSettingsWidgets(wrapper);
|
||||||
|
|
||||||
service::gui::keyboardAddTextArea(delayTextArea);
|
|
||||||
service::gui::keyboardAddTextArea(pathTextArea);
|
|
||||||
|
|
||||||
updateScreenshotMode();
|
updateScreenshotMode();
|
||||||
|
|
||||||
if (!updateTimer->isRunning()) {
|
if (!updateTimer->isRunning()) {
|
||||||
|
|||||||
@ -221,7 +221,6 @@ public:
|
|||||||
lv_obj_add_event_cb(textarea, onTextareaValueChangedCallback, LV_EVENT_VALUE_CHANGED, this);
|
lv_obj_add_event_cb(textarea, onTextareaValueChangedCallback, LV_EVENT_VALUE_CHANGED, this);
|
||||||
filterTextareaWidget = textarea;
|
filterTextareaWidget = textarea;
|
||||||
lv_obj_set_flex_grow(textarea, 1);
|
lv_obj_set_flex_grow(textarea, 1);
|
||||||
service::gui::keyboardAddTextArea(textarea);
|
|
||||||
|
|
||||||
auto* list = lv_list_create(parent);
|
auto* list = lv_list_create(parent);
|
||||||
lv_obj_set_width(list, LV_PCT(100));
|
lv_obj_set_width(list, LV_PCT(100));
|
||||||
|
|||||||
@ -187,10 +187,6 @@ void View::init(AppContext& app, lv_obj_t* parent) {
|
|||||||
// Bottom buttons
|
// Bottom buttons
|
||||||
createBottomButtons(wrapper);
|
createBottomButtons(wrapper);
|
||||||
|
|
||||||
// Keyboard bindings
|
|
||||||
service::gui::keyboardAddTextArea(ssid_textarea);
|
|
||||||
service::gui::keyboardAddTextArea(password_textarea);
|
|
||||||
|
|
||||||
// Init from app parameters
|
// Init from app parameters
|
||||||
auto bundle = app.getParameters();
|
auto bundle = app.getParameters();
|
||||||
if (bundle != nullptr) {
|
if (bundle != nullptr) {
|
||||||
|
|||||||
@ -37,8 +37,4 @@ void hardware_keyboard_set_indev(lv_indev_t* device) {
|
|||||||
keyboard_device = device;
|
keyboard_device = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyboard_add_textarea(lv_obj_t* textarea) {
|
|
||||||
service::gui::keyboardAddTextArea(textarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
Tactility/Source/lvgl/Wrappers.cpp
Normal file
14
Tactility/Source/lvgl/Wrappers.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <lvgl.h>
|
||||||
|
#include <Tactility/service/gui/Gui.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
extern lv_obj_t * __real_lv_textarea_create(lv_obj_t * parent);
|
||||||
|
|
||||||
|
lv_obj_t * __wrap_lv_textarea_create(lv_obj_t * parent) {
|
||||||
|
auto textarea = __real_lv_textarea_create(parent);
|
||||||
|
tt::service::gui::keyboardAddTextArea(textarea);
|
||||||
|
return textarea;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -50,14 +50,6 @@ bool tt_lvgl_hardware_keyboard_is_available();
|
|||||||
*/
|
*/
|
||||||
void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device);
|
void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device);
|
||||||
|
|
||||||
/**
|
|
||||||
* Glue code for the on-screen keyboard and the hardware keyboard:
|
|
||||||
* - Attach automatic hide/show parameters for the on-screen keyboard.
|
|
||||||
* - Registers the textarea to the default lv_group_t for hardware keyboards.
|
|
||||||
* @param[in] textarea
|
|
||||||
*/
|
|
||||||
void tt_lvgl_keyboard_add_textarea(lv_obj_t* textarea);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -139,7 +139,6 @@ const struct esp_elfsym elf_symbols[] {
|
|||||||
ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_deactivate),
|
ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_deactivate),
|
||||||
ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_is_available),
|
ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_is_available),
|
||||||
ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_set_indev),
|
ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_set_indev),
|
||||||
ESP_ELFSYM_EXPORT(tt_lvgl_keyboard_add_textarea),
|
|
||||||
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create),
|
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create),
|
||||||
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create_for_app),
|
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create_for_app),
|
||||||
ESP_ELFSYM_EXPORT(tt_message_queue_alloc),
|
ESP_ELFSYM_EXPORT(tt_message_queue_alloc),
|
||||||
|
|||||||
@ -30,8 +30,4 @@ void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device) {
|
|||||||
tt::lvgl::hardware_keyboard_set_indev(device);
|
tt::lvgl::hardware_keyboard_set_indev(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tt_lvgl_keyboard_add_textarea(lv_obj_t* textarea) {
|
|
||||||
tt::lvgl::keyboard_add_textarea(textarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user