From 9caf80bdc98658345ac020ffc8d43ab92c07cfe7 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Fri, 5 Aug 2022 14:38:18 +0200 Subject: [PATCH] Add option to disable text clipping in text boxes --- Source/Engine/UI/GUI/Common/RichTextBoxBase.cs | 6 ++++-- Source/Engine/UI/GUI/Common/TextBox.cs | 6 ++++-- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index eb83d2a55..bfddc966c 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -235,7 +235,8 @@ namespace FlaxEngine.GUI Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor); // Apply view offset and clip mask - Render2D.PushClip(TextClipRectangle); + if (ClipText) + Render2D.PushClip(TextClipRectangle); bool useViewOffset = !_viewOffset.IsZero; if (useViewOffset) Render2D.PushTransform(Matrix3x3.Translation2D(-_viewOffset)); @@ -355,7 +356,8 @@ namespace FlaxEngine.GUI // Restore rendering state if (useViewOffset) Render2D.PopTransform(); - Render2D.PopClip(); + if (ClipText) + Render2D.PopClip(); } /// diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs index a9ef5a72f..77ca2a258 100644 --- a/Source/Engine/UI/GUI/Common/TextBox.cs +++ b/Source/Engine/UI/GUI/Common/TextBox.cs @@ -158,7 +158,8 @@ namespace FlaxEngine.GUI Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor); // Apply view offset and clip mask - Render2D.PushClip(TextClipRectangle); + if (ClipText) + Render2D.PushClip(TextClipRectangle); bool useViewOffset = !_viewOffset.IsZero; if (useViewOffset) Render2D.PushTransform(Matrix3x3.Translation2D(-_viewOffset)); @@ -226,7 +227,8 @@ namespace FlaxEngine.GUI // Restore rendering state if (useViewOffset) Render2D.PopTransform(); - Render2D.PopClip(); + if (ClipText) + Render2D.PopClip(); } /// diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 7651f5031..d4fc42d39 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -192,6 +192,12 @@ namespace FlaxEngine.GUI } } + /// + /// Gets or sets a value indicating whether apply clipping mask on text during rendering. + /// + [EditorOrder(529)] + public bool ClipText { get; set; } = true; + /// /// Gets or sets textbox background color when the control is selected (has focus). ///