UnityEditor.CurveEditorRectangleTool.CalculateLayout C# (CSharp) Method

CalculateLayout() private method

private CalculateLayout ( ) : ToolLayout
return ToolLayout
        private ToolLayout CalculateLayout()
        {
            ToolLayout layout = new ToolLayout();
            bool flag = !Mathf.Approximately(this.selectionBounds.size.x, 0f);
            bool flag2 = !Mathf.Approximately(this.selectionBounds.size.y, 0f);
            float x = base.TimeToPixel(this.selectionBounds.min.x);
            float num2 = base.TimeToPixel(this.selectionBounds.max.x);
            float y = base.ValueToPixel(this.selectionBounds.max.y);
            float num4 = base.ValueToPixel(this.selectionBounds.min.y);
            layout.selectionRect = new Rect(x, y, num2 - x, num4 - y);
            layout.displayHScale = true;
            float width = (layout.selectionRect.width - 15f) - 15f;
            if (width < 14f)
            {
                layout.displayHScale = false;
                width = layout.selectionRect.width;
                if (width < 14f)
                {
                    layout.selectionRect.x = layout.selectionRect.center.x - 7f;
                    layout.selectionRect.width = 14f;
                    width = 14f;
                }
            }
            if (layout.displayHScale)
            {
                layout.hBarLeftRect = new Rect(layout.selectionRect.xMin, base.contentRect.yMin, 15f, 13f);
                layout.hBarRect = new Rect(layout.hBarLeftRect.xMax, base.contentRect.yMin, width, 13f);
                layout.hBarRightRect = new Rect(layout.hBarRect.xMax, base.contentRect.yMin, 15f, 13f);
            }
            else
            {
                layout.hBarRect = new Rect(layout.selectionRect.xMin, base.contentRect.yMin, width, 13f);
                layout.hBarLeftRect = new Rect(0f, 0f, 0f, 0f);
                layout.hBarRightRect = new Rect(0f, 0f, 0f, 0f);
            }
            layout.displayVScale = true;
            float height = (layout.selectionRect.height - 15f) - 15f;
            if (height < 15f)
            {
                layout.displayVScale = false;
                height = layout.selectionRect.height;
                if (height < 15f)
                {
                    layout.selectionRect.y = layout.selectionRect.center.y - 7.5f;
                    layout.selectionRect.height = 15f;
                    height = 15f;
                }
            }
            if (layout.displayVScale)
            {
                layout.vBarTopRect = new Rect(base.contentRect.xMin, layout.selectionRect.yMin, 13f, 15f);
                layout.vBarRect = new Rect(base.contentRect.xMin, layout.vBarTopRect.yMax, 13f, height);
                layout.vBarBottomRect = new Rect(base.contentRect.xMin, layout.vBarRect.yMax, 13f, 15f);
            }
            else
            {
                layout.vBarRect = new Rect(base.contentRect.xMin, layout.selectionRect.yMin, 13f, height);
                layout.vBarTopRect = g_EmptyRect;
                layout.vBarBottomRect = g_EmptyRect;
            }
            if (flag)
            {
                float num7 = 0.09999999f;
                float num8 = 0.09999999f;
                layout.scaleLeftRect = new Rect(layout.selectionRect.xMin - 17f, layout.selectionRect.yMin + (layout.selectionRect.height * num7), 17f, layout.selectionRect.height * 0.8f);
                layout.scaleRightRect = new Rect(layout.selectionRect.xMax, layout.selectionRect.yMin + (layout.selectionRect.height * num8), 17f, layout.selectionRect.height * 0.8f);
            }
            else
            {
                layout.scaleLeftRect = g_EmptyRect;
                layout.scaleRightRect = g_EmptyRect;
            }
            if (flag2)
            {
                float num9 = 0.09999999f;
                float num10 = 0.09999999f;
                layout.scaleTopRect = new Rect(layout.selectionRect.xMin + (layout.selectionRect.width * num10), layout.selectionRect.yMin - 17f, layout.selectionRect.width * 0.8f, 17f);
                layout.scaleBottomRect = new Rect(layout.selectionRect.xMin + (layout.selectionRect.width * num9), layout.selectionRect.yMax, layout.selectionRect.width * 0.8f, 17f);
            }
            else
            {
                layout.scaleTopRect = g_EmptyRect;
                layout.scaleBottomRect = g_EmptyRect;
            }
            if (flag)
            {
                layout.leftLabelAnchor = new Vector2(layout.selectionRect.xMin - 3f, base.contentRect.yMin + 1f);
                layout.rightLabelAnchor = new Vector2(layout.selectionRect.xMax + 3f, base.contentRect.yMin + 1f);
            }
            else
            {
                layout.leftLabelAnchor = layout.rightLabelAnchor = new Vector2(layout.selectionRect.xMax + 3f, base.contentRect.yMin + 1f);
            }
            if (flag2)
            {
                layout.bottomLabelAnchor = new Vector2(base.contentRect.xMin + 1f, layout.selectionRect.yMax + 2f);
                layout.topLabelAnchor = new Vector2(base.contentRect.xMin + 1f, layout.selectionRect.yMin - 2f);
            }
            else
            {
                layout.bottomLabelAnchor = layout.topLabelAnchor = new Vector2(base.contentRect.xMin + 1f, layout.selectionRect.yMin - 2f);
            }
            layout.selectionLeftRect = new Rect(base.contentRect.xMin + 13f, layout.selectionRect.yMin, layout.selectionRect.xMin - 13f, layout.selectionRect.height);
            layout.selectionTopRect = new Rect(layout.selectionRect.xMin, base.contentRect.yMin + 13f, layout.selectionRect.width, layout.selectionRect.yMin - 13f);
            layout.underlayTopRect = new Rect(base.contentRect.xMin, base.contentRect.yMin, base.contentRect.width, 13f);
            layout.underlayLeftRect = new Rect(base.contentRect.xMin, base.contentRect.yMin + 13f, 13f, base.contentRect.height - 13f);
            return layout;
        }