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)
|
_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),
|
Size = new Rect(256.0f, 128.0f),
|
||||||
|
ClipContents = false
|
||||||
};
|
};
|
||||||
|
|
||||||
// _rootFill.AddChild(_label);
|
// _rootFill.AddChild(_label);
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
|||||||
public abstract Rect MinimumSize { get; }
|
public abstract Rect MinimumSize { get; }
|
||||||
public bool Dirty => _dirty != DirtyFlags.None || _pendingDirty != DirtyFlags.None;
|
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)
|
public bool TryGetStyle(StyleSheet styleSheet, [NotNullWhen(true)] out Style? style)
|
||||||
{
|
{
|
||||||
return styleSheet.TryGet(StyleName, out style);
|
return styleSheet.TryGet(StyleName, out style);
|
||||||
@@ -109,10 +111,19 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
|||||||
public void Render(RenderSystem renderer, Style style)
|
public void Render(RenderSystem renderer, Style style)
|
||||||
{
|
{
|
||||||
RenderStyleBox(renderer, style);
|
RenderStyleBox(renderer, style);
|
||||||
|
|
||||||
|
if (ClipContents)
|
||||||
|
{
|
||||||
renderer.BeginScissored(GlobalPosition, LayoutSize);
|
renderer.BeginScissored(GlobalPosition, LayoutSize);
|
||||||
|
}
|
||||||
|
|
||||||
OnRender(renderer, style);
|
OnRender(renderer, style);
|
||||||
|
|
||||||
|
if (ClipContents)
|
||||||
|
{
|
||||||
renderer.EndScissored();
|
renderer.EndScissored();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawSize(RenderSystem renderer)
|
public void DrawSize(RenderSystem renderer)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user