// SPDX-License-Identifier: MIT // // ES-DE Frontend // GuiTextEditKeyboardPopup.h // // Text edit popup with a virtual keyboard. // Has a default mode and a complex mode, both with various options passed as arguments. // #ifndef ES_CORE_GUIS_GUI_TEXT_EDIT_KEYBOARD_POPUP_H #define ES_CORE_GUIS_GUI_TEXT_EDIT_KEYBOARD_POPUP_H #include "GuiComponent.h" #include "components/ButtonComponent.h" #include "components/ComponentGrid.h" #include "components/TextComponent.h" #include "components/TextEditComponent.h" #include "utils/LocalizationUtil.h" class GuiTextEditKeyboardPopup : public GuiComponent { public: GuiTextEditKeyboardPopup(const HelpStyle& helpstyle, const float verticalPosition, const std::string& title, const std::string& initValue, const std::function& okCallback, bool multiLine, const std::string& acceptBtnHelpText = _("OK"), const std::string& saveConfirmationText = _("SAVE CHANGES?"), const std::string& infoString = "", const std::string& defaultValue = "", const std::string& loadBtnHelpText = _("LOAD DEFAULT"), const std::string& clearBtnHelpText = _("CLEAR"), const std::string& cancelBtnHelpText = _("DISCARD CHANGES")); void onSizeChanged() override; bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; std::vector getHelpPrompts() override; HelpStyle getHelpStyle() override { return mHelpStyle; } private: class KeyboardButton { public: std::shared_ptr button; const std::string key; const std::string shiftedKey; const std::string altedKey; const std::string altshiftedKey; KeyboardButton(const std::shared_ptr b, const std::string& k, const std::string& sk, const std::string& ak, const std::string& ask) : button {b} , key {k} , shiftedKey {sk} , altedKey {ak} , altshiftedKey {ask} {}; }; void updateDeleteRepeat(int deltaTime); void updateNavigationRepeat(int deltaTime); void shiftKeys(); void altKeys(); void altShiftKeys(); std::shared_ptr makeButton(const std::string& key, const std::string& shiftedKey, const std::string& altedKey, const std::string& altshiftedKey); std::vector mKeyboardButtons; std::shared_ptr mShiftButton; std::shared_ptr mAltButton; Renderer* mRenderer; NinePatchComponent mBackground; ComponentGrid mGrid; HelpStyle mHelpStyle; std::shared_ptr mTitle; std::shared_ptr mInfoString; std::shared_ptr mDefaultValue; std::shared_ptr mText; std::shared_ptr mKeyboardGrid; std::string mInitValue; std::string mAcceptBtnHelpText; std::string mSaveConfirmationText; std::string mLoadBtnHelpText; std::string mClearBtnHelpText; std::string mCancelBtnHelpText; std::function mOkCallback; bool mMultiLine; bool mComplexMode; bool mDeleteRepeat; bool mShift; bool mAlt; float mVerticalPosition; int mHorizontalKeyCount; int mDeleteRepeatTimer; int mNavigationRepeatTimer; int mNavigationRepeatDirX; int mNavigationRepeatDirY; }; #endif // ES_CORE_GUIS_GUI_TEXT_EDIT_KEYBOARD_POPUP_H