diff options
author | chai <chaifix@163.com> | 2021-11-08 09:23:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-08 09:23:38 +0800 |
commit | 138d3f4d3d6e2aaf5ba34f89af15ef85ea074357 (patch) | |
tree | 31ca6e8ea6d2e960e8d35f801bd92555942822e2 /Editor/GUI/EditorWindows.h | |
parent | efce5b6bd5c9d4f8214a71e0f7a7c35751710a4c (diff) |
*misc
Diffstat (limited to 'Editor/GUI/EditorWindows.h')
-rw-r--r-- | Editor/GUI/EditorWindows.h | 186 |
1 files changed, 4 insertions, 182 deletions
diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index d8a3f66..d31627c 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -1,5 +1,4 @@ -#ifndef EDITOR_WINDOW_H -#define EDITOR_WINDOW_H +#pragma once #include <windows.h> #include <vector> @@ -12,184 +11,7 @@ #include "Runtime/Utilities/UtilMacros.h" #include "Editor/Utils/HelperFuncs.h" #include "Runtime/Math/Math.h" +#include "Runtime/Utilities/Exception.h" -using namespace LuaBind; - -class GUIWindow; - -class WindowUtil -{ -public : - static void RegisterClasses(); - - static const wchar_t* kContainerWindowClassName; - static const wchar_t* kPopupWindowClassName; - static const wchar_t* kGUIWindowClassName; -}; - -class WindowManager : Singleton<WindowManager> -{ -public: - static Vector2 GetMousePosition(); - static GUIWindow* GetMouseOverWindow(); - -private: - static std::vector<GUIWindow*> s_GUIWindows; - -}; - -// 一个containner window中有多个viewport -class ContainerWindow - : public LuaBind::NativeClass<ContainerWindow> -{ -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 - }; - - ContainerWindow(LuaBind::VM* vm); - ~ContainerWindow(); - - void Init(Rect size, int showMode, const Vector2& minSize, const Vector2& maxSize, std::string name = ""); - void SetTitle(const char* title); - void SetIcon(LPCSTR iconName); - void SetAsRenderContext(); - void DoPaint(); - void Close(); - - GET_SET(std::string, Name, m_Name); - - GET(HWND, WindowHandle, m_Window); - GET(HDC, DC, m_DC); - - void OnRectChanged(); - void OnActivateApplication(bool active); - -private: - bool SetRenderContext(); - - //-------------------------------------------------------- - - std::string m_Name; - - POINT m_Size; - ShowMode m_ShowMode; // 窗口类型 - bool m_IsClosing; - bool m_InMenuLoop; - bool m_CloseFromScriptDontShutdown; - Rect m_InternalRect; - POINT m_MinSize; - POINT m_MaxSize; - -#ifdef GAMELAB_WIN - HWND m_Window; - HDC m_DC; -#endif - - //-------------------------------------------------------- - - LUA_BIND_DECL_CLASS(ContainerWindow); - - LUA_BIND_DECL_METHOD(_New); - LUA_BIND_DECL_METHOD(_SetTitle); - LUA_BIND_DECL_METHOD(_SetIcon); - LUA_BIND_DECL_METHOD(_DoPaint); - -}; - -class WindowBase -{ -}; - -// 抽象窗口,用来做布局,SplitWindow是嵌套的 -class SplitWindow : public WindowBase -{ -public: - enum SplitMode - { - Horizontal, - Vertical, - }; - - SplitMode GetSplitMode() { return m_SplitMode; } - - GET(SplitMode, SplitMode, m_SplitMode); - -private: - SplitMode m_SplitMode; - - // 嵌套split - std::vector< SplitWindow*> m_ChildSplitWindows; - - // 最顶层的split window包含的是GUIWindows - std::vector<GUIWindow*>* m_GUIWindows; - -}; - -// GUI窗口,事件相应、绘制、布局的单元 -class GUIWindow - : public WindowBase - , public LuaBind::NativeClass<GUIWindow> -{ -public: - static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - static void RepaintAll(); - - GUIWindow(LuaBind::VM* vm); - - void Init(std::string name = ""); - void DoPaint(); - void SetContainerWindow(ContainerWindow* wnd); - void Focus(); - void SetPosition(Rect position); - void SetAsRenderContext(); - - void OnFocus(); - void OnLostFocus(); - void OnPaint(); - - GET_SET(std::string, Name, m_Name); - GET(HDC, DC, m_DC); - -private: - void ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam); - bool SetRenderContext(); - - //----------------------------------------------------------------- - - std::string m_Name; - - ContainerWindow* m_ContainerWindow; - - std::vector<LuaBind::MemberRef> m_EditorWindows; - LuaBind::MemberRef m_EditorWindow; // EditorWindow脚本 - LuaBind::MemberRef m_ActiveEditorWindow; // 当前激活的EditorWindow - - LuaBind::MemberRef m_Script; // EditorWindow脚本 - -#if GAMELAB_WIN - HWND m_Handle; - HDC m_DC; -#endif - - //----------------------------------------------------------------- - - LUA_BIND_DECL_CLASS(GUIWindow); - - LUA_BIND_DECL_METHOD(_New); - LUA_BIND_DECL_METHOD(_DoPaint); - LUA_BIND_DECL_METHOD(_Focus); - LUA_BIND_DECL_METHOD(_SetContainerWindow); - LUA_BIND_DECL_METHOD(_SetPosition); - LUA_BIND_DECL_METHOD(_SetInstance); - -}; - -#endif
\ No newline at end of file +#include "ContainerWindow.h" +#include "GUIWindow.h" |