16 private int _panelZOrder;
30 Color backgroundColor,
31 string? nickname =
null)
35 ValidateBounds(bounds).Location,
38 ArgumentNullException.ThrowIfNull(view);
45 $
"{Nickname}.background")
49 Add(
Background, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
65 Color backgroundColor,
66 string? nickname =
null)
70 ValidateBounds(bounds).Location,
73 ArgumentNullException.ThrowIfNull(sceneLayer);
80 $
"{Nickname}.background")
84 Add(
Background, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
97 ? Background.ScreenBounds
111 Background.ScreenBounds =
new Rectangle(
Background.ScreenBounds.Location, value);
113 Background.WorldBounds =
new Rectangle(
Background.WorldBounds.Location, value);
125 ArgumentNullException.ThrowIfNull(widget);
127 Point offset = offsetPx ?? Point.Empty;
131 keepCurrentOffset:
false,
132 explicitLocalOffsetPx:
new Vector2(offset.X, offset.Y));
134 SetWidgetZOrder(widget, _panelZOrder + 1);
211 SKPoint? offsetPx =
null,
212 SKFilterQuality filterQuality = SKFilterQuality.Medium)
237 SKPoint? offsetPx =
null,
238 SKFilterQuality filterQuality = SKFilterQuality.Medium)
267 _panelZOrder = zOrder;
268 Background.ZOrder = zOrder;
271 SetWidgetZOrder(widget, zOrder + 1);
276 private void RefreshBackground()
281 private void DisableInput()
289 private static Rectangle ValidateBounds(Rectangle bounds)
291 ValidateSize(bounds.Size);
295 private static void ValidateSize(
Size size)
297 if (size.Width <= 0 || size.Height <= 0)
298 throw new ArgumentOutOfRangeException(nameof(size), size,
"Panel size must be positive.");
301 private static void SetWidgetZOrder(
WidgetBase widget,
int zOrder)
303 DirectDrawingBase[] visuals = EnumerateVisuals(widget).ToArray();
305 if (visuals.Length == 0)
308 int currentMin = visuals.Min(
static visual => visual.ZOrder);
309 int delta = zOrder - currentMin;
311 foreach (DirectDrawingBase visual
in visuals)
312 visual.ZOrder += delta;
315 private static IEnumerable<DirectDrawingBase> EnumerateVisuals(IDirectCompositeContainer container)
317 foreach (IDirectCompositeChild child
in container.
Children)
319 if (child is DirectDrawingBase drawing)
320 yield
return drawing;
322 if (child is IDirectCompositeContainer nestedContainer)
324 foreach (DirectDrawingBase nestedDrawing
in EnumerateVisuals(nestedContainer))
325 yield
return nestedDrawing;
SceneLayer? SceneLayer
Gets the scene layer shared by all children in scene-layer mode.
View? View
Gets the view shared by all children in view mode.
DirectDrawingMode Mode
Gets the coordinate mode shared by the composite and its children.
Vector2 GetPosition()
Gets the current position of this direct drawing in pixel coordinates.
void SetPosition(Vector2 p)
Sets the position of this direct drawing to the specified pixel coordinates.
Renders a configurable rectangle with support for fill, border, rounded corners, dash patterns,...
DirectRectangle SetFilled(bool isFilled)
Sets whether the rectangle interior is filled with the base color (or pattern).
DirectRectangle SetStrokeWidth(float width)
Sets the width (thickness) of the rectangle's stroke (outline) in pixels.
ImageFillMode
Defines how an image fills the rectangle interior.
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
IReadOnlyCollection< IDirectCompositeChild > Children
Gets the read-only collection of child elements in this container.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
@ View
Performs direct drawing at the view level using screen-space coordinates.