Plasma Engine  2.0
Loading...
Searching...
No Matches
EditorInputContext.h
1#pragma once
2
3#include <EditorFramework/EditorFrameworkDLL.h>
4#include <Foundation/Math/Rect.h>
5#include <Foundation/Reflection/Reflection.h>
6
7class QWidget;
8class QKeyEvent;
9class QMouseEvent;
10class QWheelEvent;
11class plDocument;
14
15enum class plEditorInput
16{
17 MayBeHandledByOthers,
18 WasExclusivelyHandled,
19};
20
21class PL_EDITORFRAMEWORK_DLL plEditorInputContext : public plReflectedClass
22{
23 PL_ADD_DYNAMIC_REFLECTION(plEditorInputContext, plReflectedClass);
24
25public:
27
28 virtual ~plEditorInputContext();
29
30 void FocusLost(bool bCancel);
31
32 plEditorInput KeyPressEvent(QKeyEvent* e) { return DoKeyPressEvent(e); }
33 plEditorInput KeyReleaseEvent(QKeyEvent* e) { return DoKeyReleaseEvent(e); }
34 plEditorInput MousePressEvent(QMouseEvent* e) { return DoMousePressEvent(e); }
35 plEditorInput MouseReleaseEvent(QMouseEvent* e) { return DoMouseReleaseEvent(e); }
36 plEditorInput MouseMoveEvent(QMouseEvent* e);
37 plEditorInput WheelEvent(QWheelEvent* e) { return DoWheelEvent(e); }
38
39 static void SetActiveInputContext(plEditorInputContext* pContext) { s_pActiveInputContext = pContext; }
40
41 void MakeActiveInputContext(bool bActive = true);
42
43 static bool IsAnyInputContextActive() { return s_pActiveInputContext != nullptr; }
44
45 static plEditorInputContext* GetActiveInputContext() { return s_pActiveInputContext; }
46
47 static void UpdateActiveInputContext();
48
49 bool IsActiveInputContext() const;
50
51 void SetOwner(plQtEngineDocumentWindow* pOwnerWindow, plQtEngineViewWidget* pOwnerView);
52
53 plQtEngineDocumentWindow* GetOwnerWindow() const;
54
55 plQtEngineViewWidget* GetOwnerView() const;
56
57 bool GetShortcutsDisabled() const { return m_bDisableShortcuts; }
58
60 void SetShortcutsDisabled(bool bDisabled) { m_bDisableShortcuts = bDisabled; }
61
62 virtual bool IsPickingSelectedAllowed() const { return true; }
63
65 enum class MouseMode
66 {
67 Normal,
68 WrapAtScreenBorders,
69 HideAndWrapAtScreenBorders,
71 };
72
77 plVec2I32 SetMouseMode(MouseMode mode);
78
83 plVec2I32 UpdateMouseMode(QMouseEvent* e);
84
85 virtual void UpdateStatusBarText(plQtEngineDocumentWindow* pWindow) {}
86
87protected:
88 virtual void DoFocusLost(bool bCancel) {}
89
90 virtual void OnSetOwner(plQtEngineDocumentWindow* pOwnerWindow, plQtEngineViewWidget* pOwnerView) = 0;
91
92 virtual plEditorInput DoKeyPressEvent(QKeyEvent* e);
93 virtual plEditorInput DoKeyReleaseEvent(QKeyEvent* e) { return plEditorInput::MayBeHandledByOthers; }
94 virtual plEditorInput DoMousePressEvent(QMouseEvent* e) { return plEditorInput::MayBeHandledByOthers; }
95 virtual plEditorInput DoMouseReleaseEvent(QMouseEvent* e) { return plEditorInput::MayBeHandledByOthers; }
96 virtual plEditorInput DoMouseMoveEvent(QMouseEvent* e) { return plEditorInput::MayBeHandledByOthers; }
97 virtual plEditorInput DoWheelEvent(QWheelEvent* e) { return plEditorInput::MayBeHandledByOthers; }
98
99private:
100 static plEditorInputContext* s_pActiveInputContext;
101
102 plQtEngineDocumentWindow* m_pOwnerWindow;
103 plQtEngineViewWidget* m_pOwnerView;
104 bool m_bDisableShortcuts;
105 bool m_bJustWrappedMouse;
106 MouseMode m_MouseMode;
107 plVec2I32 m_vMouseRestorePosition;
108 plVec2I32 m_vMousePosBeforeWrap;
109 plVec2I32 m_vExpectedMousePosition;
110 plRectU32 m_MouseWrapRect;
111
112 virtual void UpdateContext() {}
113};
Definition Document.h:57
Definition EditorInputContext.h:22
MouseMode
How the mouse position is updated when the mouse cursor reaches the screen borders.
Definition EditorInputContext.h:66
void SetShortcutsDisabled(bool bDisabled)
If set to true, the surrounding window will ensure to block all shortcuts and instead send keypress e...
Definition EditorInputContext.h:60
Base class for all document windows that need a connection to the engine process, and might want to r...
Definition EngineDocumentWindow.moc.h:37
Base class for views that show engine output.
Definition EngineViewWidget.moc.h:34
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86