summaryrefslogtreecommitdiff
path: root/Editor/GUI/EditorWindows.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-17 11:14:00 +0800
committerchai <chaifix@163.com>2021-10-17 11:14:00 +0800
commitd35db57d457132dd9d83fa2bd51491b148530655 (patch)
treeb5a29675f091f268577b5991988c723f273b0bd1 /Editor/GUI/EditorWindows.h
parent7b0a6d1fe0117cf42a5776aaabda2db78599e5b8 (diff)
*GUI
Diffstat (limited to 'Editor/GUI/EditorWindows.h')
-rw-r--r--Editor/GUI/EditorWindows.h89
1 files changed, 82 insertions, 7 deletions
diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h
index 4bd33ec..33d99c1 100644
--- a/Editor/GUI/EditorWindows.h
+++ b/Editor/GUI/EditorWindows.h
@@ -2,15 +2,38 @@
#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"
-void RegisterWindowClasses();
+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
@@ -23,12 +46,22 @@ public:
ContainnerWindow();
~ContainnerWindow();
- static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-
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;
@@ -40,20 +73,62 @@ private:
};
+// 窗口基类
+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;
-// 窗口内的单个子窗口,是事件相应、绘制、布局的单元
-class GUIView
+};
+
+// 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:
- HWND m_View;
+ bool SetRenderContext();
- LuaBind::Ref m_Script;
+ ContainnerWindow* m_ContainnerWindow;
+ HWND m_Handle;
+ HDC m_DC;
+ HGLRC m_RC;
+ LuaBind::Ref m_Script;
};