16 private int _panelZOrder;
29 Color backgroundColor,
30 string? nickname =
null)
33 ArgumentNullException.ThrowIfNull(view);
39 Add(
Background, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
54 Color backgroundColor,
55 string? nickname =
null)
58 ArgumentNullException.ThrowIfNull(sceneLayer);
64 Add(
Background, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
77 ? Background.ScreenBounds
91 Background.ScreenBounds =
new Rectangle(
Background.ScreenBounds.Location, value);
93 Background.WorldBounds =
new Rectangle(
Background.WorldBounds.Location, value);
105 ArgumentNullException.ThrowIfNull(widget);
107 Point offset = offsetPx ?? Point.Empty;
109 keepCurrentOffset:
false,
110 explicitLocalOffsetPx:
new Vector2(offset.X, offset.Y));
111 SetWidgetZOrder(widget, _panelZOrder + 1);
187 SKPoint? offsetPx =
null,
188 SKFilterQuality filterQuality = SKFilterQuality.Medium)
190 Background.SetFillImage(bitmap, mode, scale, offsetPx, filterQuality);
206 SKPoint? offsetPx =
null,
207 SKFilterQuality filterQuality = SKFilterQuality.Medium)
209 Background.SetFillImage(image, mode, scale, offsetPx, filterQuality);
230 _panelZOrder = zOrder;
231 Background.ZOrder = zOrder;
234 SetWidgetZOrder(widget, zOrder + 1);
239 private void RefreshBackground()
244 private void DisableInput()
252 private static Rectangle ValidateBounds(Rectangle bounds)
254 ValidateSize(bounds.Size);
258 private static void ValidateSize(
Size size)
260 if (size.Width <= 0 || size.Height <= 0)
261 throw new ArgumentOutOfRangeException(nameof(size), size,
"Panel size must be positive.");
264 private static void SetWidgetZOrder(
WidgetBase widget,
int zOrder)
266 DirectDrawingBase[] visuals = EnumerateVisuals(widget).ToArray();
267 if (visuals.Length == 0)
270 int currentMin = visuals.Min(
static visual => visual.ZOrder);
271 int delta = zOrder - currentMin;
273 foreach (DirectDrawingBase visual
in visuals)
274 visual.ZOrder += delta;
277 private static IEnumerable<DirectDrawingBase> EnumerateVisuals(IDirectCompositeContainer container)
279 foreach (IDirectCompositeChild child
in container.
Children)
281 if (child is DirectDrawingBase drawing)
282 yield
return drawing;
284 if (child is IDirectCompositeContainer nestedContainer)
286 foreach (DirectDrawingBase nestedDrawing
in EnumerateVisuals(nestedContainer))
287 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.