|
|
|
|
|
|
RegisterCallback<MouseUpEvent>(HandleDraggableMouseUp); |
|
|
|
} |
|
|
|
|
|
|
|
void OnResize(Vector2 resizeDelta, ResizeDirection direction, bool moveWhileResizeHorizontal, bool moveWhileresizerVertical) |
|
|
|
void OnResize(Vector2 resizeDelta, ResizeDirection direction, bool moveWhileResizeHorizontal, bool moveWhileresizeVertical) |
|
|
|
{ |
|
|
|
Vector2 normalizedResizeDelta = resizeDelta / 2f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rect newLayout = m_ResizeTarget.layout; |
|
|
|
|
|
|
|
// Resize form bottom/right
|
|
|
|
// Resize from bottom/right
|
|
|
|
if (!moveWhileResizeHorizontal) |
|
|
|
{ |
|
|
|
newLayout.width = Mathf.Max(newLayout.width + normalizedResizeDelta.x, minSize.x); |
|
|
|
|
|
|
if (!moveWhileresizerVertical) |
|
|
|
if (!moveWhileresizeVertical) |
|
|
|
{ |
|
|
|
newLayout.height = Mathf.Max(newLayout.height + normalizedResizeDelta.y, minSize.y); |
|
|
|
normalizedResizeDelta.y = 0f; |
|
|
|
|
|
|
|
|
|
|
if (m_StayWithinParentBounds) |
|
|
|
{ |
|
|
|
if (newLayout.x < 0f || (newLayout.x + newLayout.width) > m_ResizeTarget.parent.layout.width) |
|
|
|
float horizontalTranscendance = Mathf.Min(newLayout.x, 0f) + Mathf.Max(newLayout.xMax - m_ResizeTarget.parent.layout.width, 0f); |
|
|
|
float verticalTranscendance = Mathf.Min(newLayout.y, 0f) + Mathf.Max(newLayout.yMax - m_ResizeTarget.parent.layout.height, 0f); |
|
|
|
|
|
|
|
if (moveWhileResizeHorizontal) |
|
|
|
newLayout.width = m_ResizeTarget.layout.width; |
|
|
|
newLayout.x -= horizontalTranscendance; |
|
|
|
newLayout.width -= Mathf.Abs(horizontalTranscendance); |
|
|
|
if (newLayout.y < 0f || (newLayout.y + newLayout.height) > m_ResizeTarget.parent.layout.height) |
|
|
|
if (moveWhileresizeVertical) |
|
|
|
newLayout.height = m_ResizeTarget.layout.height; |
|
|
|
newLayout.y -= verticalTranscendance; |
|
|
|
newLayout.height -= Mathf.Abs(verticalTranscendance); |
|
|
|
} |
|
|
|
|
|
|
|
m_ResizeTarget.layout = newLayout; |
|
|
|