From 48100cf9fc4bbb577bd68c47df651e9f9d5e605d Mon Sep 17 00:00:00 2001 From: Saas Date: Mon, 13 Oct 2025 11:16:07 +0200 Subject: [PATCH] fix group element text clipping fixes group element header text clipping outside of the header and into the settings icon (if there is one). Also some extra code to handle script editor, as that displays some extra icons in the header. --- Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs | 3 ++- .../Editor/CustomEditors/Elements/Container/GroupElement.cs | 3 ++- Source/Engine/UI/GUI/Panels/DropPanel.cs | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs index 356ae5ee4..36a993e2c 100644 --- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs @@ -909,7 +909,8 @@ namespace FlaxEditor.CustomEditors.Dedicated settingsButton.Tag = script; settingsButton.Clicked += OnSettingsButtonClicked; - group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right - 12, 15, 2, 2); + // Adjust margin to not overlap with other ui elements in the header + group.Panel.HeaderTextMargin = group.Panel.HeaderTextMargin with { Left = scriptDrag.Right - 12, Right = settingsButton.Width + Utilities.Constants.UIMargin }; group.Object(values, editor); // Remove drop down arrows and containment lines if no objects in the group if (group.Children.Count == 0) diff --git a/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs b/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs index 64bc9080b..055c6a29d 100644 --- a/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs +++ b/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs @@ -44,7 +44,8 @@ namespace FlaxEditor.CustomEditors.Elements { var style = Style.Current; var settingsButtonSize = Panel.HeaderHeight; - return new Image + Panel.HeaderTextMargin = Panel.HeaderTextMargin with { Right = settingsButtonSize + Utilities.Constants.UIMargin }; +; return new Image { TooltipText = "Settings", AutoFocus = true, diff --git a/Source/Engine/UI/GUI/Panels/DropPanel.cs b/Source/Engine/UI/GUI/Panels/DropPanel.cs index 0bfa799c2..c71223cb4 100644 --- a/Source/Engine/UI/GUI/Panels/DropPanel.cs +++ b/Source/Engine/UI/GUI/Panels/DropPanel.cs @@ -361,7 +361,7 @@ namespace FlaxEngine.GUI var style = Style.Current; var enabled = EnabledInHierarchy; - // Paint Background + // Draw Background var backgroundColor = BackgroundColor; if (backgroundColor.A > 0.0f) { @@ -388,7 +388,7 @@ namespace FlaxEngine.GUI ArrowImageOpened?.Draw(dropDownRect, arrowColor); } - // Text + // Header text var textRect = new Rectangle(textLeft, 0, Width - textLeft, HeaderHeight); _headerTextMargin.ShrinkRectangle(ref textRect); var textColor = HeaderTextColor; @@ -397,7 +397,9 @@ namespace FlaxEngine.GUI textColor *= 0.6f; } + Render2D.PushClip(textRect); Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center); + Render2D.PopClip(); if (!_isClosed && EnableContainmentLines) {