fix table behavor on touch release (Highlight)

This commit is contained in:
kevin koenig
2022-06-17 06:02:01 -04:00
parent 85cdf709a0
commit 732cb1ba19
4 changed files with 67 additions and 1 deletions
+1
View File
@@ -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})
+2 -1
View File
@@ -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);
}
@@ -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);
}
}
@@ -0,0 +1,16 @@
#ifndef EDGETX_TABLE_H
#define EDGETX_TABLE_H
#include <lvgl/lvgl.h>
#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