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)