mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-23 16:19:59 -05: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;
|
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:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
@ -118,11 +118,16 @@ class PlaylistView : public View {
|
|||||||
Text text_sample_rate{
|
Text text_sample_rate{
|
||||||
{10 * 8, 1 * 16, 7 * 8, 16}};
|
{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{
|
ProgressBar progressbar_track{
|
||||||
{18 * 8, 1 * 16, 12 * 8, 8}};
|
{18 * 8, 1 * 16, 12 * 8, 8 + 1}};
|
||||||
|
|
||||||
ProgressBar progressbar_transmit{
|
ProgressBar progressbar_transmit{
|
||||||
{18 * 8, 3 * 8, 12 * 8, 8}};
|
{18 * 8, 3 * 8 - 1, 12 * 8, 8}};
|
||||||
|
|
||||||
Text text_duration{
|
Text text_duration{
|
||||||
{0 * 8, 2 * 16, 5 * 8, 16}};
|
{0 * 8, 2 * 16, 5 * 8, 16}};
|
||||||
|
@ -37,9 +37,13 @@ AlphanumView::AlphanumView(
|
|||||||
: TextEntryView(nav, str, max_length) {
|
: TextEntryView(nav, str, max_length) {
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
add_children({&button_mode,
|
add_children({
|
||||||
&text_raw,
|
&labels,
|
||||||
&field_raw});
|
&field_raw,
|
||||||
|
&text_raw_to_char,
|
||||||
|
&button_delete,
|
||||||
|
&button_mode,
|
||||||
|
});
|
||||||
|
|
||||||
const auto button_fn = [this](Button& button) {
|
const auto button_fn = [this](Button& button) {
|
||||||
this->on_button(button);
|
this->on_button(button);
|
||||||
@ -65,10 +69,19 @@ AlphanumView::AlphanumView(
|
|||||||
set_mode(mode + 1);
|
set_mode(mode + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
button_delete.on_select = [this](Button&) {
|
||||||
|
char_delete();
|
||||||
|
};
|
||||||
|
|
||||||
field_raw.set_value('0');
|
field_raw.set_value('0');
|
||||||
field_raw.on_select = [this](NumberField&) {
|
field_raw.on_select = [this](NumberField&) {
|
||||||
char_add(field_raw.value());
|
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) {
|
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) {
|
void AlphanumView::on_button(Button& button) {
|
||||||
const auto c = button.text()[0];
|
const auto c = button.text()[0];
|
||||||
|
|
||||||
if (c == '<')
|
|
||||||
char_delete();
|
|
||||||
else
|
|
||||||
char_add(c);
|
char_add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ class AlphanumView : public TextEntryView {
|
|||||||
bool on_encoder(const EncoderEvent delta) override;
|
bool on_encoder(const EncoderEvent delta) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, .<";
|
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, ._";
|
||||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, .<";
|
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, ._";
|
||||||
const char* const keys_digit = "0123456789!\"#'()*+-/:;=>?@[\\]<";
|
const char* const keys_digit = "0123456789!\"#'()*+-/:;=<>@[\\]?";
|
||||||
|
|
||||||
const std::pair<std::string, const char*> key_sets[3] = {
|
const std::pair<std::string, const char*> key_sets[3] = {
|
||||||
{"Upper", keys_upper},
|
{"ABC", keys_upper},
|
||||||
{"Lower", keys_lower},
|
{"abc", keys_lower},
|
||||||
{"Digit", keys_digit}};
|
{"123", keys_digit}};
|
||||||
|
|
||||||
int16_t focused_button = 0;
|
int16_t focused_button = 0;
|
||||||
uint32_t mode = 0; // Uppercase
|
uint32_t mode = 0; // Uppercase
|
||||||
@ -60,13 +60,10 @@ class AlphanumView : public TextEntryView {
|
|||||||
|
|
||||||
std::array<Button, 30> buttons{};
|
std::array<Button, 30> buttons{};
|
||||||
|
|
||||||
Button button_mode{
|
Labels labels{
|
||||||
{21 * 8, 33 * 8, 8 * 8, 32},
|
{{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{
|
NumberField field_raw{
|
||||||
{5 * 8, 33 * 8},
|
{5 * 8, 33 * 8},
|
||||||
3,
|
3,
|
||||||
@ -74,9 +71,17 @@ class AlphanumView : public TextEntryView {
|
|||||||
1,
|
1,
|
||||||
'0'};
|
'0'};
|
||||||
|
|
||||||
Button button_ok{
|
Text text_raw_to_char{
|
||||||
{10 * 8, 33 * 8, 9 * 8, 32},
|
{5 * 8, 35 * 8, 4 * 8, 16},
|
||||||
"OK"};
|
"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 */
|
} /* namespace ui */
|
||||||
|
@ -50,7 +50,7 @@ class TextEntryView : public View {
|
|||||||
|
|
||||||
TextField text_input;
|
TextField text_input;
|
||||||
Button button_ok{
|
Button button_ok{
|
||||||
{10 * 8, 33 * 8, 9 * 8, 32},
|
{22 * 8, 33 * 8, 7 * 8, 32},
|
||||||
"OK"};
|
"OK"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user