|
|
|
|
|
|
|
|
|
|
bool m_Active; |
|
|
|
|
|
|
|
bool m_DockLeft; |
|
|
|
bool m_DockTop; |
|
|
|
WindowDockingLayout m_WindowDockingLayout; |
|
|
|
|
|
|
|
Vector2 m_LocalMosueOffset; |
|
|
|
Rect m_PreviousParentRect; |
|
|
|
|
|
|
m_ResizeWithParentWindow = resizeWithParentwindow; |
|
|
|
m_Active = false; |
|
|
|
m_PreviousParentRect = new Rect(0f, 0f, 0f, 0f); |
|
|
|
m_WindowDockingLayout = new WindowDockingLayout(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void RegisterCallbacksOnTarget() |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OnMouseUp(MouseUpEvent evt) |
|
|
|
{ |
|
|
|
bool emitDragFinishedEvent = m_Active; |
|
|
|
|
|
|
|
|
|
|
evt.StopPropagation(); |
|
|
|
|
|
|
|
RefreshDocking(); |
|
|
|
m_WindowDockingLayout.CalculateDockingCornerAndOffset(target.layout, target.parent.layout); |
|
|
|
|
|
|
|
if (emitDragFinishedEvent && OnDragFinished != null) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
void RefreshDocking() |
|
|
|
{ |
|
|
|
Vector2 windowCenter = new Vector2(target.layout.x + target.layout.width * .5f, target.layout.y + target.layout.height * .5f); |
|
|
|
windowCenter /= target.parent.layout.size; |
|
|
|
|
|
|
|
m_DockLeft = windowCenter.x < .5f; |
|
|
|
m_DockTop = windowCenter.y < .5f; |
|
|
|
} |
|
|
|
|
|
|
|
void InitialLayoutSetup(PostLayoutEvent postLayoutEvent) |
|
|
|
{ |
|
|
|
m_PreviousParentRect = target.parent.layout; |
|
|
|
|
|
|
RefreshDocking(); |
|
|
|
m_WindowDockingLayout.CalculateDockingCornerAndOffset(target.layout, target.parent.layout); |
|
|
|
} |
|
|
|
|
|
|
|
void OnPostLayout(PostLayoutEvent postLayoutEvent) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Vector2 distanceFromParentEdge = Vector2.zero; |
|
|
|
distanceFromParentEdge.x = m_DockLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width); |
|
|
|
distanceFromParentEdge.y = m_DockTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height); |
|
|
|
distanceFromParentEdge.x = m_WindowDockingLayout.dockingLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width); |
|
|
|
distanceFromParentEdge.y = m_WindowDockingLayout.dockingTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height); |
|
|
|
|
|
|
|
Vector2 normalizedDistanceFromEdge = distanceFromParentEdge / m_PreviousParentRect.size; |
|
|
|
|
|
|
|
|
|
|
normalizedDistanceFromEdge = distanceFromParentEdge / target.parent.layout.size; |
|
|
|
} |
|
|
|
|
|
|
|
if (m_DockLeft) |
|
|
|
if (m_WindowDockingLayout.dockingLeft) |
|
|
|
{ |
|
|
|
windowRect.x = normalizedDistanceFromEdge.x * target.parent.layout.width; |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (m_DockTop) |
|
|
|
if (m_WindowDockingLayout.dockingTop) |
|
|
|
{ |
|
|
|
windowRect.y = normalizedDistanceFromEdge.y * target.parent.layout.height; |
|
|
|
} |
|
|
|