From 9195096bcbe1e382c56cc2d105f57b5c395dd962 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Thu, 13 Jun 2013 08:59:07 +0000 Subject: [PATCH] keyboard --- include/GUIManager/GUIManager.h | 5 +++++ src/GUIManager/ButtonWidget.cpp | 3 +++ src/GUIManager/GUIManager.cpp | 21 +++++++++++++++++++++ src/GUIManager/KeyboardWidget.cpp | 19 ++++++------------- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/include/GUIManager/GUIManager.h b/include/GUIManager/GUIManager.h index 2ce4a3c..ee076cd 100644 --- a/include/GUIManager/GUIManager.h +++ b/include/GUIManager/GUIManager.h @@ -138,6 +138,7 @@ protected: boost::mutex WidgetListMutex; + bool KeyboardIsOnScreen; public: boost::signal KeyPressedSignal; @@ -169,6 +170,10 @@ public: void OnMove(vec2 shift); + void ShowKeyboard(); + void HideKeyboard(); + + void PrintWidgetList(); std::shared_ptr> GetOnClickSignal(const std::string& widgetName); diff --git a/src/GUIManager/ButtonWidget.cpp b/src/GUIManager/ButtonWidget.cpp index 8974eaf..a168f78 100644 --- a/src/GUIManager/ButtonWidget.cpp +++ b/src/GUIManager/ButtonWidget.cpp @@ -640,7 +640,10 @@ void TEdit::OnTapDown(vec2 pos) { ResourceManager->GUIManager.KeyPressedSignal.disconnect_all_slots(); InputConnection = ResourceManager->GUIManager.KeyPressedSignal.connect(boost::bind(&TEdit::OnKeyPress, this, _1)); + } + + ResourceManager->GUIManager.ShowKeyboard(); } void TEdit::OnKeyPress(int key) diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp index 88919b3..f46d518 100644 --- a/src/GUIManager/GUIManager.cpp +++ b/src/GUIManager/GUIManager.cpp @@ -10,6 +10,7 @@ const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag"; TGUIManager::TGUIManager() + : KeyboardIsOnScreen(false) { } @@ -369,6 +370,26 @@ void TGUIManager::OnMove(vec2 shift) } } + +void TGUIManager::ShowKeyboard() +{ + if (!KeyboardIsOnScreen) + { + MoveWidget("Keyboard", vec2(0, 216)); + KeyboardIsOnScreen = true; + } +} + + +void TGUIManager::HideKeyboard() +{ + if (KeyboardIsOnScreen) + { + MoveWidget("Keyboard", vec2(0, -216)); + KeyboardIsOnScreen = false; + } +} + void TGUIManager::PrintWidgetList() { TWidgetArr::iterator i; diff --git a/src/GUIManager/KeyboardWidget.cpp b/src/GUIManager/KeyboardWidget.cpp index 2895eac..5114006 100644 --- a/src/GUIManager/KeyboardWidget.cpp +++ b/src/GUIManager/KeyboardWidget.cpp @@ -4,19 +4,6 @@ namespace SE { - /* -struct TKeyboardWidget : public TInstancingWidgetAncestor -{ - - - TKeyboardWidget(); - - virtual bool CheckClick(vec2 mousePos); - virtual void OnTapDown(vec2 pos); - virtual void OnTapUp(vec2 pos); - -};*/ - TKeyboardWidget::TKeyboardWidget() : Shifted(false) { @@ -160,6 +147,12 @@ struct TKeyboardWidget : public TInstancingWidgetAncestor ResourceManager->GUIManager.KeyPressedSignal(std::get<1>(visualKeyElement)); } } + + if (pos.v[0] >= 280 - 74/2 && pos.v[0] <= 280 + 74/2 && + pos.v[1] >= 23 - 38/2 && pos.v[1] <= 23 + 38/2) + { + ResourceManager->GUIManager.HideKeyboard(); + } }