mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
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
This commit is contained in:
parent
19b77bf03b
commit
e15a8ed2d8
@ -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_;
|
||||
|
@ -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}};
|
||||
|
@ -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<char>(field_raw.value())});
|
||||
};
|
||||
}
|
||||
|
||||
void AlphanumView::set_mode(const uint32_t new_mode) {
|
||||
@ -96,10 +109,6 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -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<std::string, const char*> 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<Button, 30> 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},
|
||||
"<DEL"};
|
||||
|
||||
Button button_mode{
|
||||
{16 * 8 - 2, 33 * 8, 4 * 8 + 2, 32},
|
||||
""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -50,7 +50,7 @@ class TextEntryView : public View {
|
||||
|
||||
TextField text_input;
|
||||
Button button_ok{
|
||||
{10 * 8, 33 * 8, 9 * 8, 32},
|
||||
{22 * 8, 33 * 8, 7 * 8, 32},
|
||||
"OK"};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user