Add a ClipContents property to UIElement
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user