MyGUI_InputManager.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_INPUT_MANAGER_H_
#define MYGUI_INPUT_MANAGER_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Macros.h"
#include "MyGUI_Singleton.h"
#include "MyGUI_WidgetDefines.h"
#include "MyGUI_IUnlinkWidget.h"
#include "MyGUI_XmlDocument.h"
#include "MyGUI_MouseButton.h"
#include "MyGUI_KeyCode.h"
#include "MyGUI_Timer.h"
#include "MyGUI_ILayer.h"
#include "MyGUI_Delegate.h"
#include "MyGUI_BackwardCompatibility.h"
namespace MyGUI
{
class MYGUI_EXPORT InputManager : public IUnlinkWidget, public MemberObsolete<InputManager>
{
MYGUI_SINGLETON_DECLARATION(InputManager);
public:
InputManager();
void initialise();
void shutdown();
bool injectMouseMove(int _absx, int _absy, int _absz);
bool injectMousePress(int _absx, int _absy, MouseButton _id);
bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
bool injectKeyPress(KeyCode _key, Char _text = 0);
bool injectKeyRelease(KeyCode _key);
bool isFocusMouse() const;
bool isFocusKey() const;
bool isCaptureMouse() const;
void setKeyFocusWidget(Widget* _widget);
void resetKeyFocusWidget(Widget* _widget);
void resetKeyFocusWidget();
Widget* getMouseFocusWidget() const;
Widget* getKeyFocusWidget() const;
const IntPoint& getLastPressedPosition(MouseButton _id) const;
const IntPoint& getMousePosition() const;
IntPoint getMousePositionByLayer() const;
// работа с модальными окнами
void addWidgetModal(Widget* _widget);
void removeWidgetModal(Widget* _widget);
bool isModalAny() const;
bool isControlPressed() const;
bool isShiftPressed() const;
bool isAltPressed() const;
bool isMetaPressed() const;
void resetMouseCaptureWidget();
void unlinkWidget(Widget* _widget);
delegates::MultiDelegate<Widget*> eventChangeMouseFocus;
delegates::MultiDelegate<Widget*> eventChangeKeyFocus;
/*internal:*/
void _resetMouseFocusWidget();
private:
// удаляем данный виджет из всех возможных мест
void _unlinkWidget(Widget* _widget) override;
void frameEntered(float _frame);
void firstEncoding(KeyCode _key, bool bIsKeyPressed);
// запоминает клавишу для поддержки повторения
void storeKey(KeyCode _key, Char _text);
// сбрасывает клавишу повторения
void resetKey();
private:
// виджеты которым принадлежит фокус
Widget* mWidgetMouseFocus{nullptr};
Widget* mWidgetKeyFocus{nullptr};
ILayer* mLayerMouseFocus{nullptr};
//used for double click timing
float mTimerDoubleClick; // time since the last click
// нажат ли шифт
bool mIsShiftPressed{false};
// нажат ли контрол
bool mIsControlPressed{false};
bool mIsAltPressed{false};
bool mIsMetaPressed{false};
IntPoint mMousePosition;
// last mouse press position (in Layer coordinates).
IntPoint mLastPressed[MouseButton::MAX];
// is mouse button captured by active widget
bool mMouseCapture[MouseButton::MAX];
// клавиша для повтора
KeyCode mHoldKey{KeyCode::None};
Char mHoldChar{0};
bool mFirstPressKey{false};
float mTimerKey{0.0f};
int mOldAbsZ{0};
// список виджетов с модальным режимом
VectorWidgetPtr mVectorModalRootWidget;
bool mIsInitialise{false};
};
} // namespace MyGUI
#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