fixing edit freq,edit desc, delete freq (#1117)

* fixing edit freq,edit desc, delete freq
* fixing scrolling issues
* fixing indent
This commit is contained in:
gullradriel
2023-06-07 10:17:55 +02:00
committed by GitHub
parent c66df8c807
commit eecdd3acda
6 changed files with 89 additions and 116 deletions

View File

@@ -108,8 +108,19 @@ void FreqManUIList::paint(Painter& painter) {
void FreqManUIList::set_db(freqman_db& db) {
freqlist_db = db;
current_index = 0;
highlighted_index = 0;
if (db.size() == 0) {
current_index = 0;
highlighted_index = 0;
} else {
if ((unsigned)(current_index + highlighted_index) >= db.size()) {
current_index = db.size() - 1 - highlighted_index;
}
if (current_index < 0) {
current_index = 0;
if (highlighted_index > 0)
highlighted_index--;
}
}
}
void FreqManUIList::on_focus() {

View File

@@ -56,8 +56,9 @@ class FreqManUIList : public Widget {
bool on_touch(const TouchEvent event) override;
bool on_encoder(EncoderEvent delta) override;
void set_highlighted_index(int index); // set highlighted_index and return capped highlighted_index value to set in caller
void set_highlighted_index(int index); // internal set highlighted_index in list handler
uint8_t get_index(); // return highlighed + index
uint8_t set_index(uint8_t index); // try to set current_index + highlighed from index, return capped index
void set_db(freqman_db& db);
private: