From 7b6fb71e1efcd4b9066cb15474800dbfa2813331 Mon Sep 17 00:00:00 2001 From: dnesov Date: Tue, 2 Jun 2026 02:03:50 +0200 Subject: [PATCH] Add a ClipContents property to UIElement --- TestGame/TestGame.cs | 1 + Voile/Source/UI/UIElement.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs index dff9036..70a1f01 100644 --- a/TestGame/TestGame.cs +++ b/TestGame/TestGame.cs @@ -107,6 +107,7 @@ public class TestGame : Game _label = new Label("What the heck??? Word wrapping!!! That's crazy... Noooo wayyy Before GTA 6 too!!!\nnewline :)", _defaultFontSet) { Size = new Rect(256.0f, 128.0f), + ClipContents = false }; // _rootFill.AddChild(_label); diff --git a/Voile/Source/UI/UIElement.cs b/Voile/Source/UI/UIElement.cs index 8a43901..397c4af 100644 --- a/Voile/Source/UI/UIElement.cs +++ b/Voile/Source/UI/UIElement.cs @@ -65,6 +65,8 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme public abstract Rect MinimumSize { get; } public bool Dirty => _dirty != DirtyFlags.None || _pendingDirty != DirtyFlags.None; + public bool ClipContents { get; set; } = true; + public bool TryGetStyle(StyleSheet styleSheet, [NotNullWhen(true)] out Style? style) { return styleSheet.TryGet(StyleName, out style); @@ -109,9 +111,18 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme public void Render(RenderSystem renderer, Style style) { RenderStyleBox(renderer, style); - renderer.BeginScissored(GlobalPosition, LayoutSize); + + if (ClipContents) + { + renderer.BeginScissored(GlobalPosition, LayoutSize); + } + OnRender(renderer, style); - renderer.EndScissored(); + + if (ClipContents) + { + renderer.EndScissored(); + } } public void DrawSize(RenderSystem renderer)