MyGUI 3.5.3
MyGUI_InputManager.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_INPUT_MANAGER_H_
8#define MYGUI_INPUT_MANAGER_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Macros.h"
12#include "MyGUI_Singleton.h"
13#include "MyGUI_WidgetDefines.h"
14#include "MyGUI_IUnlinkWidget.h"
15#include "MyGUI_XmlDocument.h"
16#include "MyGUI_MouseButton.h"
17#include "MyGUI_KeyCode.h"
18#include "MyGUI_Timer.h"
19#include "MyGUI_ILayer.h"
20#include "MyGUI_Delegate.h"
22
23namespace MyGUI
24{
25
26 class MYGUI_EXPORT InputManager : public IUnlinkWidget, public MemberObsolete<InputManager>
27 {
28 MYGUI_SINGLETON_DECLARATION(InputManager);
29
30 public:
31 InputManager();
32
33 void initialise();
34 void shutdown();
35
39 bool injectMouseMove(int _absx, int _absy, int _absz);
43 bool injectMousePress(int _absx, int _absy, MouseButton _id);
47 bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
48
52 void setDoubleClickTime(float _value);
54 float getDoubleClickTime() const;
55
59 bool injectKeyPress(KeyCode _key, Char _text = 0);
63 bool injectKeyRelease(KeyCode _key);
64
66 bool isFocusMouse() const;
68 bool isFocusKey() const;
70 bool isCaptureMouse() const;
71
73 void setKeyFocusWidget(Widget* _widget);
75 void resetKeyFocusWidget(Widget* _widget);
77 void resetKeyFocusWidget();
78
80 Widget* getMouseFocusWidget() const;
82 Widget* getKeyFocusWidget() const;
83
87 const IntPoint& getLastPressedPosition(MouseButton _id) const;
89 IntPoint getLastPressedPositionForWidget(MouseButton _id, const Widget* _widget) const;
90
92 const IntPoint& getMousePosition() const;
93
97 IntPoint getMousePositionByLayer() const;
99 IntPoint getMousePositionForWidget(const Widget* _widget) const;
100
102 void addWidgetModal(Widget* _widget);
104 void removeWidgetModal(Widget* _widget);
105
107 bool isModalAny() const;
108
110 bool isControlPressed() const;
112 bool isShiftPressed() const;
114 bool isAltPressed() const;
116 bool isMetaPressed() const;
117
122 void resetMouseCaptureWidget();
123
125 void unlinkWidget(Widget* _widget);
126
131 delegates::MultiDelegate<Widget*> eventChangeMouseFocus;
132
137 delegates::MultiDelegate<Widget*> eventChangeKeyFocus;
138
139 /*internal:*/
140 void _resetMouseFocusWidget();
141
142 private:
143 // Remove widget from all tracked places (focus, capture, modal, etc)
144 void _unlinkWidget(Widget* _widget) override;
145
146 void frameEntered(float _frame);
147
148 void firstEncoding(KeyCode _key, bool bIsKeyPressed);
149
150 // Store key for repeat support
151 void storeKey(KeyCode _key, Char _text);
152
153 void resetKey();
154
155 private:
156 // Widgets that currently have focus
157 Widget* mWidgetMouseFocus{nullptr};
158 Widget* mWidgetKeyFocus{nullptr};
159 ILayer* mLayerMouseFocus{nullptr};
160
161 //used for double click timing
162 float mDoubleClickTime{0.25f};
163 float mTimerDoubleClick; // time since the last click
164
165 bool mIsShiftPressed{false};
166 bool mIsControlPressed{false};
167 bool mIsAltPressed{false};
168 bool mIsMetaPressed{false};
169
170 IntPoint mMousePosition;
171
172 // last mouse press position (in Layer coordinates).
173 IntPoint mLastPressed[MouseButton::MAX];
174
175 // is mouse button captured by active widget
176 bool mMouseCapture[MouseButton::MAX];
177
178 // Key repeat state
179 KeyCode mHoldKey{KeyCode::None};
180 Char mHoldChar{0};
181 bool mFirstPressKey{false};
182 float mTimerKey{0.0f};
183 int mOldAbsZ{0};
184
185 // Modal widgets stack
186 VectorWidgetPtr mVectorModalRootWidget;
187
188 bool mIsInitialise{false};
189 };
190
191} // namespace MyGUI
192
193#endif // MYGUI_INPUT_MANAGER_H_
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:26
unsigned int Char
Definition MyGUI_Types.h:49
std::vector< Widget * > VectorWidgetPtr