Hi Everyone,
I’m trying to make custom widget in LVGL. I’ve created simple component based on lv_objx_template.c/h
. My widget will be a composition of few standard widget including scale and few labels. For sake of this example I simplified my widget to following code:
#include "gc_guage.h"
#include "../LVGL/src/core/lv_obj_private.h"
#include "../LVGL/src/core/lv_obj_class_private.h"
#define MY_CLASS &gc_guage_class
static void gc_guage_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
const lv_obj_class_t gc_guage_class = {
.constructor_cb = gc_guage_constructor,
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
.base_class = &lv_obj_class,
.width_def = LV_DPI_DEF,
.height_def = LV_DPI_DEF,
.instance_size = sizeof(gc_guage_t),
.name = "gc_guage",
};
lv_obj_t* gc_guage_create(lv_obj_t *parent) {
LV_LOG_INFO("begin");
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
lv_obj_class_init_obj(obj);
gc_guage_t *_guage = (gc_guage_t *)obj;
LV_ASSERT_MALLOC(obj);
if (obj == NULL) return NULL;
lv_obj_t *container = lv_obj_create(obj);
return obj;
}
Everything seems to work so far.
The issue is when I’m trying to insert my widget into GRID layout with:
lv_obj_set_grid_cell(my_widget, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
The widget doesn’t fill entire space of grid cell. Every other lvgl built-in widget I put into grid this way is stretching to fill entire grid cell but mine stays small in the corner of grid’s cell.
Im suspecting this part of code:
[...]
.width_def = LV_DPI_DEF,
.height_def = LV_DPI_DEF,
[...]
but my widget seems to not respond to any changes for this values.
I’ve also try to experiment with events
like LV_EVENT_SIZE_CHANGED
but with no success.
What is missing in my widget?
Also if you know any source of knowledge in custom widget subject let me know.