summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/_Win/UI/SceneView.h
blob: 12a58c6a2550e816491b1bc41dd8aa4d5f43daf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/****************************************************************************
**
** Copyright (C) 2002 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//==============================================================================
//	Prefix
//==============================================================================
#ifndef INCLUDED_SCENE_VIEW_H
#define INCLUDED_SCENE_VIEW_H 1

#pragma once

//==============================================================================
//	Includes
//==============================================================================

#include <QWidget>
#include <QCursor>

#include "EditorPane.h"
#include "PlayerWnd.h"
#include "PlayerContainerWnd.h"
#include "DispatchListeners.h"

class CStudioApp;
class CHotKeys;
class CMouseCursor;
class CWndControl;

//==============================================================================
//	Forwards
//==============================================================================

//==============================================================================
//	Class CSceneView
//==============================================================================

//==============================================================================
/**
 *	CSceneView: Scene View.
 *
 *	Provides the view of the scene and displays the 3D Client window.
 */
//==============================================================================
class CSceneView : public QWidget,
                   public CEditorPane,
                   public CSelectedNodePropChangeListener,
                   public CClientPlayChangeListener,
                   public CEditCameraChangeListener
{
    Q_OBJECT
    //==========================================================================
    //	Protected Properties
    //==========================================================================
protected:
    bool m_FitClientToWindow = false; ///< True if user selected fit to window in prefrences
    bool m_RegisteredKeyDown = false; ///< True if a key is down
    CPlayerContainerWnd *m_PlayerContainerWnd = nullptr; ///< first-level child
    CPlayerWnd *m_PlayerWnd = nullptr; ///< second-level child (grandchild)
    QCursor m_ArrowCursor; ///< A pointer to the current cursor (changes according to mode)
    QCursor m_CursorGroupMove; ///< The move group cursor
    QCursor m_CursorGroupRotate; ///< The rotate group cursor
    QCursor m_CursorGroupScale; ///< The scale group cursor
    QCursor m_CursorItemMove; ///< The move item cursor
    QCursor m_CursorItemRotate; ///< The rotate item cursor
    QCursor m_CursorItemScale; ///< The scale item cursor
    QCursor m_CursorEditCameraPan; ///< The edit camera pan cursor
    QCursor m_CursorEditCameraRotate; ///< The edit camera rotate cursor
    QCursor m_CursorEditCameraZoom; ///< The edit camera zoom cursor

    long m_PreviousToolMode; ///< The previous tool mode (used when toggling with hotkeys to switch
                             ///back to previous mode on release)
    long m_PreviousSelectMode; ///< The previous select mode

    //==========================================================================
    //	Protected Methods
    //==========================================================================
protected: // create from serialization only

    //==========================================================================
    //	Public Methods
    //==========================================================================
public:
    CSceneView(CStudioApp *inStudioApp, QWidget *parent = nullptr);
    CSceneView(); // used for serialization only!
    virtual ~CSceneView();

    bool HandleModifierUp(int inChar, int inRepCnt, Qt::KeyboardModifiers modifiers);
    bool HandleModifierDown(int inChar, int inRepCnt, Qt::KeyboardModifiers modifiers);
    bool PtInClientRect(const QPoint& inPoint);
    void SetViewCursor();
    void SetToolMode(long inMode);
    void RecheckSizingMode();

    void SetRegisteredKey(bool inStatus);
    void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler);
    bool GetKeyStatus();

    void SetPlayerWndPosition();

    // redirect to/from PlayerContainerWnd
    bool IsDeploymentView();
    void SetViewMode(CPlayerContainerWnd::EViewMode inViewMode);

    // Tool helper methods
    void RestorePreviousTool();
    void SetToolOnCtrl();
    void SetToolOnAlt();

    void OnRulerGuideToggled();

    // CSelectedNodePropChangeListener
    void OnPropValueChanged(const Q3DStudio::CString &inPropertyName) override;
    void OnMouseDragged(bool inConstrainXAxis, bool inConstrainYAxis) override;

    // CClientPlayChangeListener
    void OnTimeChanged(long inTime) override;

    // CEditCameraChangeListener

    void OnEditCameraChanged() override;
    void OnEditCamerasTransformed() override;
    void OnAuthorZoomChanged() override;

    QSize sizeHint() const override;

    void OnToolGroupSelection();
    void OnToolItemSelection();
public:

    void resizeEvent(QResizeEvent *event) override;

Q_SIGNALS:
    void toolChanged();

protected:
    void RecalcMatte();

    // Generated message map functions
protected:
    void OnSetCursor();
    void showEvent(QShowEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
private:
    void onDropReceived();
};

/////////////////////////////////////////////////////////////////////////////

#endif // INCLUDED_SCENE_VIEW_H