Skip to content

Commit

Permalink
fix(color): adjust layout of model labels list to reduce text overlap (
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored May 29, 2024
1 parent 5e14ce6 commit 945136a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
37 changes: 28 additions & 9 deletions radio/src/gui/colorlcd/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,38 @@ void ListBase::onDrawEnd(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc
return;

lv_area_t coords;
lv_coord_t area_h = lv_area_get_height(dsc->draw_area);

lv_coord_t cell_right = lv_obj_get_style_pad_right(lvobj, LV_PART_ITEMS);
lv_coord_t font_h = getFontHeight(FONT(STD));

coords.x1 = dsc->draw_area->x2 - cell_right - font_h;
coords.x2 = coords.x1 + 36;
coords.y1 = dsc->draw_area->y1 + (area_h - font_h) / 2;
coords.y2 = coords.y1 + font_h - 1;
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
label_dsc.font = dsc->label_dsc->font;
label_dsc.align = LV_TEXT_ALIGN_RIGHT;

const char* sym = LV_SYMBOL_OK;
if (getSelectedSymbol)
sym = getSelectedSymbol(row);

lv_draw_label(dsc->draw_ctx, dsc->label_dsc, &coords, sym, nullptr);
lv_coord_t w = 30;
lv_coord_t h = 12;
lv_coord_t xo = 1;
lv_coord_t yo = 1;

if (smallSelectMarker) {
// Check for non-LVGL symbol
if (sym[0] != (char)0xEF) {
yo = -2;
xo = 0;
}
label_dsc.font = getFont(FONT(XS));
} else {
h = getFontHeight(FONT(STD));
xo = 2;
yo = (lv_area_get_height(dsc->draw_area) - h) / 2;
}

coords.x2 = dsc->draw_area->x2 - xo;
coords.x1 = coords.x2 - w + 1;
coords.y1 = dsc->draw_area->y1 + yo;
coords.y2 = coords.y1 + h - 1;

lv_draw_label(dsc->draw_ctx, &label_dsc, &coords, sym, nullptr);
}
3 changes: 3 additions & 0 deletions radio/src/gui/colorlcd/listbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class ListBase : public TableField
pressHandler = std::move(handler);
}

void setSmallSelectMarker() { smallSelectMarker = true; }

#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "ListBox"; }
#endif
Expand All @@ -92,6 +94,7 @@ class ListBase : public TableField
static void event_cb(lv_event_t* e);
int activeItem = -1;
bool multiSelect = false;
bool smallSelectMarker = false;

void onPress(uint16_t row, uint16_t col) override;
void onLongPressed();
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/model_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
LV_GRID_ALIGN_STRETCH, LABELS_ROW, 1);
lblselector =
new ListBox(box, rect_t{0, 0, LV_PCT(100), LV_PCT(100)}, getLabels());
lblselector->setSmallSelectMarker();
auto lbl_obj = lblselector->getLvObj();

// Sort Buttons
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/themes/etx_lv_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ LV_STYLE_CONST_MULTI_INIT(cb_marker_checked, cb_marker_checked_props);
const lv_style_const_prop_t table_cell_props[] = {
LV_STYLE_CONST_BORDER_WIDTH(1),
LV_STYLE_CONST_BORDER_SIDE(LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM),
LV_STYLE_CONST_PAD_TOP(7), LV_STYLE_CONST_PAD_BOTTOM(7),
LV_STYLE_CONST_PAD_LEFT(4), LV_STYLE_CONST_PAD_RIGHT(4),
LV_STYLE_PROP_INV,
};
LV_STYLE_CONST_MULTI_INIT(table_cell, table_cell_props);
Expand Down Expand Up @@ -514,8 +516,6 @@ void table_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
COLOR_THEME_PRIMARY1_INDEX);
lv_obj_add_style(obj, (lv_style_t*)&table_cell, LV_PART_ITEMS);
lv_obj_add_style(obj, &styles->border_color_secondary2, LV_PART_ITEMS);
lv_obj_add_style(obj, (lv_style_t*)&pad_small, LV_PART_ITEMS);
lv_obj_set_style_pad_ver(obj, 7, LV_PART_ITEMS);

lv_obj_add_style(obj, (lv_style_t*)&pressed,
LV_PART_ITEMS | LV_STATE_PRESSED);
Expand Down

0 comments on commit 945136a

Please sign in to comment.