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.lua42
1 files changed, 31 insertions, 11 deletions
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
index f842ec5..2a01e53 100644
--- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
@@ -1,12 +1,16 @@
+local inspect = require "inspect"
+
local Debug = GameLab.Debug
local EEventType = GameLab.Events.EEventType
-local Math = require "GameLab.Engine.Math"
-local GUI = require "GameLab.Engine.GUI"
-local inspect = require "inspect"
+local Math = GameLab.Engine.Math
+local GUI = GameLab.Engine.GUI
local ECursor = GameLab.Editor.Window.ECursor
local Window = GameLab.Editor.Window
+local Vector2 = GameLab.Engine.Math.Vector2
+local Utils = GameLab.Utils
local Rect = Math.Rect
+local GUIState = GUI.GUIState
local Splitter = GameLab.Class("GameLab.Editor.Window.Internal.Splitter")
@@ -46,14 +50,31 @@ SplitWindow.Ctor = function(self, mode, splitter)
end
end
+SplitWindow.get_controlID = function(self)
+ return self.m_ControlID
+end
+
+SplitWindow.set_controlID = function(self, value)
+ self.m_ControlID = value
+end
+
+SplitWindow.get_containerWindow = function(self)
+ return self.m_ContainerWindow
+end
+
+SplitWindow.set_containerWindow = function(self, wnd)
+ self.m_ContainerWindow = wnd
+end
+
-- 布局,设置GUIWindow的大小
SplitWindow.DoSplit = function(self, event)
if self.m_Parent ~= nil then
self.m_Parent:DoSplit(event)
end
- self.m_ControlID = GUI.GetControlID()
+ self.controlID = GUIState.GetControlID()
+ local mousePosition = event.mousePosition
if event.type == EEventType.MouseDown then
for _, sp in ipairs(self.m_Splitter) do
local rect = Rect()
@@ -72,18 +93,17 @@ SplitWindow.DoSplit = function(self, event)
rect.width = self.m_Position.width
rect.height = h
end
- if rect:Contains(event.mousePosition) then
+ if rect:Contains(mousePosition) then
SplitState.currentSplitter = sp
- GUI.SetHotControl(self.m_ControlID)
+ GUIState.hotControl = self.controlID
break
end
end
elseif event.type == EEventType.MouseDrag then
- local hot = GUI.GetHotControl()
- if hot == self.m_ControlID then
+ if GUIState.hotControl == self.controlID then
local splitter = SplitState.currentSplitter
if splitter ~= nil then
- local mousePos = event.mousePosition
+ local mousePos = Utils.Clone(mousePosition)
mousePos.x = mousePos.x - self.m_Position.x
mousePos.y = mousePos.y - self.m_Position.y
if self.m_SplitMode == ESplitMode.Horizontal then
@@ -96,8 +116,8 @@ SplitWindow.DoSplit = function(self, event)
end
end
elseif event.type == EEventType.MouseUp then
- if GUI.GetHotControl() == self.m_ControlID then
- GUI.SetHotControl(0)
+ if GUIState.hotControl == self.controlID then
+ GUIState.hotControl = 0
SplitState.currentSplitter = nil
end
end