#include "wlvgl.h" #include /// A table that maps an incrementing integer to a style reference static std::vector style_table; /// A table that maps an incrementing integer to a style reference static std::vector obj_table; static int index_of_style(lv_style_t* style) { for (size_t i = 0; i < style_table.size(); i++) { if (style_table[i] == style) { return i; } } return -1; } static int index_of_obj(lv_obj_t* obj) { for (size_t i = 0; i < obj_table.size(); i++) { if (obj_table[i] == obj) { return i; } } return -1; } 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()) { int obj_index = index_of_obj(obj); char buf[64]; sprintf(buf, "%d,%d,%ld", obj_index, value.full, selector); event_occured("lv_obj_set_style_bg_color", buf); } }