File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ public class Container : Drawable
2020 /// </summary>
2121 public RenderTargetOptions RenderTargetOptions { get ; } = new RenderTargetOptions ( ) ;
2222
23+ protected override RectangleF ChildDrawRectangleMask =>
24+ RenderTargetOptions . RenderTarget . Value ? . Bounds
25+ ?? base . ChildDrawRectangleMask ;
26+
2327 /// <summary>
2428 /// A projection sprite that has the same dimension, position, rotation and parent as the container.
2529 /// It shows <see cref="RenderTarget"/>, which the container can render its entire content to
Original file line number Diff line number Diff line change @@ -76,6 +76,19 @@ public Drawable Parent
7676 /// </summary>
7777 public RectangleF ScreenRectangle { get ; private set ; } = new RectangleF ( ) ;
7878
79+ /// <summary>
80+ /// If outside this region, this will not be drawed.
81+ /// </summary>
82+ private RectangleF DrawRectangleMask { get ; set ; } =
83+ new RectangleF ( 0 , 0 , WindowManager . Width , WindowManager . Height ) ;
84+
85+ /// <summary>
86+ /// Clipping region for children. Useful to RenderTargets
87+ /// </summary>
88+ protected virtual RectangleF ChildDrawRectangleMask =>
89+ Parent ? . ChildDrawRectangleMask
90+ ?? new RectangleF ( 0 , 0 , WindowManager . Width , WindowManager . Height ) ;
91+
7992 /// <summary>
8093 /// The bounding box of the drawable relative to the entire screen.
8194 /// </summary>
@@ -584,6 +597,8 @@ protected void RecalculateRectangles()
584597 // Update AbsoluteRotation
585598 AbsoluteRotation = ( Parent ? . AbsoluteRotation ?? 0 ) + Rotation ;
586599 AbsoluteScale = ( Parent ? . AbsoluteScale ?? Vector2 . One ) * Scale ;
600+ DrawRectangleMask = Parent ? . ChildDrawRectangleMask
601+ ?? new RectangleF ( 0 , 0 , WindowManager . Width , WindowManager . Height ) ;
587602
588603 // Make it relative to the parent.
589604 var width = RelativeWidth ;
You can’t perform that action at this time.
0 commit comments