MyGUI 3.4.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 {
29
30 public:
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 bool injectKeyPress(KeyCode _key, Char _text = 0);
56 bool injectKeyRelease(KeyCode _key);
57
59 bool isFocusMouse() const;
61 bool isFocusKey() const;
63 bool isCaptureMouse() const;
64
66 void setKeyFocusWidget(Widget* _widget);
68 void resetKeyFocusWidget(Widget* _widget);
71
76
81
83 const IntPoint& getMousePosition() const;
84
89
90 // работа с модальными окнами
92 void addWidgetModal(Widget* _widget);
94 void removeWidgetModal(Widget* _widget);
95
97 bool isModalAny() const;
98
100 bool isControlPressed() const;
102 bool isShiftPressed() const;
104 bool isAltPressed() const;
106 bool isMetaPressed() const;
107
113
115 void unlinkWidget(Widget* _widget);
116
122
128
129 /*internal:*/
131
132 private:
133 // удаляем данный виджет из всех возможных мест
134 void _unlinkWidget(Widget* _widget) override;
135
136 void frameEntered(float _frame);
137
138 void firstEncoding(KeyCode _key, bool bIsKeyPressed);
139
140 // запоминает клавишу для поддержки повторения
141 void storeKey(KeyCode _key, Char _text);
142
143 // сбрасывает клавишу повторения
144 void resetKey();
145
146 private:
147 // виджеты которым принадлежит фокус
148 Widget* mWidgetMouseFocus{nullptr};
149 Widget* mWidgetKeyFocus{nullptr};
150 ILayer* mLayerMouseFocus{nullptr};
151
152 //used for double click timing
153 float mTimerDoubleClick; // time since the last click
154
155 // нажат ли шифт
156 bool mIsShiftPressed{false};
157 // нажат ли контрол
158 bool mIsControlPressed{false};
159 bool mIsAltPressed{false};
160 bool mIsMetaPressed{false};
161
162 IntPoint mMousePosition;
163
164 // last mouse press position (in Layer coordinates).
165 IntPoint mLastPressed[MouseButton::MAX];
166
167 // is mouse button captured by active widget
168 bool mMouseCapture[MouseButton::MAX];
169
170 // клавиша для повтора
171 KeyCode mHoldKey{KeyCode::None};
172 Char mHoldChar{0};
173 bool mFirstPressKey{false};
174 float mTimerKey{0.0f};
175 int mOldAbsZ{0};
176
177 // список виджетов с модальным режимом
178 VectorWidgetPtr mVectorModalRootWidget;
179
180 bool mIsInitialise{false};
181 };
182
183} // namespace MyGUI
184
185#endif // MYGUI_INPUT_MANAGER_H_
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
const IntPoint & getLastPressedPosition(MouseButton _id) const
void unlinkWidget(Widget *_widget)
bool injectMousePress(int _absx, int _absy, MouseButton _id)
InputManager(const InputManager &)=delete
bool injectMouseMove(int _absx, int _absy, int _absz)
const IntPoint & getMousePosition() const
Widget * getKeyFocusWidget() const
void setKeyFocusWidget(Widget *_widget)
void resetKeyFocusWidget(Widget *_widget)
delegates::MultiDelegate< Widget * > eventChangeMouseFocus
Widget * getMouseFocusWidget() const
delegates::MultiDelegate< Widget * > eventChangeKeyFocus
bool injectMouseRelease(int _absx, int _absy, MouseButton _id)
bool injectKeyPress(KeyCode _key, Char _text=0)
bool injectKeyRelease(KeyCode _key)
void addWidgetModal(Widget *_widget)
void removeWidgetModal(Widget *_widget)
IntPoint getMousePositionByLayer() const
widget description should be here.
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
unsigned int Char
Definition MyGUI_Types.h:50
std::vector< Widget * > VectorWidgetPtr