MyGUI: MyGUI_InputManager.h Source File

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"
21#include "MyGUI_BackwardCompatibility.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 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);
70 void resetKeyFocusWidget();
71
73 Widget* getMouseFocusWidget() const;
75 Widget* getKeyFocusWidget() const;
76
80 const IntPoint& getLastPressedPosition(MouseButton _id) const;
81
83 const IntPoint& getMousePosition() const;
84
88 IntPoint getMousePositionByLayer() const;
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
112 void resetMouseCaptureWidget();
113
115 void unlinkWidget(Widget* _widget);
116
121 delegates::MultiDelegate<Widget*> eventChangeMouseFocus;
122
127 delegates::MultiDelegate<Widget*> eventChangeKeyFocus;
128
129 /*internal:*/
130 void _resetMouseFocusWidget();
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_
MyGUI_BackwardCompatibility.h
MyGUI_Delegate.h
MyGUI_ILayer.h
MyGUI_IUnlinkWidget.h
MyGUI_KeyCode.h
MyGUI_Macros.h
MyGUI_MouseButton.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_Singleton.h
MYGUI_SINGLETON_DECLARATION
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Definition MyGUI_Singleton.h:112
MyGUI_Timer.h
MyGUI_WidgetDefines.h
MyGUI_XmlDocument.h
MyGUI::IUnlinkWidget
Definition MyGUI_IUnlinkWidget.h:17
MyGUI::InputManager::isAltPressed
bool isAltPressed() const
Definition MyGUI_InputManager.cpp:677
MyGUI::InputManager::getLastPressedPosition
const IntPoint & getLastPressedPosition(MouseButton _id) const
Definition MyGUI_InputManager.cpp:648
MyGUI::InputManager::unlinkWidget
void unlinkWidget(Widget *_widget)
Definition MyGUI_InputManager.cpp:695
MyGUI::InputManager::isShiftPressed
bool isShiftPressed() const
Definition MyGUI_InputManager.cpp:672
MyGUI::InputManager::injectMousePress
bool injectMousePress(int _absx, int _absy, MouseButton _id)
Definition MyGUI_InputManager.cpp:212
MyGUI::InputManager::InputManager
InputManager(const InputManager &)=delete
MyGUI::InputManager::injectMouseMove
bool injectMouseMove(int _absx, int _absy, int _absz)
Definition MyGUI_InputManager.cpp:73
MyGUI::InputManager::isFocusMouse
bool isFocusMouse() const
Definition MyGUI_InputManager.cpp:613
MyGUI::InputManager::getMousePosition
const IntPoint & getMousePosition() const
Definition MyGUI_InputManager.cpp:657
MyGUI::InputManager::getKeyFocusWidget
Widget * getKeyFocusWidget() const
Definition MyGUI_InputManager.cpp:643
MyGUI::InputManager::initialise
void initialise()
Definition MyGUI_InputManager.cpp:31
MyGUI::InputManager::setKeyFocusWidget
void setKeyFocusWidget(Widget *_widget)
Definition MyGUI_InputManager.cpp:388
MyGUI::InputManager::shutdown
void shutdown()
Definition MyGUI_InputManager.cpp:61
MyGUI::InputManager::isMetaPressed
bool isMetaPressed() const
Definition MyGUI_InputManager.cpp:682
MyGUI::InputManager::isControlPressed
bool isControlPressed() const
Definition MyGUI_InputManager.cpp:667
MyGUI::InputManager::resetKeyFocusWidget
void resetKeyFocusWidget(Widget *_widget)
Definition MyGUI_InputManager.cpp:600
MyGUI::InputManager::eventChangeMouseFocus
delegates::MultiDelegate< Widget * > eventChangeMouseFocus
Definition MyGUI_InputManager.h:121
MyGUI::InputManager::isCaptureMouse
bool isCaptureMouse() const
Definition MyGUI_InputManager.cpp:623
MyGUI::InputManager::_resetMouseFocusWidget
void _resetMouseFocusWidget()
Definition MyGUI_InputManager.cpp:441
MyGUI::InputManager::getMouseFocusWidget
Widget * getMouseFocusWidget() const
Definition MyGUI_InputManager.cpp:638
MyGUI::InputManager::resetMouseCaptureWidget
void resetMouseCaptureWidget()
Definition MyGUI_InputManager.cpp:687
MyGUI::InputManager::isModalAny
bool isModalAny() const
Definition MyGUI_InputManager.cpp:662
MyGUI::InputManager::eventChangeKeyFocus
delegates::MultiDelegate< Widget * > eventChangeKeyFocus
Definition MyGUI_InputManager.h:127
MyGUI::InputManager::injectMouseRelease
bool injectMouseRelease(int _absx, int _absy, MouseButton _id)
Definition MyGUI_InputManager.cpp:285
MyGUI::InputManager::isFocusKey
bool isFocusKey() const
Definition MyGUI_InputManager.cpp:618
MyGUI::InputManager::injectKeyPress
bool injectKeyPress(KeyCode _key, Char _text=0)
Definition MyGUI_InputManager.cpp:341
MyGUI::InputManager::injectKeyRelease
bool injectKeyRelease(KeyCode _key)
Definition MyGUI_InputManager.cpp:360
MyGUI::InputManager::addWidgetModal
void addWidgetModal(Widget *_widget)
Definition MyGUI_InputManager.cpp:503
MyGUI::InputManager::removeWidgetModal
void removeWidgetModal(Widget *_widget)
Definition MyGUI_InputManager.cpp:517
MyGUI::InputManager::getMousePositionByLayer
IntPoint getMousePositionByLayer() const
Definition MyGUI_InputManager.cpp:606
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
MyGUI::Char
unsigned int Char
Definition MyGUI_Types.h:50
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::KeyCode
Definition MyGUI_KeyCode.h:16
MyGUI::MouseButton
Definition MyGUI_MouseButton.h:16