19 private int _pageZOrder;
20 private string _title;
31 internal TabPageWidget(
34 Rectangle contentBounds,
41 ValidateBounds(contentBounds).Location,
44 ArgumentNullException.ThrowIfNull(view);
46 _title = ValidateTitle(title);
50 DefaultBackgroundColor,
54 $
"{Nickname}.background")
73 internal TabPageWidget(
76 Rectangle contentBounds,
83 ValidateBounds(contentBounds).Location,
86 ArgumentNullException.ThrowIfNull(sceneLayer);
88 _title = ValidateTitle(title);
92 DefaultBackgroundColor,
96 $
"{Nickname}.background")
125 ? Background.ScreenBounds
141 Point? offsetPx =
null)
143 ArgumentNullException.ThrowIfNull(widget);
145 Point offset = offsetPx ?? Point.Empty;
149 keepCurrentOffset:
false,
150 explicitLocalOffsetPx:
new Vector2(offset.X, offset.Y));
152 SetWidgetZOrder(widget, _pageZOrder + 1);
165 bool dispose =
false)
178 string validatedTitle = ValidateTitle(title);
180 if (
string.Equals(_title, validatedTitle, StringComparison.Ordinal))
183 _title = validatedTitle;
184 TitleChanged?.Invoke(
this);
220 throw new ArgumentOutOfRangeException(nameof(width),
"The page border width cannot be negative.");
235 throw new ArgumentOutOfRangeException(nameof(radius),
"The page corner radius cannot be negative.");
255 SKPoint? offsetPx =
null,
256 SKFilterQuality filterQuality = SKFilterQuality.Medium)
281 SKPoint? offsetPx =
null,
282 SKFilterQuality filterQuality = SKFilterQuality.Medium)
307 internal event Action<TabPageWidget>? TitleChanged;
313 internal void SetContentBounds(Rectangle bounds)
315 ValidateBounds(bounds);
327 internal void SetPageZOrder(
int zOrder)
329 _pageZOrder = zOrder;
330 Background.ZOrder = zOrder;
333 SetWidgetZOrder(widget, zOrder + 1);
336 private const int DefaultBackgroundAlpha = 235;
338 private static readonly Color DefaultBackgroundColor = Color.FromArgb(
339 DefaultBackgroundAlpha,
344 private static readonly Color DefaultBorderColor = Color.FromArgb(
350 private void DisablePageInput()
358 private void RefreshBackground()
363 private static Rectangle ValidateBounds(Rectangle bounds)
365 if (bounds.Width <= 0 || bounds.Height <= 0)
367 throw new ArgumentOutOfRangeException(
370 "Tab-page bounds must have positive width and height.");
376 private static string ValidateTitle(
string title)
378 ArgumentException.ThrowIfNullOrWhiteSpace(title);
382 private static void SetWidgetZOrder(
386 DirectDrawingBase[] visuals = EnumerateVisuals(widget).ToArray();
388 if (visuals.Length == 0)
391 int currentMinimum = visuals.Min(
static visual => visual.ZOrder);
392 int delta = zOrder - currentMinimum;
394 foreach (DirectDrawingBase visual
in visuals)
395 visual.ZOrder += delta;
398 private static IEnumerable<DirectDrawingBase> EnumerateVisuals(IDirectCompositeContainer container)
400 foreach (IDirectCompositeChild child
in container.
Children)
402 if (child is DirectDrawingBase drawing)
403 yield
return drawing;
405 if (child is IDirectCompositeContainer nestedContainer)
407 foreach (DirectDrawingBase nestedDrawing
in EnumerateVisuals(nestedContainer))
408 yield
return nestedDrawing;
DirectDrawingMode Mode
Gets the coordinate mode shared by the composite and its children.
Rectangle WorldBounds
Gets or sets the world-space bounds of this direct drawing in pixels.
Rectangle ScreenBounds
Gets or sets the screen-space bounds of this direct drawing in pixels.
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 SetBorderColor(Color color)
Sets a distinct border (stroke) color, independent of the fill color.
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 ...
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Represents a single layer within a Scene, containing a grid of tiles and supporting various coordinat...
Rectangle ContentBounds
Gets the page's content bounds in its native coordinate space.
TabPageWidget SetStrokeWidth(float width)
Sets the page border width.
TabPageWidget AddWidget(WidgetBase widget, Point? offsetPx=null)
Adds a widget at an offset from the page content area's upper-left corner.
TabPageWidget SetCornerRadius(float radius)
Sets the page corner radius.
Rectangle HeaderBounds
Gets the bounds occupied by this page's tab header in its native coordinate space.
TabPageWidget SetBackgroundImage(SKBitmap bitmap, DirectRectangle.ImageFillMode mode=DirectRectangle.ImageFillMode.Stretch, float scale=1f, SKPoint? offsetPx=null, SKFilterQuality filterQuality=SKFilterQuality.Medium)
Uses a bitmap as the page background.
DirectRectangle Background
Gets the direct rectangle used for this page's content background.
TabPageWidget SetBackgroundColor(Color color)
Sets the page background fill color.
TabPageWidget SetBackgroundImage(SKImage image, DirectRectangle.ImageFillMode mode=DirectRectangle.ImageFillMode.Stretch, float scale=1f, SKPoint? offsetPx=null, SKFilterQuality filterQuality=SKFilterQuality.Medium)
Uses an image as the page background.
TabPageWidget ClearBackgroundImage()
Removes an image background and restores the configured color fill.
char? Mnemonic
Gets the optional Alt-key mnemonic that selects this page.
TabPageWidget RemoveWidget(WidgetBase widget, bool dispose=false)
Removes a child widget from the page.
TabPageWidget SetTitle(string title)
Changes the title displayed by the owning tab control.
string Title
Gets the title displayed by the page's tab header.
TabPageWidget SetBorderColor(Color color)
Sets the page border color.
IReadOnlyCollection< IDirectCompositeChild > Children
Gets the read-only collection of child elements in this container.
@ Rectangle
Particles are spawned uniformly within a rectangular area. This is the default distribution.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
@ View
Performs direct drawing at the view level using screen-space coordinates.