mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-10 00:29:33 +00:00
Merge remote-tracking branch 'upstream/master'
Base class for text entry
This commit is contained in:
@@ -25,12 +25,44 @@
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_handwrite.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
void text_entry(NavigationView& nav, std::string * str, size_t max_length, const std::function<void(std::string*)> on_done = nullptr);
|
||||
class TextEntryView : public View {
|
||||
public:
|
||||
std::function<void(std::string*)> on_changed { };
|
||||
|
||||
void focus() override;
|
||||
std::string title() const override { return "Text entry"; };
|
||||
|
||||
protected:
|
||||
TextEntryView(NavigationView& nav, std::string * str, size_t max_length);
|
||||
|
||||
TextEntryView(const TextEntryView&) = delete;
|
||||
TextEntryView(TextEntryView&&) = delete;
|
||||
TextEntryView& operator=(const TextEntryView&) = delete;
|
||||
TextEntryView& operator=(TextEntryView&&) = delete;
|
||||
|
||||
void char_add(const char c);
|
||||
void char_delete();
|
||||
void draw_cursor();
|
||||
void update_text();
|
||||
|
||||
std::string * _str;
|
||||
size_t _max_length;
|
||||
uint32_t _cursor_pos { 0 };
|
||||
|
||||
Text text_input {
|
||||
{ 0, 0, 240, 16 }
|
||||
};
|
||||
|
||||
Button button_ok {
|
||||
{ 10 * 8, 33 * 8, 9 * 8, 32 },
|
||||
"OK"
|
||||
};
|
||||
};
|
||||
|
||||
void text_prompt(NavigationView& nav, std::string * str, size_t max_length, const std::function<void(std::string*)> on_done = nullptr);
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user