auto scroll the name list (#2358)

* auto scroll the name list

* script

* remove uneeded empty line in script

* script
This commit is contained in:
sommermorgentraum 2024-11-14 21:52:43 +08:00 committed by GitHub
parent c8f236a708
commit 6c838256df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 4 deletions

View file

@ -1,5 +1,8 @@
#include "ui_about_simple.hpp"
#define ROLL_SPEED_FRAME_PER_LINE 60
// cuz frame rate of pp screen is probably 60, scroll per sec
namespace ui {
// TODO: Generate this automatically from github
@ -87,10 +90,42 @@ AboutView::AboutView(NavigationView& nav) {
}
}
void AboutView::on_frame_sync() {
if (interacted) return;
if (frame_sync_count++ % ROLL_SPEED_FRAME_PER_LINE == 0) {
const auto current = menu_view.highlighted_index();
const auto count = menu_view.item_count();
if (current < count - 1) {
menu_view.set_highlighted(current + 1);
} else {
menu_view.set_highlighted(0);
// ^ to go back to the REAL top instead of make the 2 at the top to make the title disappeares
menu_view.set_highlighted(2); // the first line that has human name
}
}
}
void AboutView::focus() {
button_ok.focus();
menu_view.set_highlighted(2); // the first line that has human name
}
bool AboutView::on_touch(const TouchEvent) {
interacted = true;
return false;
}
bool AboutView::on_key(const KeyEvent) {
interacted = true;
return false;
}
bool AboutView::on_encoder(const EncoderEvent) {
interacted = true;
menu_view.focus();
// put focus on last text line to make it more obvious that list is scrollable
menu_view.set_highlighted(10);
return false;
}
} /* namespace ui */