| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <QEvent> |
| 7 |
#include <QWidget> |
| 8 |
|
| 9 |
class QMouseEvent; |
| 10 |
class QTimer; |
| 11 |
|
| 12 |
class RenderWidget final : public QWidget |
| 13 |
{ |
| 14 |
Q_OBJECT |
| 15 |
|
| 16 |
public: |
| 17 |
explicit RenderWidget(QWidget* parent = nullptr); |
| 18 |
|
| 19 |
bool event(QEvent* event) override; |
| 20 |
void showFullScreen(); |
| 21 |
QPaintEngine* paintEngine() const override; |
| 22 |
bool IsCursorLocked() const { return m_cursor_locked; } |
| 23 |
void SetCursorLockedOnNextActivation(bool locked = true); |
| 24 |
void SetWaitingForMessageBox(bool waiting_for_message_box); |
| 25 |
void SetCursorLocked(bool locked, bool follow_aspect_ratio = true); |
| 26 |
|
| 27 |
signals: |
| 28 |
void EscapePressed(); |
| 29 |
void Closed(); |
| 30 |
void HandleChanged(void* handle); |
| 31 |
void StateChanged(bool fullscreen); |
| 32 |
void SizeChanged(int new_width, int new_height); |
| 33 |
void FocusChanged(bool focus); |
| 34 |
|
| 35 |
private: |
| 36 |
void HandleCursorTimer(); |
| 37 |
void OnHandleChanged(void* handle); |
| 38 |
void OnHideCursorChanged(); |
| 39 |
void OnNeverHideCursorChanged(); |
| 40 |
void OnLockCursorChanged(); |
| 41 |
void OnKeepOnTopChanged(bool top); |
| 42 |
void UpdateCursor(); |
| 43 |
void PassEventToPresenter(const QEvent* event); |
| 44 |
void SetPresenterKeyMap(); |
| 45 |
void dragEnterEvent(QDragEnterEvent* event) override; |
| 46 |
void dropEvent(QDropEvent* event) override; |
| 47 |
|
| 48 |
static constexpr int MOUSE_HIDE_DELAY = 3000; |
| 49 |
QTimer* m_mouse_timer; |
| 50 |
QPoint m_last_mouse{}; |
| 51 |
int m_last_window_width = 0; |
| 52 |
int m_last_window_height = 0; |
| 53 |
float m_last_window_scale = 0; |
| 54 |
bool m_cursor_locked = false; |
| 55 |
bool m_lock_cursor_on_next_activation = false; |
| 56 |
bool m_dont_lock_cursor_on_show = false; |
| 57 |
bool m_waiting_for_message_box = false; |
| 58 |
bool m_should_unpause_on_focus = false; |
| 59 |
}; |