diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index c18698890..763f82fdb 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -180,162 +180,6 @@ namespace FlaxEditor.Surface } } - public ContainerControl HACK = null; - - private Float2 CompareAndGetNewCollisionSize(Rectangle rect1, Rectangle rect2, float collisionWidth, float collisionHeight) - { - Rectangle sharedArea; - Rectangle.Shared(ref rect1, ref rect2, out sharedArea); - - Color colliderColor = Color.Chocolate; - colliderColor.A = 0.1f; - /*Panel colliderPanel = new Panel - { - BackgroundColor = colliderColor, - Location = sharedArea.Location, - Size = sharedArea.Size, - Parent = HACK - };*/ - - return new Float2(Mathf.Max(collisionWidth, sharedArea.Width + 4), Mathf.Max(collisionHeight, sharedArea.Height + 4)); - } - - private Float2 CalculateCollisionSize(List controls, Font boxLabelFont) - { - Debug.Log(string.Format("{0}:", Title)); - - List colliderRectangles = new List(); - int controlsCount = controls.Count; - for (int i = 0; i < controlsCount; i++) - { - var control = controls[i]; - if (!control.Visible || control is Panel panel) - continue; - - Debug.Log(string.Format("\t{0}:", control.GetType().ToString())); - Debug.Log(string.Format("\t\tControl Bounds: {0}", control.Bounds)); - /*Color colliderColor2 = Color.Crimson; - colliderColor2.A = 0.25f; - new Panel - { - BackgroundColor = colliderColor2, - Location = control.Bounds.Location, - Size = control.Bounds.Size, - Parent = HACK - }; - - if (control is InputBox inputBox2) - { - Rectangle textRect; - textRect.Size = boxLabelFont.MeasureText(inputBox2.Text); - textRect.Location = new Float2(control.Bounds.Location.X + 24, control.Bounds.Location.Y); - Debug.Log(string.Format("\t\tText Rectangle: {0}", textRect)); - - Color colliderColor3 = Color.ForestGreen; - colliderColor3.A = 0.25f; - new Panel - { - BackgroundColor = colliderColor3, - Location = textRect.Location, - Size = textRect.Size, - Parent = HACK - }; - } - - if (control is OutputBox outputBox2) - { - Rectangle textRect; - textRect.Size = boxLabelFont.MeasureText(outputBox2.Text); - textRect.Location = new Float2(control.Bounds.Location.X - textRect.Size.X - 2, control.Bounds.Location.Y); - Debug.Log(string.Format("\t\tText Rectangle: {0}", textRect)); - - Color colliderColor3 = Color.ForestGreen; - colliderColor3.A = 0.25f; - new Panel - { - BackgroundColor = colliderColor3, - Location = textRect.Location, - Size = textRect.Size, - Parent = HACK - }; - }*/ - - - - - - Float2 boxSize = GetBoxControlWidthHeight(control, boxLabelFont); - Float2 boxPosition = control.Location; - - // Special condition handling that is different than `GetBoxControlWidthHeight` - if (control is OutputBox outputBox) - { - boxPosition.X -= boxLabelFont.MeasureText(outputBox.Text).X; - boxSize.X = boxLabelFont.MeasureText(outputBox.Text).X + 20; - boxSize.Y = Mathf.Max(boxLabelFont.MeasureText(outputBox.Text).Y, outputBox.Height) + 4; - } else if (control is InputBox inputBox) - { - boxSize.X = boxLabelFont.MeasureText(inputBox.Text).X + 20; - boxSize.Y = Mathf.Max(boxLabelFont.MeasureText(inputBox.Text).Y, inputBox.Height) + 4; - } else - { - if (control.AnchorPreset == AnchorPresets.TopLeft) - { - boxSize.X = control.Right + 4 - Constants.NodeMarginX; - boxSize.Y = control.Bottom - control.Top + 4 - Constants.NodeMarginY - Constants.NodeHeaderSize; - boxPosition.Y = control.Top; - } - else - { - boxSize.X = control.Width + 4; - boxSize.Y = control.Height + 4; - } - } - - Rectangle controlRect = new Rectangle(boxPosition.X, boxPosition.Y, boxSize.X, boxSize.Y); - colliderRectangles.Add(controlRect); - - Color colliderColor = Style.Current.BackgroundSelected; - colliderColor.A = 0.25f; - /*Panel colliderPanel = new Panel - { - BackgroundColor = colliderColor, - Location = controlRect.Location, - Size = controlRect.Size, - Parent = HACK - };*/ - } - - float collisionWidth = 0; - float collisionHeight = 0; - for (int i = 0; i < colliderRectangles.Count; i++) - { - for (int j = 0; j < colliderRectangles.Count; j++) - { - if (i == j) - { - continue; - } - - Rectangle rect1 = colliderRectangles[i]; - Rectangle rect2 = colliderRectangles[j]; - Float2 newCollisionSize = CompareAndGetNewCollisionSize(rect1, rect2, collisionWidth, collisionHeight); - - collisionWidth = newCollisionSize.X; - collisionHeight = newCollisionSize.Y; - } - } - - return new Float2(collisionWidth, collisionHeight); - } - - //HACK - private Color alphainator(Color color, float alpha) - { - color.A = alpha; - return color; - } - private Float2 GetBoxControlWidthHeight(Control control, Font boxLabelFont) { float boxWidth = 0; @@ -376,7 +220,6 @@ namespace FlaxEditor.Surface { if (Surface == null) return; - HACK = this; var width = 0.0f; var height = 0.0f; var leftHeight = 0.0f; @@ -417,25 +260,6 @@ namespace FlaxEditor.Surface width = Mathf.Max(width, leftWidth + rightWidth + 10); width = Mathf.Max(width, titleLabelFont.MeasureText(Title).X + 30); height = Mathf.Max(height, Mathf.Max(leftHeight, rightHeight)); - - new Panel - { - BackgroundColor = alphainator(Color.Azure, 0.25f), - Size = new Float2(leftWidth, height), - AnchorPreset = AnchorPresets.TopLeft, - Location = new Float2(4f, Constants.NodeHeaderSize + 4), - Parent = HACK - }; - - new Panel - { - BackgroundColor = alphainator(Color.Crimson, 0.25f), - Size = new Float2(rightWidth, height), - AnchorPreset = AnchorPresets.TopRight, - Location = new Float2(-4-rightWidth, Constants.NodeHeaderSize + 4), - Parent = HACK - }; - Float2 roundedSize = VisjectSurface.RoundToGrid(new Float2(width, height), ceil: true); Resize(roundedSize.X, roundedSize.Y); }