blk_box_tc/main/drivers/wlvgl.cpp
2025-04-04 23:52:48 -05:00

56 lines
1.3 KiB
C++

#include "wlvgl.h"
#include <vector>
/// A table that maps an incrementing integer to a style reference
static std::vector<lv_style_t*> style_table;
/// A table that maps an incrementing integer to a style reference
static std::vector<lv_obj_t*> obj_table;
void reset_wlv_tables() {
style_table.clear();
obj_table.clear();
}
lv_obj_t wlv_obj_create(lv_obj_t* parent) {
// initialize the obj
lv_obj_t value = lv_obj_create(parent);
if (is_state_tracking()) {
// add the style to the table
obj_table.push_back(value);
size_t obj_index = obj_table.size();
char buf[8];
sprintf(buf, "%d", obj_index);
event_occured("lv_obj_create", buf);
}
return value;
}
void wlv_style_init(lv_style_t* style) {
// initialize the style
lv_style_init(style);
if (is_state_tracking()) {
// add the style to the table
style_table.push_back(style);
size_t style_index = style_table.size();
char buf[8];
sprintf(buf, "%d", style_index);
event_occured("lv_style_init", buf);
}
}
void wlv_obj_set_style_bg_color(lv_obj_t* obj, lv_color_t value, lv_style_selector_t selector) {
lv_obj_set_style_bg_color(obj, value, selector);
if (is_state_tracking()) {
char buf[8];
sprintf(buf, "%d", style_index);
event_occured("lv_obj_set_style_bg_color", buf);
}
}