MyGUI  3.0.1
MyGUI_InputManager.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_INPUT_MANAGER_H__
24 #define __MYGUI_INPUT_MANAGER_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Macros.h"
28 #include "MyGUI_Instance.h"
29 #include "MyGUI_WidgetDefines.h"
30 #include "MyGUI_IUnlinkWidget.h"
31 #include "MyGUI_WidgetDefines.h"
32 #include "MyGUI_XmlDocument.h"
33 #include "MyGUI_InputDefine.h"
34 #include "MyGUI_Timer.h"
35 #include "MyGUI_ILayer.h"
36 #include "MyGUI_Delegate.h"
37 
38 namespace MyGUI
39 {
40 
42  {
44 
45  public:
46  void initialise();
47  void shutdown();
48 
52  bool injectMouseMove(int _absx, int _absy, int _absz);
56  bool injectMousePress(int _absx, int _absy, MouseButton _id);
60  bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
61 
65  bool injectKeyPress(KeyCode _key, Char _text = 0);
69  bool injectKeyRelease(KeyCode _key);
70 
72  bool isFocusMouse() { return mWidgetMouseFocus != nullptr; }
74  bool isFocusKey() { return mWidgetKeyFocus != nullptr; }
76  bool isCaptureMouse() { return mIsWidgetMouseCapture; }
77 
79  void setKeyFocusWidget(Widget* _widget);
81  void resetKeyFocusWidget(Widget* _widget);
83  void resetKeyFocusWidget() { setKeyFocusWidget(nullptr); }
84 
86  Widget* getMouseFocusWidget() { return mWidgetMouseFocus; }
88  Widget* getKeyFocusWidget() { return mWidgetKeyFocus; }
90  const IntPoint& getLastLeftPressed() { return mLastLeftPressed; }
92  const IntPoint& getMousePosition() { return mMousePosition; }
93 
94  IntPoint getMousePositionByLayer();
95 
96  // тестовый вариант, очистка фокуса мыши
98  void resetMouseFocusWidget();
99 
100  // работа с модальными окнами
102  void addWidgetModal(Widget* _widget);
104  void removeWidgetModal(Widget* _widget);
105 
107  bool isModalAny() { return !mVectorModalRootWidget.empty(); }
108 
110  bool isControlPressed() { return mIsControlPressed; }
112  bool isShiftPressed() { return mIsShiftPressed; }
113 
117  void resetMouseCaptureWidget() { mIsWidgetMouseCapture = false; }
118 
119  void unlinkWidget(Widget* _widget) { _unlinkWidget(_widget); }
120 
127 
134 
135  private:
136  // удаляем данный виджет из всех возможных мест
137  void _unlinkWidget(Widget* _widget);
138 
139  void frameEntered(float _frame);
140 
141  void firstEncoding(KeyCode _key, bool bIsKeyPressed);
142 
143  // запоминает клавишу для поддержки повторения
144  void storeKey(KeyCode _key, Char _text);
145 
146  // сбрасывает клавишу повторения
147  void resetKey();
148 
149  private:
150  // виджеты которым принадлежит фокус
151  Widget* mWidgetMouseFocus;
152  Widget* mWidgetKeyFocus;
153  ILayer* mLayerMouseFocus;
154  // захватил ли мышь активный виджет
155  bool mIsWidgetMouseCapture;
156  // таймер для двойного клика
157  Timer mTimer; //used for double click timing
158 
159  // нажат ли шифт
160  bool mIsShiftPressed;
161  // нажат ли контрол
162  bool mIsControlPressed;
163  // там где была последний раз нажата левая кнопка
164  IntPoint mLastLeftPressed;
165  IntPoint mMousePosition;
166  // клавиша для повтора
167  KeyCode mHoldKey;
168  Char mHoldChar;
169  bool mFirstPressKey;
170  float mTimerKey;
171  int mOldAbsZ;
172 
173  // список виджетов с модальным режимом
174  VectorWidgetPtr mVectorModalRootWidget;
175 
176  };
177 
178 } // namespace MyGUI
179 
180 #endif // __MYGUI_INPUT_MANAGER_H__