From e15a8ed2d8de2441de1c7ccb54d0cf2b073cb551 Mon Sep 17 00:00:00 2001 From: Stupid retard noob attention king Date: Fri, 30 Jun 2023 00:24:18 +0800 Subject: [PATCH] improve keyboard (#1209) * init commit for raw input in keyboard * clean up * clean up - 1 * clean up - 2 * can input underline and < now * format fix * textual change * textual change - 2 * textual change - 3 * textual change - 4 * edit for PR comment * edit for PR comment - 2 * edit for PR comment - 3 * edit for PR comment - 4 * edit for PR comment - 5 --- .../application/apps/ui_flash_utility.hpp | 2 +- .../application/apps/ui_looking_glass_app.hpp | 2 +- firmware/application/apps/ui_playlist.hpp | 9 +++-- firmware/application/ui/ui_alphanum.cpp | 25 ++++++++----- firmware/application/ui/ui_alphanum.hpp | 35 +++++++++++-------- firmware/application/ui/ui_textentry.hpp | 2 +- 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/firmware/application/apps/ui_flash_utility.hpp b/firmware/application/apps/ui_flash_utility.hpp index 201290ae..9ea96c0b 100644 --- a/firmware/application/apps/ui_flash_utility.hpp +++ b/firmware/application/apps/ui_flash_utility.hpp @@ -40,7 +40,7 @@ class FlashUtilityView : public View { void focus() override; - std::string title() const override { return "FlashUtility"; }; // Removed the space because the title and speaker icon overlapped. + std::string title() const override { return "Flash Utility"; }; private: NavigationView& nav_; diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index d692717b..823d7990 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -63,7 +63,7 @@ class GlassView : public View { GlassView& operator=(const GlassView& nav); ~GlassView(); - std::string title() const override { return "LookingGlass"; }; + std::string title() const override { return "Looking Glass"; }; void on_show() override; void on_hide() override; diff --git a/firmware/application/apps/ui_playlist.hpp b/firmware/application/apps/ui_playlist.hpp index f1c796d9..7303253d 100644 --- a/firmware/application/apps/ui_playlist.hpp +++ b/firmware/application/apps/ui_playlist.hpp @@ -118,11 +118,16 @@ class PlaylistView : public View { Text text_sample_rate{ {10 * 8, 1 * 16, 7 * 8, 16}}; + /*v making there's 1px line (instead of two) between two progress bars, + * by letting 1px overlapped. + * So, since they overlapped 1px, they are visually same, and looks better. + */ + ProgressBar progressbar_track{ - {18 * 8, 1 * 16, 12 * 8, 8}}; + {18 * 8, 1 * 16, 12 * 8, 8 + 1}}; ProgressBar progressbar_transmit{ - {18 * 8, 3 * 8, 12 * 8, 8}}; + {18 * 8, 3 * 8 - 1, 12 * 8, 8}}; Text text_duration{ {0 * 8, 2 * 16, 5 * 8, 16}}; diff --git a/firmware/application/ui/ui_alphanum.cpp b/firmware/application/ui/ui_alphanum.cpp index 024125de..409909b3 100644 --- a/firmware/application/ui/ui_alphanum.cpp +++ b/firmware/application/ui/ui_alphanum.cpp @@ -37,9 +37,13 @@ AlphanumView::AlphanumView( : TextEntryView(nav, str, max_length) { size_t n; - add_children({&button_mode, - &text_raw, - &field_raw}); + add_children({ + &labels, + &field_raw, + &text_raw_to_char, + &button_delete, + &button_mode, + }); const auto button_fn = [this](Button& button) { this->on_button(button); @@ -65,10 +69,19 @@ AlphanumView::AlphanumView( set_mode(mode + 1); }; + button_delete.on_select = [this](Button&) { + char_delete(); + }; + field_raw.set_value('0'); field_raw.on_select = [this](NumberField&) { char_add(field_raw.value()); }; + + // make text_raw_to_char widget display the char value from field_raw + field_raw.on_change = [this](auto) { + text_raw_to_char.set(std::string{static_cast(field_raw.value())}); + }; } void AlphanumView::set_mode(const uint32_t new_mode) { @@ -96,11 +109,7 @@ void AlphanumView::set_mode(const uint32_t new_mode) { void AlphanumView::on_button(Button& button) { const auto c = button.text()[0]; - - if (c == '<') - char_delete(); - else - char_add(c); + char_add(c); } bool AlphanumView::on_encoder(const EncoderEvent delta) { diff --git a/firmware/application/ui/ui_alphanum.hpp b/firmware/application/ui/ui_alphanum.hpp index e415ff9e..87802660 100644 --- a/firmware/application/ui/ui_alphanum.hpp +++ b/firmware/application/ui/ui_alphanum.hpp @@ -43,14 +43,14 @@ class AlphanumView : public TextEntryView { bool on_encoder(const EncoderEvent delta) override; private: - const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, .<"; - const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, .<"; - const char* const keys_digit = "0123456789!\"#'()*+-/:;=>?@[\\]<"; + const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, ._"; + const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, ._"; + const char* const keys_digit = "0123456789!\"#'()*+-/:;=<>@[\\]?"; const std::pair key_sets[3] = { - {"Upper", keys_upper}, - {"Lower", keys_lower}, - {"Digit", keys_digit}}; + {"ABC", keys_upper}, + {"abc", keys_lower}, + {"123", keys_digit}}; int16_t focused_button = 0; uint32_t mode = 0; // Uppercase @@ -60,13 +60,10 @@ class AlphanumView : public TextEntryView { std::array buttons{}; - Button button_mode{ - {21 * 8, 33 * 8, 8 * 8, 32}, - ""}; + Labels labels{ + {{1 * 8, 33 * 8}, "Raw:", Color::light_grey()}, + {{1 * 8, 35 * 8}, "AKA:", Color::light_grey()}}; - Text text_raw{ - {1 * 8, 33 * 8, 4 * 8, 16}, - "Raw:"}; NumberField field_raw{ {5 * 8, 33 * 8}, 3, @@ -74,9 +71,17 @@ class AlphanumView : public TextEntryView { 1, '0'}; - Button button_ok{ - {10 * 8, 33 * 8, 9 * 8, 32}, - "OK"}; + Text text_raw_to_char{ + {5 * 8, 35 * 8, 4 * 8, 16}, + "0"}; + + Button button_delete{ + {10 * 8 - 2, 33 * 8, 4 * 8 + 2, 32}, + "