add back correct highlight to list (#1114)

This commit is contained in:
gullradriel 2023-06-07 10:17:29 +02:00 committed by GitHub
parent f2a7617b1b
commit c66df8c807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -75,18 +75,22 @@ void FreqManUIList::paint(Painter& painter) {
uint8_t nb_lines = 0;
for (uint8_t it = current_index; it < freqlist_db.size(); it++) {
uint8_t line_height = (int)nb_lines * char_height;
if (line_height < (r.height() - char_height)) {
if (line_height < (r.height() - char_height)) { // line is within the widget
std::string description = freqman_item_string(freqlist_db[it], 30);
// line is within the widget
painter.draw_string(
{0, r.location().y() + (int)nb_lines * char_height},
*text_color, description);
if (nb_lines == highlighted_index) {
const Rect r_highlighted_freq{0, r.location().y() + (int)nb_lines * char_height, 240, char_height};
painter.draw_rectangle(
painter.fill_rectangle(
r_highlighted_freq,
Color::white());
painter.draw_string(
{0, r.location().y() + (int)nb_lines * char_height},
style_highlight, description);
} else {
painter.draw_string(
{0, r.location().y() + (int)nb_lines * char_height},
*text_color, description);
}
nb_lines++;
} else {
// rect is filled, we can break

View File

@ -66,6 +66,11 @@ class FreqManUIList : public Widget {
.background = Color::black(),
.foreground = Color::white(),
};
Style style_highlight{
.font = font::fixed_8x16,
.background = Color::white(),
.foreground = Color::black(),
};
Style style_yellow{
.font = font::fixed_8x16,
.background = Color::black(),