Skip to content

Commit

Permalink
fix(color): Slow performance of Manage Models page (#4551)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored Jan 19, 2024
1 parent 4cad7a2 commit b0824f9
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions radio/src/gui/colorlcd/model_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ class ModelButton : public Button
setWidth(MODEL_SELECT_CELL_WIDTH);
setHeight(MODEL_SELECT_CELL_HEIGHT);

check(modelCell == modelslist.getCurrentModel());

lv_obj_add_event_cb(lvobj, ModelButton::on_draw, LV_EVENT_DRAW_MAIN_BEGIN,
nullptr);
}

~ModelButton()
{
if (buffer) {
delete buffer;
}
}

void addDetails()
{
LcdFlags bg_color = modelCell == modelslist.getCurrentModel()
? COLOR_THEME_ACTIVE
: COLOR_THEME_PRIMARY2;
Expand Down Expand Up @@ -115,14 +130,16 @@ class ModelButton : public Button
name->setBackgroudOpacity(LV_OPA_80);
name->setBackgroundColor(bg_color);
name->padTop(-3);

check(modelCell == modelslist.getCurrentModel());
}

~ModelButton()
static void on_draw(lv_event_t *e)
{
if (buffer) {
delete buffer;
auto btn = (ModelButton *)lv_obj_get_user_data(lv_event_get_target(e));
if (btn) {
if (!btn->loaded) {
btn->loaded = true;
btn->addDetails();
}
}
}

Expand Down

0 comments on commit b0824f9

Please sign in to comment.