chore(ui): improve static text and window base speed (#88)

This commit is contained in:
Malte Langermann
2023-03-26 18:16:28 +10:00
committed by GitHub
parent d56d641fb0
commit f84fbd01bf
2 changed files with 7 additions and 7 deletions
+5 -2
View File
@@ -25,8 +25,7 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt,
Window(parent, rect, windowFlags, textFlags, lv_label_create), Window(parent, rect, windowFlags, textFlags, lv_label_create),
text(std::move(txt)) text(std::move(txt))
{ {
lv_label_set_text(lvobj, text.c_str()); lv_obj_enable_style_refresh(false);
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_set_style_text_font(lvobj, getFont(textFlags), LV_PART_MAIN); lv_obj_set_style_text_font(lvobj, getFont(textFlags), LV_PART_MAIN);
@@ -43,6 +42,10 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt,
} }
lv_obj_set_style_grid_cell_x_align(lvobj, LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(lvobj, LV_GRID_ALIGN_STRETCH, 0);
lv_label_set_text(lvobj, text.c_str());
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
lv_obj_enable_style_refresh(true);
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
} }
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
+2 -5
View File
@@ -119,17 +119,17 @@ class Window
void setRect(rect_t value) void setRect(rect_t value)
{ {
rect = value; rect = value;
lv_obj_enable_style_refresh(false);
lv_obj_set_pos(lvobj, rect.x, rect.y); lv_obj_set_pos(lvobj, rect.x, rect.y);
lv_obj_set_width(lvobj, rect.w); lv_obj_set_width(lvobj, rect.w);
lv_obj_enable_style_refresh(true);
lv_obj_set_height(lvobj, rect.h); lv_obj_set_height(lvobj, rect.h);
invalidate();
} }
void setWidth(coord_t value) void setWidth(coord_t value)
{ {
rect.w = value; rect.w = value;
lv_obj_set_width(lvobj, rect.w); lv_obj_set_width(lvobj, rect.w);
invalidate();
} }
void setWindowCentered() void setWindowCentered()
@@ -143,21 +143,18 @@ class Window
{ {
rect.h = value; rect.h = value;
if (lvobj != nullptr) lv_obj_set_height(lvobj, rect.h); if (lvobj != nullptr) lv_obj_set_height(lvobj, rect.h);
invalidate();
} }
void setLeft(coord_t x) void setLeft(coord_t x)
{ {
rect.x = x; rect.x = x;
lv_obj_set_pos(lvobj, rect.x, rect.y); lv_obj_set_pos(lvobj, rect.x, rect.y);
invalidate();
} }
void setTop(coord_t y) void setTop(coord_t y)
{ {
rect.y = y; rect.y = y;
lv_obj_set_pos(lvobj, rect.x, rect.y); lv_obj_set_pos(lvobj, rect.x, rect.y);
invalidate();
} }
coord_t left() const coord_t left() const