From d3891688f0c6359b4bd61a9552f99bd08354c62f Mon Sep 17 00:00:00 2001 From: Saas Date: Fri, 13 Mar 2026 21:59:53 +0100 Subject: [PATCH] fix boxes positioning and remove unused constants --- Source/Editor/Surface/Archetypes/Animation.cs | 2 +- Source/Editor/Surface/Constants.cs | 14 ++------------ Source/Editor/Surface/Elements/InputBox.cs | 2 +- Source/Editor/Surface/Elements/OutputBox.cs | 4 ++-- Source/Editor/Surface/NodeElementArchetype.cs | 8 ++++---- Source/Editor/Surface/SurfaceNode.cs | 2 +- Source/Editor/Surface/SurfaceStyle.cs | 2 +- 7 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs index ad5e45611..48a54a56f 100644 --- a/Source/Editor/Surface/Archetypes/Animation.cs +++ b/Source/Editor/Surface/Archetypes/Animation.cs @@ -243,7 +243,7 @@ namespace FlaxEditor.Surface.Archetypes { Type = NodeElementType.Input, Position = new Float2( - FlaxEditor.Surface.Constants.NodeMarginX - FlaxEditor.Surface.Constants.BoxOffsetX, + FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight + ylevel * FlaxEditor.Surface.Constants.LayoutOffsetY), Text = "Pose " + _blendPoses.Count, Single = true, diff --git a/Source/Editor/Surface/Constants.cs b/Source/Editor/Surface/Constants.cs index 2945a85e9..9b857805e 100644 --- a/Source/Editor/Surface/Constants.cs +++ b/Source/Editor/Surface/Constants.cs @@ -23,7 +23,7 @@ namespace FlaxEditor.Surface /// /// The node header height. /// - public const float NodeHeaderHeight = 23.0f; + public const float NodeHeaderHeight = 25.0f; /// /// The scale of the header text. @@ -45,11 +45,6 @@ namespace FlaxEditor.Surface /// public const float NodeMarginY = 8.0f; - /// - /// The box position offset on the x axis. - /// - public const float BoxOffsetX = 0.0f; - /// /// The width of the row that is started by a box. /// @@ -68,16 +63,11 @@ namespace FlaxEditor.Surface /// /// The offset between the box text and the box /// - public const float BoxTextOffset = 2.0f; + public const float BoxTextOffset = 1.65f; /// /// The width of the rectangle used to draw the box text. /// public const float BoxTextRectWidth = 500.0f; - - /// - /// The scale of text of boxes. - /// - public const float BoxTextScale = 1f; } } diff --git a/Source/Editor/Surface/Elements/InputBox.cs b/Source/Editor/Surface/Elements/InputBox.cs index 5a4bfc31c..3e2bb4d5c 100644 --- a/Source/Editor/Surface/Elements/InputBox.cs +++ b/Source/Editor/Surface/Elements/InputBox.cs @@ -1443,7 +1443,7 @@ namespace FlaxEditor.Surface.Elements // Draw text var style = Style.Current; var rect = new Rectangle(Width + Constants.BoxTextOffset, 0, Constants.BoxTextRectWidth, Height); - Render2D.DrawText(style.FontMedium, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1f, Constants.BoxTextScale); + Render2D.DrawText(style.FontMedium, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center); } /// diff --git a/Source/Editor/Surface/Elements/OutputBox.cs b/Source/Editor/Surface/Elements/OutputBox.cs index 3e473d7ac..fa9d15c22 100644 --- a/Source/Editor/Surface/Elements/OutputBox.cs +++ b/Source/Editor/Surface/Elements/OutputBox.cs @@ -234,8 +234,8 @@ namespace FlaxEditor.Surface.Elements // Draw text var style = Style.Current; - var rect = new Rectangle(-Constants.BoxTextRectWidth - Constants.BoxTextOffset, 0, Constants.BoxTextRectWidth, Height); - Render2D.DrawText(style.FontMedium, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Far, TextAlignment.Center, TextWrapping.NoWrap, 1f, Constants.BoxTextScale); + var rect = new Rectangle(-Constants.BoxTextRectWidth - Constants.BoxTextOffset * 2f, 0f, Constants.BoxTextRectWidth, Height); + Render2D.DrawText(style.FontMedium, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Far, TextAlignment.Center); } } } diff --git a/Source/Editor/Surface/NodeElementArchetype.cs b/Source/Editor/Surface/NodeElementArchetype.cs index d8008f53f..55c8a43a7 100644 --- a/Source/Editor/Surface/NodeElementArchetype.cs +++ b/Source/Editor/Surface/NodeElementArchetype.cs @@ -106,7 +106,7 @@ namespace FlaxEditor.Surface { Type = NodeElementType.Input, Position = new Float2( - Constants.NodeMarginX - Constants.BoxOffsetX, + Constants.NodeMarginX, Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY), Text = text, Single = single, @@ -132,7 +132,7 @@ namespace FlaxEditor.Surface { Type = NodeElementType.Input, Position = new Float2( - Constants.NodeMarginX - Constants.BoxOffsetX, + Constants.NodeMarginX, Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY), Text = text, Single = single, @@ -157,7 +157,7 @@ namespace FlaxEditor.Surface { Type = NodeElementType.Output, Position = new Float2( - Constants.NodeMarginX - Constants.BoxRowHeight + Constants.BoxOffsetX, + -Constants.NodeMarginX, Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY), Text = text, Single = single, @@ -182,7 +182,7 @@ namespace FlaxEditor.Surface { Type = NodeElementType.Output, Position = new Float2( - Constants.NodeMarginX - Constants.BoxSize + Constants.BoxOffsetX, + -Constants.NodeMarginX, Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY), Text = text, Single = single, diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index deca508b1..a775d446c 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -199,7 +199,7 @@ namespace FlaxEditor.Surface { if (Elements[i] is OutputBox box) { - box.Location = box.Archetype.Position + new Float2(width, 0); + box.Location = box.Archetype.Position + new Float2(width - Constants.NodeMarginX, 0); } } diff --git a/Source/Editor/Surface/SurfaceStyle.cs b/Source/Editor/Surface/SurfaceStyle.cs index 8d547c14e..94d9b04df 100644 --- a/Source/Editor/Surface/SurfaceStyle.cs +++ b/Source/Editor/Surface/SurfaceStyle.cs @@ -222,7 +222,7 @@ namespace FlaxEditor.Surface private static void DefaultDrawBox(Elements.Box box) { - var rect = new Rectangle(0.0f, box.Height * 0.5f - Constants.BoxSize * 0.5f, new Float2(Constants.BoxSize)); + var rect = new Rectangle(box.Width * 0.5f - Constants.BoxSize * 0.5f, box.Height * 0.5f - Constants.BoxSize * 0.5f, new Float2(Constants.BoxSize)); // Size culling const float minBoxSize = 5.0f;