mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-25 07:10:43 -04:00
Accessibility over serial (#1717)
* Initial accessibility support * added it to some widgets to test * More widget accessibility response * More widgets, better output * Mark selected widget on list * typo
This commit is contained in:
parent
eedebe1c52
commit
1a69ce2d97
7 changed files with 275 additions and 0 deletions
|
@ -106,6 +106,9 @@ class Widget {
|
|||
|
||||
virtual Context& context() const;
|
||||
|
||||
virtual void getAccessibilityText(std::string& result);
|
||||
virtual void getWidgetName(std::string& result);
|
||||
|
||||
void set_style(const Style* new_style);
|
||||
|
||||
const Style& style() const;
|
||||
|
@ -207,6 +210,8 @@ class Text : public Widget {
|
|||
void set(std::string_view value);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
protected:
|
||||
// NB: Don't truncate this string. The UI will only render
|
||||
|
@ -234,6 +239,8 @@ class Labels : public Widget {
|
|||
void set_labels(std::initializer_list<Label> labels);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
std::vector<Label> labels_;
|
||||
|
@ -312,6 +319,8 @@ class ProgressBar : public Widget {
|
|||
void set_value(const uint32_t value);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
uint32_t _value = 0;
|
||||
|
@ -345,6 +354,8 @@ class Console : public Widget {
|
|||
void enable_scrolling(bool enable);
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
Point pos{0, 0};
|
||||
|
@ -385,6 +396,8 @@ class Checkbox : public Widget {
|
|||
bool on_key(const KeyEvent key) override;
|
||||
bool on_keyboard(const KeyboardEvent key) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
|
@ -421,6 +434,8 @@ class Button : public Widget {
|
|||
bool on_key(const KeyEvent key) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
|
@ -461,6 +476,9 @@ class ButtonWithEncoder : public Widget {
|
|||
bool on_encoder(const EncoderEvent delta) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
int32_t encoder_delta = 0;
|
||||
|
@ -496,6 +514,9 @@ class NewButton : public Widget {
|
|||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
protected:
|
||||
|
@ -550,6 +571,8 @@ class ImageButton : public Image {
|
|||
bool on_key(const KeyEvent key) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
};
|
||||
|
||||
/* A button that toggles between two images when set. */
|
||||
|
@ -583,6 +606,9 @@ class ImageToggle : public ImageButton {
|
|||
bool value() const;
|
||||
void set_value(bool b);
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
// Hide this field.
|
||||
using ImageButton::on_select;
|
||||
|
@ -628,6 +654,8 @@ class ImageOptionsField : public Widget {
|
|||
bool on_encoder(const EncoderEvent delta) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
options_t options;
|
||||
|
@ -667,6 +695,9 @@ class OptionsField : public Widget {
|
|||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
const size_t length_;
|
||||
options_t options_;
|
||||
|
@ -712,6 +743,9 @@ class TextEdit : public Widget {
|
|||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
void on_focus() override;
|
||||
void on_blur() override;
|
||||
|
||||
|
@ -738,6 +772,9 @@ class TextField : public Text {
|
|||
bool on_encoder(EncoderEvent delta) override;
|
||||
bool on_touch(TouchEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
using Text::set;
|
||||
};
|
||||
|
@ -774,6 +811,9 @@ class NumberField : public Widget {
|
|||
bool on_touch(const TouchEvent event) override;
|
||||
bool on_keyboard(const KeyboardEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
range_t range;
|
||||
int32_t step;
|
||||
|
@ -849,6 +889,9 @@ class SymField : public Widget {
|
|||
bool on_encoder(EncoderEvent delta) override;
|
||||
bool on_touch(TouchEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
/* Ensure the specified symbol is in the symbol list. */
|
||||
char ensure_valid(char symbol) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue