Files
MuditaOS/module-gui/gui/widgets/InputMode.hpp
T
Alek-Mudita 8585ea8cf4 Call app - contact recognition (#169)
* [EGD-2569] added # and * as numeric inputs

* [EGD-2569] added '+' input sign

* [EGD-2569] created defines with window names for call app

* [EGD-2547] contact recognition during call

* [EGD-2547] moved UiCommon

* [fix][EGD-2547] fix for setting empty UTF string to text gui field

* [EGD-2547] adding new contact from call enter window

* [EGD-2547] minor clean up and added param validation

* [EGD-2547] easier method to add contact

* [EGD-2569] added new keyboard profile (numeric with special signs)
Desktop is passing it properly to Call app.

* [EGD-2569] added transaltor to enternumberwindow

* [EGD-2569] reverted unnecessary changes

[EGD-2569] revert

[EGD-2569] revert of not needed changes

* [EGD-2569] fix in phone.kprof

* [EGD-2547] unified API to call and send sms

* [EGD-2547]  changed default to true

* [EGD-2547] minor clean up.

* [EGD-2569] revert changes in PinLockWindow.cpp

* [EGD-2569][fix] eneter as null char

* [EGD-2547] PR fixes

[EGD-2547] code review fixes / refactored UiCommon

[EGD-2547] more code review fixes

[EGD-2547] rem not needed cast

* [EGD-2547] PR fixes

* [EGD-2547] splitting of UiCommon

* [EGD-2547] typo fix

* [EGD-2547] revereted one line conversion from char to string.
2020-02-28 09:37:25 +01:00

54 lines
1.4 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 widget has one goal - nicelly 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()> show_special_char_selector = nullptr;
Mode modeNow();
// text to restore when show_input_type was called (and overwritten some other text)
UTF8 restore_text = "";
void show_input_type();
void show_restore();
public:
InputMode(std::list<InputMode::Mode> mode_list, std::function<void(const UTF8 &text)> show_type_cb = nullptr,
std::function<void()> show_special_char_selector = nullptr, const UTF8 &prev_text = "");
void on_focus(bool focus)
{
if (focus)
show_input_type();
else
show_restore();
}
void next();
const std::string &get();
void select_special_char();
};