summaryrefslogtreecommitdiff
path: root/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Data/Libraries/GameLab/Editor/Window/SplitWindow.lua')
-rw-r--r--Data/Libraries/GameLab/Editor/Window/SplitWindow.lua30
1 files changed, 15 insertions, 15 deletions
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
index 8f126a9..9a398c2 100644
--- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
@@ -3,6 +3,8 @@ local EEventType = GameLab.Events.EEventType
local Math = require "GameLab.Engine.Math"
local GUI = require "GameLab.Engine.GUI"
local inspect = require "inspect"
+local ECursor = GameLab.Editor.Window.ECursor
+local Window = GameLab.Editor.Window
local Rect = Math.Rect
@@ -24,22 +26,21 @@ local SplitState = {
}
-- 抽象的窗口,用来处理布局
-local SplitWindow = GameLab.GlobalClass("GameLab.Editor.Window.SplitWindow")
-
-SplitWindow.Ctor = function(self, mode, splitter)
+local SplitWindow = GameLab.GlobalClass("GameLab.Editor.Window.SplitWindow", function(self, mode, splitter)
+ self.m_ControlID = nil
self.m_ContainerWindow = nil
self.m_SplitMode = mode
self.m_Parent = nil -- 父节点是一个split window或者空
self.m_SubWindows = {} -- 子窗口,可以是SplitWindow或GUIWindow
self.m_Splitter = {}
- self.m_Position = Rect.New()
+ self.m_Position = Rect()
if splitter ~= nil and type(splitter) == "table" then
for _, v in ipairs(splitter) do
- local sp = Splitter.New(v)
+ local sp = Splitter(v)
table.insert(self.m_Splitter, sp)
end
end
-end
+end)
-- 布局,设置GUIWindow的大小
SplitWindow.DoSplit = function(self, event)
@@ -47,12 +48,11 @@ SplitWindow.DoSplit = function(self, event)
self.m_Parent:DoSplit(event)
end
- local id = GUI.GetControlID()
+ self.m_ControlID = GUI.GetControlID()
if event.type == EEventType.MouseDown then
- local bHandled = false
for i, sp in ipairs(self.m_Splitter) do
- local rect = Rect.New()
+ local rect = Rect()
if self.m_SplitMode == ESplitMode.Horizontal then
local x = sp.value * self.m_Position.width + self.m_Position.x - sp.size / 2
local w = sp.size
@@ -70,14 +70,13 @@ SplitWindow.DoSplit = function(self, event)
end
if rect:Contains(event.mousePosition) then
SplitState.currentSplitter = sp
- GUI.SetHotControl(id)
- bHandled = true
+ GUI.SetHotControl(self.m_ControlID)
break
end
end
elseif event.type == EEventType.MouseDrag then
local hot = GUI.GetHotControl()
- if hot == id then
+ if hot == self.m_ControlID then
local splitter = SplitState.currentSplitter
if splitter ~= nil then
local mousePos = event.mousePosition
@@ -93,7 +92,8 @@ SplitWindow.DoSplit = function(self, event)
end
end
elseif event.type == EEventType.MouseUp then
- if GUI.GetHotControl() == id then
+ if GUI.GetHotControl() == self.m_ControlID then
+ GUI.SetHotControl(0)
SplitState.currentSplitter = nil
end
end
@@ -105,7 +105,7 @@ SplitWindow.SetPosition = function(self, position)
for i, subWindow in ipairs(self.m_SubWindows) do
local prev = i > 1 and self.m_Splitter[i-1].value or 0
local next = i <= #self.m_Splitter and self.m_Splitter[i].value or 1
- local pos = Rect.New()
+ local pos = Rect()
pos:CopyFrom(position)
if self.m_SplitMode == ESplitMode.Horizontal then
pos.x = pos.x + prev * position.width
@@ -119,7 +119,7 @@ SplitWindow.SetPosition = function(self, position)
end
SplitWindow.GetPosition = function(self)
- local pos = Rect.New()
+ local pos = Rect()
pos:CopyFrom(self.m_Position)
return pos
end