mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-23 00:19:31 -04:00
* EGD-3229 [FIX] UTF8 fixed uint32_t range error * EGD-3229 [util] gui::Item Navigation switch case moved to function Needed to not copy senslessly NavigationDirection enum switch case * gui::Item Navigation switch case moved to function * added NavigationDirection::None enum value * cleaned up Navigation.hpp/cpp * EGD-3229 [util] gui: InputEvent - str() for logging added & is...() check methods * EGD-3229 [util] removed notorious log on unknown glyph * EGD-3229 [util] InputMode - added is(Mode) method, input Profile added default definition * is() method addded to check instead of `==` comparison * added default to Profile instead of `== 0` use * [FIX] ARM GCC 10.1.0 - build fixed fixed include in wrong place * PR style fix * Review applied
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <list>
|
|
#include <utf8/UTF8.hpp>
|
|
|
|
// TODO read from keymap file ...
|
|
namespace gui
|
|
{
|
|
inline const std::vector<char> special_chars = {'.', ',', '_', ':', ';', ')', '(', '?', '!', '/', '*', '+'};
|
|
}
|
|
|
|
/// this element has one goal - nicely change input parsing which is done in application in it's widgets
|
|
class InputMode
|
|
{
|
|
public:
|
|
/// ! when adding modes please update next method and input_mode (in cpp file)
|
|
enum Mode
|
|
{
|
|
digit,
|
|
abc,
|
|
ABC,
|
|
phone,
|
|
};
|
|
|
|
private:
|
|
InputMode() = delete;
|
|
// list of enabled input modes
|
|
std::list<Mode> input_mode_list = {};
|
|
uint32_t input_mode_list_pos = 0;
|
|
std::function<void(const UTF8 &text)> show_type_cb = nullptr;
|
|
std::function<void()> restore_after_show_type_cb = nullptr;
|
|
std::function<void()> show_special_char_selector = nullptr;
|
|
Mode modeNow() const;
|
|
|
|
void show_input_type();
|
|
|
|
public:
|
|
void show_restore();
|
|
InputMode(std::list<InputMode::Mode> mode_list,
|
|
std::function<void(const UTF8 &text)> show_type_cb = nullptr,
|
|
std::function<void()> restore_after_show_type_cb = nullptr,
|
|
std::function<void()> show_special_char_selector = nullptr);
|
|
void on_focus(bool focus)
|
|
{
|
|
if (!focus)
|
|
show_restore();
|
|
}
|
|
void next();
|
|
const std::string &get();
|
|
void select_special_char();
|
|
[[nodiscard]] bool is(Mode mode) const
|
|
{
|
|
return mode == modeNow();
|
|
}
|
|
};
|