Support showing invalid entries in Freqman and allow minor edits (#1269)

* Support showing invalid entries in Freqman and allow minor edits
* Use light_grey instead of grey
* Fix comment
* Fix null in description bug
* Fix spacing in delete entry dialog
* trim in delete modal
This commit is contained in:
Kyle Reed 2023-07-12 23:28:27 -07:00 committed by GitHub
parent 4ed06b9eff
commit d72d935607
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 16 deletions

View file

@ -56,16 +56,19 @@ void FreqManUIList::paint(Painter& painter) {
auto text = std::string{};
auto index = start_index_ + offset;
auto line_position = rect.location() + Point{4, 1 + (int)offset * char_height};
// Highlight the selected item.
auto style = (offset == selected_index_) ? &Styles::bg_white : base_style;
auto is_selected = offset == selected_index_;
auto style = base_style;
if (index < db_->entry_count()) {
auto entry = (*db_)[index];
// db_ is directly backed by a file, so invalid lines cannot be
// pre-filtered. Just show an empty 'slot' in this case.
// pre-filtered. Show an empty entry if 'Unknown'.
if (entry.type != freqman_type::Unknown)
text = pretty_string(entry, line_max_length);
// Otherwise, if 'Raw' indicate an invalid entry by color.
if (entry.type == freqman_type::Raw)
style = &Styles::light_grey;
}
// Pad right with ' ' so trailing chars are cleaned up.
@ -73,7 +76,8 @@ void FreqManUIList::paint(Painter& painter) {
if (text.length() < line_max_length)
text.resize(line_max_length, ' ');
painter.draw_string(line_position, *style, text);
painter.draw_string(
line_position, (is_selected ? style->invert() : *style), text);
}
// Draw a bounding rectangle when focused.