summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Data/DefaultContent/Libraries/GameLab/Engine/GUI/IMGUI.lua18
-rw-r--r--Data/DefaultContent/Libraries/GameLab/Engine/Math/Rect.lua7
-rw-r--r--Data/Libraries/GameLab/Editor/EditorWindow.lua3
-rw-r--r--Data/Libraries/GameLab/Editor/Window/ContainerWindow.lua15
-rw-r--r--Data/Libraries/GameLab/Editor/Window/SplitWindow.lua80
-rw-r--r--Data/Libraries/GameLab/Editor/Window/init.lua1
-rw-r--r--Data/Scripts/Editor/AssetBrowser.lua14
-rw-r--r--Data/Scripts/EditorApplication.lua11
-rw-r--r--Data/Scripts/EditorGUI/EditorWindowManager.lua23
-rw-r--r--Data/boot.lua2
-rw-r--r--Editor/GUI/ContainerWindow.cpp10
-rw-r--r--Editor/GUI/ContainerWindow.h3
-rw-r--r--Editor/Scripting/Window/ContainerWindow.bind.cpp12
13 files changed, 168 insertions, 31 deletions
diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/GUI/IMGUI.lua b/Data/DefaultContent/Libraries/GameLab/Engine/GUI/IMGUI.lua
index f8cc33b..2b763e7 100644
--- a/Data/DefaultContent/Libraries/GameLab/Engine/GUI/IMGUI.lua
+++ b/Data/DefaultContent/Libraries/GameLab/Engine/GUI/IMGUI.lua
@@ -31,8 +31,24 @@ GUI.EndFrame = function()
end
-GUI.Button = function()
+------------------------------------------------------------------------------------------------
+-- 控件
+------------------------------------------------------------------------------------------------
+
+GUI.Button = function(rect, content )
local id = GUI.GetControlID()
+
+end
+
+GUI.Toggle = function()
+
+end
+
+GUI.Label = function()
+
+end
+
+GUI.Box = function()
end
diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Rect.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Rect.lua
index 75b550d..ba18637 100644
--- a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Rect.lua
+++ b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Rect.lua
@@ -14,6 +14,13 @@ Rect.Set = function(self, rect)
self.w = rect.w or rect[4]
end
+Rect.CopyFrom = function(self, rect)
+ self.x = rect.x
+ self.y = rect.y
+ self.width = rect.width
+ self.height = rect.height
+end
+
Rect.Contains = function(self, point)
end
diff --git a/Data/Libraries/GameLab/Editor/EditorWindow.lua b/Data/Libraries/GameLab/Editor/EditorWindow.lua
index 6bb59d3..94a7464 100644
--- a/Data/Libraries/GameLab/Editor/EditorWindow.lua
+++ b/Data/Libraries/GameLab/Editor/EditorWindow.lua
@@ -1,9 +1,10 @@
+local EditorWindowManager = require("EditorGUI.EditorWindowManager")
+
-- EditorWindow是应用级别的逻辑窗口
-- ContainerWindow
-- |- SplitWindow
-- |- GUIWindow
-- |- EditorWindow
-
local EditorWindow = GameLab.GlobalClass("GameLab.Editor.EditorWindow")
EditorWindow.Ctor = function(self, title)
diff --git a/Data/Libraries/GameLab/Editor/Window/ContainerWindow.lua b/Data/Libraries/GameLab/Editor/Window/ContainerWindow.lua
index 2936101..caf3b37 100644
--- a/Data/Libraries/GameLab/Editor/Window/ContainerWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/ContainerWindow.lua
@@ -1,8 +1,11 @@
local NativeContainWidow = GameLab.Editor.Window.Internal.ContainerWindow
+local Window = GameLab.Editor.Window
+
local ContainerWindow = GameLab.GlobalClass("GameLab.Editor.Window.ContainerWindow")
ContainerWindow.Ctor = function(self, position, showMode, min, max)
self.m_Native = NativeContainWidow.New(position, showMode, min, max)
+ self.m_RootSplitWindow = Window.SplitWindow.New(Window.ESplitMode.Horizontal)
end
ContainerWindow.SetTitle = function(self)
@@ -17,4 +20,16 @@ ContainerWindow.GetNative = function(self)
return self.m_Native
end
+ContainerWindow.GetSize = function(self)
+ return self.m_Native:GetSize()
+end
+
+ContainerWindow.GetWidth = function(self)
+ return self:GetSize().x
+end
+
+ContainerWindow.GetHeight = function(self)
+ return self:GetSize().y
+end
+
return ContainerWindow \ No newline at end of file
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
index f5d410c..597e858 100644
--- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
@@ -1,32 +1,88 @@
+local Debug = GameLab.Debug
+local Rect = require("GameLab.Engine.Math.Rect")
+
local Splitter = GameLab.Class("GameLab.Editor.Window.Internal.Splitter")
-Splitter.Ctor = function(self)
- self.width = 10
+Splitter.Ctor = function(self, value)
+ self.size = 10
+ self.value = value -- [0-1] 位置
end
-- 抽象的窗口,用来处理布局
local SplitWindow = GameLab.GlobalClass("GameLab.Editor.Window.SplitWindow")
local ESplitMode = GameLab.GlobalEnum("GameLab.Editor.Window.ESplitMode", {
- "Vertical",
- "Horizontal"
+ "Horizontal", -- 水平划分
+ "Vertical", -- 垂直划分
})
-SplitWindow.Ctor = function(self)
- self.m_Splitter = {}
- self.m_SplitMode = ESplitMode.Horizontal
- self.m_GUIWindows = {}
- self.m_Parent = nil -- 父节点也是一个split window
- self.m_SubSplit = {} -- 子节点也是split windows
+SplitWindow.Ctor = function(self, mode, splitter)
+ self.m_SplitMode = mode
+ self.m_Parent = nil -- 父节点是一个split window或者空
+ self.m_SubSplit = {} -- 子节点也是split windows
+ self.m_GUIWindow = {} -- 不包含subSplit的有一个GUIWindow
+ self.m_Splitter = {}
+ self.m_ContainerWindow = nil
+ if splitter ~= nil and type(splitter) == "table" then
+ for _, v in ipairs(splitter) do
+ local sp = Splitter.New(v)
+ table.insert(self.m_Splitter, sp)
+ end
+ end
end
+-- 布局,设置GUIWindow的大小
SplitWindow.DoSplit = function(self, event)
-
+ -- local position = self:GetPosition()
+ -- for _, sp in ipairs(self.m_SubSplit) do
+ -- sp:DoSplit(event)
+ -- end
end
+-- 返回在containerWindow下的像素大小和位置
+SplitWindow.GetPosition = function(self)
+ local position = Rect.New()
+ local parent = self.GetParent
+ if parent == nil then --最顶层的split window
+ position.x = 0
+ position.y = 0
+ position.width = self.m_ContainerWindow:GetWidth()
+ position.height = self.m_ContainerWindow:GetHeight()
+ return position
+ end
+ local parentPos = parent:GetPosition()
+ local index = self:GetIndexOfParent()
+ -- 前后的splitter
+ local prev = index > 1 and parent.m_Splitter[index - 1] or nil
+ local next = index <= #parent.m_Splitter and parent.m_Splitter[index] or nil
+ local offset = prev ~= nil and prev.value or 0
+ local pv = offset
+ local nv = next ~= nil and next.value or 1
+ local size = nv - pv
+ position:CopyFrom(parentPos)
+ if parent.m_SplitMode == ESplitMode.Horizontal then
+ position.x = position.x + offset
+ position.width = position.width * size
+ else
+ position.y = position.y + offset
+ position.height = position.height * size
+ end
+end
+
-- 返回guiWnd
-SplitWindow.IndexOfGUIWindow = function(self, guiWnd)
+SplitWindow.GetIndexOfParent = function(self)
+ if self.m_Parent == nil then
+ return 1
+ end
+ for i, sp in ipairs(self.m_Parent.m_SubSplit) do
+ if sp == self then
+ return i
+ end
+ end
+end
+SplitWindow.GetParent = function(self)
+ return self.m_Parent
end
return SplitWindow \ No newline at end of file
diff --git a/Data/Libraries/GameLab/Editor/Window/init.lua b/Data/Libraries/GameLab/Editor/Window/init.lua
index 07f2a92..430e8f9 100644
--- a/Data/Libraries/GameLab/Editor/Window/init.lua
+++ b/Data/Libraries/GameLab/Editor/Window/init.lua
@@ -5,5 +5,6 @@ local import = GameLab.import(...)
import("ContainerWindow")
import("GUIWindow")
+import("SplitWindow")
return m \ No newline at end of file
diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua
index 37e9358..6d02579 100644
--- a/Data/Scripts/Editor/AssetBrowser.lua
+++ b/Data/Scripts/Editor/AssetBrowser.lua
@@ -1,12 +1,12 @@
-local Debug = GameLab.Debug
-local AssetBrowser = GameLab.Editor.EditorWindow.Extend("GameLab.Editor.AssetBrowser")
-local GL = GameLab.Engine.GL
+local Debug = GameLab.Debug
+local GL = GameLab.Engine.GL
local Matrix44 = GameLab.Engine.Math.Matrix44
-local Engine = GameLab.Engine
-local Editor = GameLab.Editor
-local IO = GameLab.IO
+local Engine = GameLab.Engine
+local Editor = GameLab.Editor
+local IO = GameLab.IO
+local inspect = require("inspect")
-local inspect = require("inspect")
+local AssetBrowser = GameLab.Editor.EditorWindow.Extend("GameLab.Editor.AssetBrowser")
AssetBrowser.Ctor = function(self)
self.base.Ctor(self, "AssetBrowser")
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua
index 4c4a708..01f5b70 100644
--- a/Data/Scripts/EditorApplication.lua
+++ b/Data/Scripts/EditorApplication.lua
@@ -8,7 +8,7 @@ local Engine = GameLab.Engine
local Resource = GameLab.Engine.Resource
local Rendering = GameLab.Engine.Rendering
local Debug = GameLab.Debug
-local GUI = GameLab.Editor.Window
+local Window = GameLab.Editor.Window
local GL = GameLab.Engine.GL
local app = GameLab.Editor.EditorApplication.New()
@@ -17,22 +17,21 @@ if app == nil then
Debug.LogError("app is nil")
end
-local mainWindow = GUI.ContainerWindow.New({400, 400, 800, 500}, GUI.EShowMode.MainWindow, {100, 100}, {700, 700})
+local mainWindow = Window.ContainerWindow.New({400, 400, 800, 500}, Window.EShowMode.MainWindow, {100, 100}, {700, 700})
mainWindow:SetTitle("GameLab")
mainWindow:SetIcon("./Data/Icon/GameLab.ico")
app:SetMainWindow(mainWindow:GetNative())
+EditorWindowManager.SetMainWindow(mainWindow)
-local guiWindow = GUI.GUIWindow.New()
+local guiWindow = Window.GUIWindow.New()
guiWindow:SetContainerWindow(mainWindow)
guiWindow:SetPosition({0,0, 400, 400})
-local guiWindow2 = GUI.GUIWindow.New()
+local guiWindow2 = Window.GUIWindow.New()
guiWindow2:SetContainerWindow(mainWindow)
guiWindow2:SetPosition({400,0, 400, 400})
-local wnd = AssetBrowser.New()
-
local v = GameLab.Engine.Math.Vector4.New(1,2,3,4)
local c = Engine.Rendering.Color.New(1,1,1,1)
diff --git a/Data/Scripts/EditorGUI/EditorWindowManager.lua b/Data/Scripts/EditorGUI/EditorWindowManager.lua
index 27dd16d..ecd6912 100644
--- a/Data/Scripts/EditorGUI/EditorWindowManager.lua
+++ b/Data/Scripts/EditorGUI/EditorWindowManager.lua
@@ -4,8 +4,27 @@ local SplitWindow = require("GameLab.Editor.Window.SplitWindow")
local EditorWindowManager = {}
-EditorWindowManager.splitWindows = {}
+EditorWindowManager.splitWindows = {}
+EditorWindowManager.containerWindows = {}
+EditorWindowManager.guiWindows = {}
+EditorWindowManager.rootSplitWindow = nil
+EditorWindowManager.mainWindow = nil
+local splitWindows = EditorWindowManager.splitWindows
+local containerWindows = EditorWindowManager.containerWindows
+local guiWindows = EditorWindowManager.guiWindows
+-- 申请一个GUIWindow并
+EditorWindowManager.ClaimGUIWindow = function()
+ if #splitWindows == 0 then
+ local sp = SplitWindow.New()
+ table.insert( splitWindows, sp)
-return EditorWindowManager \ No newline at end of file
+ end
+end
+
+EditorWindowManager.SetMainWindow = function(wnd)
+ EditorWindowManager.mainWindow = wnd
+end
+
+return EditorWindowManager \ No newline at end of file
diff --git a/Data/boot.lua b/Data/boot.lua
index bb95b16..9d372c9 100644
--- a/Data/boot.lua
+++ b/Data/boot.lua
@@ -35,7 +35,7 @@ require "GameLab.Editor"
require "GameLab.Editor.Window"
-- debugging
-require("LuaPanda").start("127.0.0.1",8818)
+--require("LuaPanda").start("127.0.0.1",8818)
-- launch editor
dofile("./Scripts/EditorApplication.lua")
diff --git a/Editor/GUI/ContainerWindow.cpp b/Editor/GUI/ContainerWindow.cpp
index 99fa6cb..59cd008 100644
--- a/Editor/GUI/ContainerWindow.cpp
+++ b/Editor/GUI/ContainerWindow.cpp
@@ -431,6 +431,16 @@ void ContainerWindow::Close()
SendMessage(m_Window, WM_CLOSE, 0, 0);
}
+Vector2f ContainerWindow::GetSize()
+{
+ RECT rect;
+ GetClientRect(m_Window, &rect);
+ Vector2f size;
+ size.x = rect.right - rect.left;
+ size.y = rect.bottom - rect.top;
+ return size;
+}
+
void ContainerWindow::OnRectChanged()
{
diff --git a/Editor/GUI/ContainerWindow.h b/Editor/GUI/ContainerWindow.h
index 140748d..08f08fe 100644
--- a/Editor/GUI/ContainerWindow.h
+++ b/Editor/GUI/ContainerWindow.h
@@ -40,6 +40,8 @@ public:
void DoPaint();
void Close();
+ Vector2f GetSize();
+
GET_SET(std::string, Name, m_Name);
GET(HWND, WindowHandle, m_Window);
@@ -77,6 +79,7 @@ private:
LUA_BIND_DECL_METHOD(_SetTitle);
LUA_BIND_DECL_METHOD(_SetIcon);
LUA_BIND_DECL_METHOD(_DoPaint);
+ LUA_BIND_DECL_METHOD(_GetSize);
};
diff --git a/Editor/Scripting/Window/ContainerWindow.bind.cpp b/Editor/Scripting/Window/ContainerWindow.bind.cpp
index 6c73116..5e7319b 100644
--- a/Editor/Scripting/Window/ContainerWindow.bind.cpp
+++ b/Editor/Scripting/Window/ContainerWindow.bind.cpp
@@ -9,7 +9,8 @@ LUA_BIND_REGISTRY(ContainerWindow)
{ "New", _New },
{ "SetTitle", _SetTitle },
{ "SetIcon", _SetIcon },
- { "DoPaint", _DoPaint }
+ { "DoPaint", _DoPaint },
+ { "GetSize", _GetSize }
);
}
@@ -37,6 +38,15 @@ LUA_BIND_IMPL_METHOD(ContainerWindow, _SetIcon)
return 0;
}
+LUA_BIND_IMPL_METHOD(ContainerWindow, _GetSize)
+{
+ LUA_BIND_PREPARE(L, ContainerWindow);
+
+ state.PushLuaObject(self->GetSize());
+
+ return 1;
+}
+
LUA_BIND_IMPL_METHOD(ContainerWindow, _DoPaint)
{
LUA_BIND_PREPARE(L, ContainerWindow);