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
|
#ifndef EDITOR_WINDOW_H
#define EDITOR_WINDOW_H
#include <windows.h>
#include <vector>
#include "Runtime/Math/Rect.h"
#include "Runtime/Scripting/LuaBind.h"
#include "Runtime/Utilities/Singleton.h"
#include "Editor/Utils/Log.h"
#include "Runtime/Graphics/OpenGL.h"
class GUIWindow;
class WindowUtil
{
public :
static void Init();
static const wchar_t* kContainerWindowClassName;
static const wchar_t* kPopupWindowClassName;
static const wchar_t* kGUIWindowClassName;
};
class WindowManager : Singleton<WindowManager>
{
public:
static Vector2f GetMousePosition();
static GUIWindow* GetMouseOverWindow();
};
// 一个containner window中有多个viewport
class ContainnerWindow
{
public:
static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
enum ShowMode {
kShowNormalWindow = 0, // normal window with max/min/close buttons
kShowPopupMenu = 1, // popup menu - no title bar
kShowUtility = 2, // tool window - floats in the app, and hides when the app deactivates
kShowNoShadow = 3, // no shadow/decorations
kShowMainWindow = 4, // main Unity window. On Mac does not have close button; on Windows has menu bar etc.
kShowAuxWindow = 5, // Popup windows like the color picker, gradient editor, etc. Drawn with black background on Mac
};
ContainnerWindow();
~ContainnerWindow();
void Init(Rectf size, int showMode, const Vector2f& minSize, const Vector2f& maxSize);
void SetTitle(const char* title);
void SetIcon(LPCSTR iconName);
void SetAsRenderContext();
void DoPaint();
HWND GetWindowHandle();
HDC GetDC() { return m_DC; }
HGLRC GetRC() { return m_RC; }
private:
bool SetRenderContext();
HWND m_Window;
HDC m_DC;
HGLRC m_RC;
POINT m_Size;
ShowMode m_ShowMode; // 窗口类型
bool m_IsClosing;
bool m_InMenuLoop;
bool m_CloseFromScriptDontShutdown;
Rectf m_InternalRect;
POINT m_MinSize;
POINT m_MaxSize;
};
// 窗口基类
class WindowBase
{
};
// 抽象窗口,用来做布局
class SplitWindow : public WindowBase
{
public:
enum SplitMode
{
Horizontal,
Vertical,
};
SplitMode GetSplitMode() { return m_SplitMode; }
private:
SplitMode m_SplitMode;
GUIWindow* m_GUIWindow;
std::vector<GUIWindow*> m_GUIWindows;
};
// GUI窗口,事件相应、绘制、布局的单元
// 和unity不一样的地方在于一个GUIWindow只会有一个EditorWindow,即一个切页,因为在实际开发中我发现很少会频繁的切换切页,UE逻辑更像blender
// 好处也在于比较好组织
class GUIWindow : public WindowBase
{
public:
static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static void RepaintAll();
void Init();
void DoPaint();
void SetContainnerWindow(ContainnerWindow* wnd);
void Focus();
void SetPosition(Rectf position);
void SetAsRenderContext();
void OnFocus();
void OnLostFocus();
HDC GetDC() { return m_DC; }
HGLRC GetRC() { return m_RC; }
private:
bool SetRenderContext();
ContainnerWindow* m_ContainnerWindow;
HWND m_Handle;
HDC m_DC;
HGLRC m_RC;
LuaBind::Ref m_Script;
};
#endif
|