Contributors scroll (#2093)

* adding on_right

* menu view instead of console

* fixing on_right typo

---------

Co-authored-by: gullradriel <gullradriel@no-mail.com>
This commit is contained in:
gullradriel 2024-04-08 07:45:33 +02:00 committed by GitHub
parent 8e90c65a62
commit 004799e1a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 102 additions and 96 deletions

View file

@ -1,83 +1,93 @@
#include "ui_about_simple.hpp" #include "ui_about_simple.hpp"
namespace ui { namespace ui {
AboutView::AboutView(NavigationView& nav) {
add_children({&console, &button_ok}); // TODO: Generate this automatically from github
// Information: a line starting with a '#' will be yellow coloured
button_ok.on_select = [&nav](Button&) { const std::string authors_list[] = {
nav.pop(); " ",
}; "# * List of contributors * ",
" ",
console.writeln(STR_COLOR_LIGHT_GREY "List of contributors:"); "#Mayhem:",
console.writeln(""); " ",
} "eried,euquiq,gregoryfenton",
"johnelder,jwetzell,nnemanjan00",
void AboutView::update() { "N0vaPixel,klockee,gullradriel",
if (++timer > 400) { "jamesshao8,ITAxReal,rascafr",
timer = 0; "mcules,dqs105,strijar",
"zhang00963,RedFox-Fr,aldude999",
switch (++frame) { "East2West,fossum,ArjanOnwezen",
case 1: "vXxOinvizioNxX,teixeluis",
// TODO: Generate this automatically from github "Brumi-2021,texasyojimbo",
// https://github.com/portapack-mayhem/mayhem-firmware/graphs/contributors?to=2022-01-01&from=2020-04-12&type=c "heurist1,intoxsick,ckuethe",
console.writeln(STR_COLOR_DARK_YELLOW "Mayhem:"); "notpike,jLynx,zigad",
console.writeln("eried,euquiq,gregoryfenton"); "MichalLeonBorsuk,jimilinuxguy",
console.writeln("johnelder,jwetzell,nnemanjan00"); "kallanreed,bernd-herzog",
console.writeln("N0vaPixel,klockee,gullradriel"); "NotherNgineer,zxkmm,u-foka",
console.writeln("jamesshao8,ITAxReal,rascafr"); "Netro,HTotoo",
console.writeln("mcules,dqs105,strijar"); " ",
console.writeln("zhang00963,RedFox-Fr,aldude999"); "#Havoc:",
console.writeln("East2West,fossum,ArjanOnwezen"); " ",
console.writeln("vXxOinvizioNxX,teixeluis"); "furrtek,mrmookie,NotPike",
console.writeln("Brumi-2021,texasyojimbo"); "mjwaxios,ImDroided,Giorgiofox",
console.writeln("heurist1,intoxsick,ckuethe"); "F4GEV,z4ziggy,xmycroftx",
console.writeln("notpike,jLynx,zigad"); "troussos,silascutler",
console.writeln("MichalLeonBorsuk,jimilinuxguy"); "nickbouwhuis,msoose,leres",
console.writeln("kallanreed,bernd-herzog"); "joakar,dhoetger,clem-42",
break; "brianlechthaler,ZeroChaos-...",
case 2: " ",
console.writeln("NotherNgineer,zxkmm,u-foka"); "#PortaPack:",
console.writeln("Netro,HTotoo"); " ",
console.writeln(""); "jboone,argilo",
break; " ",
"#HackRF:",
case 3: " ",
// https://github.com/portapack-mayhem/mayhem-firmware/graphs/contributors?to=2020-04-12&from=2015-07-31&type=c "mossmann,dominicgs,bvernoux",
console.writeln(STR_COLOR_DARK_YELLOW "Havoc:"); "bgamari,schneider42,miek",
console.writeln("furrtek,mrmookie,NotPike"); "willcode,hessu,Sec42",
console.writeln("mjwaxios,ImDroided,Giorgiofox"); "yhetti,ckuethe,smunaut",
console.writeln("F4GEV,z4ziggy,xmycroftx"); "wishi,mrbubble62,scateu..."};
console.writeln("troussos,silascutler");
console.writeln("nickbouwhuis,msoose,leres"); AboutView::AboutView(NavigationView& nav) {
console.writeln("joakar,dhoetger,clem-42"); add_children({&menu_view,
console.writeln("brianlechthaler,ZeroChaos-..."); &button_ok});
console.writeln("");
break; button_ok.on_select = [&nav](Button&) {
nav.pop();
case 4: };
// https://github.com/portapack-mayhem/mayhem-firmware/graphs/contributors?from=2014-07-05&to=2015-07-31&type=c
console.writeln(STR_COLOR_DARK_YELLOW "PortaPack:"); menu_view.on_left = [this]() {
console.writeln("jboone,argilo"); button_ok.focus();
console.writeln(""); };
break;
menu_view.on_right = [this]() {
case 5: button_ok.focus();
// https://github.com/mossmann/hackrf/graphs/contributors };
console.writeln(STR_COLOR_DARK_YELLOW "HackRF:");
console.writeln("mossmann,dominicgs,bvernoux"); for (const std::string& authors_line : authors_list) {
console.writeln("bgamari,schneider42,miek"); // if it's starting with #, it's a title and we have to substract the '#' and paint yellow
console.writeln("willcode,hessu,Sec42"); if (authors_line.size() > 0) {
console.writeln("yhetti,ckuethe,smunaut"); if (authors_line[0] == '#') {
console.writeln("wishi,mrbubble62,scateu..."); menu_view.add_item(
console.writeln(""); {authors_line.substr(1, authors_line.size() - 1),
frame = 0; // Loop ui::Color::yellow(),
break; nullptr,
} nullptr});
} } else {
} menu_view.add_item(
{authors_line,
void AboutView::focus() { ui::Color::white(),
button_ok.focus(); nullptr,
} nullptr});
}
} /* namespace ui */ }
}
}
void AboutView::focus() {
menu_view.focus();
// put focus on first text line
menu_view.set_highlighted(1);
}
} /* namespace ui */

View file

@ -12,25 +12,16 @@ class AboutView : public View {
AboutView(NavigationView& nav); AboutView(NavigationView& nav);
void focus() override; void focus() override;
std::string title() const override { return "About"; }; std::string title() const override { return "About"; };
int32_t timer{180};
short frame{0};
private: private:
void update(); MenuView menu_view{
{0, 0, 240, 240},
Console console{ true};
{0, 10, 240, 240}};
Button button_ok{ Button button_ok{
{240 / 3, 270, 240 / 3, 24}, {240 / 3, 270, 240 / 3, 24},
"OK", "OK",
}; };
MessageHandlerRegistration message_handler_update{
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->update();
}};
}; };
} // namespace ui } // namespace ui

View file

@ -251,8 +251,12 @@ bool MenuView::on_key(const KeyEvent key) {
case KeyEvent::Down: case KeyEvent::Down:
return set_highlighted(highlighted_item + 1); return set_highlighted(highlighted_item + 1);
case KeyEvent::Select:
case KeyEvent::Right: case KeyEvent::Right:
if (on_right) {
on_right();
}
[[fallthrough]];
case KeyEvent::Select:
if (menu_items[highlighted_item].on_select) { if (menu_items[highlighted_item].on_select) {
menu_items[highlighted_item].on_select(key); menu_items[highlighted_item].on_select(key);
} }

View file

@ -75,6 +75,7 @@ class MenuItemView : public Widget {
class MenuView : public View { class MenuView : public View {
public: public:
std::function<void(void)> on_left{}; std::function<void(void)> on_left{};
std::function<void(void)> on_right{};
std::function<void(void)> on_highlight{nullptr}; std::function<void(void)> on_highlight{nullptr};
MenuView(Rect new_parent_rect = {0, 0, screen_width, screen_height - 16}, MenuView(Rect new_parent_rect = {0, 0, screen_width, screen_height - 16},