浏览代码

Improve resize handling of inspector window

/main
Jens Holm 7 年前
当前提交
0ff2964b
共有 2 个文件被更改,包括 22 次插入20 次删除
  1. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  2. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


normalizedResizeDelta.y = 0f;
}
Vector2 newSize = new Vector2();
Vector2 newPosition = new Vector2(style.positionLeft, style.positionTop);
Rect newLayout = layout;
if (moveWhileResize)
// Resize form bottom/right
if (!moveWhileResize)
newPosition.x = style.positionLeft + normalizedResizeDelta.x;
newPosition.y = style.positionTop + normalizedResizeDelta.y;
newLayout.width = Mathf.Max(layout.width + normalizedResizeDelta.x, 60f);
newLayout.height = Mathf.Max(layout.height + normalizedResizeDelta.y, 60f);
layout = newLayout;
normalizedResizeDelta *= -1f;
return;
newSize.x = Mathf.Max(style.width + normalizedResizeDelta.x, 60f);
newSize.y = Mathf.Max(style.height + normalizedResizeDelta.y, 60f);
float previousFarX = layout.x + layout.width;
float previousFarY = layout.y + layout.height;
if (newSize.x > 60f)
{
style.positionLeft = newPosition.x;
style.width = Mathf.Max(style.width + normalizedResizeDelta.x, 60f);
}
newLayout.width = Mathf.Max(layout.width - normalizedResizeDelta.x, 60f);
newLayout.height = Mathf.Max(layout.height - normalizedResizeDelta.y, 60f);
newLayout.x = Mathf.Min(layout.x + normalizedResizeDelta.x, previousFarX - 60f);
newLayout.y = Mathf.Min(layout.y + normalizedResizeDelta.y, previousFarY - 60f);
if (newSize.y > 60f)
{
style.positionTop = newPosition.y;
style.height = Mathf.Max(style.height + normalizedResizeDelta.y, 60f);
}
layout = newLayout;
}
MasterNode masterNode

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


{
Vector2 normalizedDelta = mouseDelta / 2f;
m_GraphInspectorView.style.positionLeft += normalizedDelta.x;
m_GraphInspectorView.style.positionTop += normalizedDelta.y;
Rect inspectorWindowRect = m_GraphInspectorView.layout;
inspectorWindowRect.x += normalizedDelta.x;
inspectorWindowRect.y += normalizedDelta.y;
m_GraphInspectorView.layout = inspectorWindowRect;
}
GraphViewChange GraphViewChanged(GraphViewChange graphViewChange)

正在加载...
取消
保存