diff --git a/radio/src/thirdparty/libopenui/src/CMakeLists.txt b/radio/src/thirdparty/libopenui/src/CMakeLists.txt index f55e96b2e..50d910e00 100644 --- a/radio/src/thirdparty/libopenui/src/CMakeLists.txt +++ b/radio/src/thirdparty/libopenui/src/CMakeLists.txt @@ -38,6 +38,7 @@ set(LIBOPENUI_SRC widgets/window_base.c widgets/simple_btn.c widgets/field_edit.c + widgets/edgetx_table.c ) foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC}) diff --git a/radio/src/thirdparty/libopenui/src/table.cpp b/radio/src/thirdparty/libopenui/src/table.cpp index d83488ae4..cf249a564 100644 --- a/radio/src/thirdparty/libopenui/src/table.cpp +++ b/radio/src/thirdparty/libopenui/src/table.cpp @@ -18,6 +18,7 @@ */ #include "table.h" +#include "widgets/edgetx_table.h" void TableField::event_cb(lv_event_t *e) { @@ -135,7 +136,7 @@ void TableField::draw_end(lv_event_t* e) } TableField::TableField(Window* parent, const rect_t& rect, WindowFlags windowFlags) : - Window(parent, rect, windowFlags, 0, lv_table_create) + Window(parent, rect, windowFlags, 0, edgetx_table_create) { lv_obj_add_event_cb(lvobj, TableField::event_cb, LV_EVENT_ALL, nullptr); } diff --git a/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.c b/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.c new file mode 100644 index 000000000..22040de91 --- /dev/null +++ b/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.c @@ -0,0 +1,48 @@ + +#include "edgetx_table.h" + + +#define MY_CLASS &lv_edgetx_table_class + +static void edgetx_table_event(const lv_obj_class_t * class_p, lv_event_t * e); + +const lv_obj_class_t lv_edgetx_table_class = { + .constructor_cb = NULL, + .destructor_cb = NULL, + .event_cb = edgetx_table_event, + .width_def = LV_SIZE_CONTENT, + .height_def = LV_SIZE_CONTENT, + .base_class = &lv_table_class, + .editable = LV_OBJ_CLASS_EDITABLE_TRUE, + .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, + .instance_size = 0, +}; + + +lv_obj_t * edgetx_table_create(lv_obj_t * parent) +{ + lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent); + lv_obj_class_init_obj(obj); + return obj; +} + + +static void edgetx_table_event(const lv_obj_class_t * class_p, lv_event_t * e) +{ + lv_res_t res; + + lv_table_t * obj = (lv_table_t *) lv_event_get_target(e); + uint16_t col = obj->col_act; + uint16_t row = obj->row_act; + + /*Call the ancestor's event handler*/ + res = lv_obj_event_base(MY_CLASS, e); + if(res != LV_RES_OK) return; + + lv_event_code_t code = lv_event_get_code(e); + if (code == LV_EVENT_RELEASED) { + obj->col_act = col; + obj->row_act = row; + lv_obj_invalidate((lv_obj_t *)obj); + } +} diff --git a/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.h b/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.h new file mode 100644 index 000000000..613753471 --- /dev/null +++ b/radio/src/thirdparty/libopenui/src/widgets/edgetx_table.h @@ -0,0 +1,16 @@ +#ifndef EDGETX_TABLE_H +#define EDGETX_TABLE_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const lv_obj_class_t lv_edgetx_table_class; +lv_obj_t* edgetx_table_create(lv_obj_t* parent); + +#ifdef __cplusplus +}; +#endif + +#endif