19 private int _pageZOrder;
20 private string _title;
33 Rectangle contentBounds,
37 : base(renderSurfaceHost,
DirectDrawingMode.View, ValidateBounds(contentBounds).Location, nickname)
39 ArgumentNullException.ThrowIfNull(view);
41 _title = ValidateTitle(title);
48 $
"{Nickname}.background")
69 Rectangle contentBounds,
73 : base(renderSurfaceHost,
DirectDrawingMode.SceneLayer, ValidateBounds(contentBounds).Location, nickname)
75 ArgumentNullException.ThrowIfNull(sceneLayer);
77 _title = ValidateTitle(title);
84 $
"{Nickname}.background")
113 ? Background.ScreenBounds
128 Point? offsetPx =
null)
130 ArgumentNullException.ThrowIfNull(widget);
132 Point offset = offsetPx ?? Point.Empty;
134 keepCurrentOffset:
false,
135 explicitLocalOffsetPx:
new Vector2(offset.X, offset.Y));
136 SetWidgetZOrder(widget, _pageZOrder + 1);
148 bool dispose =
false)
161 string validatedTitle = ValidateTitle(title);
162 if (
string.Equals(_title, validatedTitle, StringComparison.Ordinal))
165 _title = validatedTitle;
166 TitleChanged?.Invoke(
this);
202 throw new ArgumentOutOfRangeException(nameof(width),
"The page border width cannot be negative.");
217 throw new ArgumentOutOfRangeException(nameof(radius),
"The page corner radius cannot be negative.");
236 SKPoint? offsetPx =
null,
237 SKFilterQuality filterQuality = SKFilterQuality.Medium)
239 Background.SetFillImage(bitmap, mode, scale, offsetPx, filterQuality);
255 SKPoint? offsetPx =
null,
256 SKFilterQuality filterQuality = SKFilterQuality.Medium)
258 Background.SetFillImage(image, mode, scale, offsetPx, filterQuality);
275 internal event Action<TabPageWidget>? TitleChanged;
281 internal void SetContentBounds(Rectangle bounds)
283 ValidateBounds(bounds);
295 internal void SetPageZOrder(
int zOrder)
297 _pageZOrder = zOrder;
298 Background.ZOrder = zOrder;
301 SetWidgetZOrder(widget, zOrder + 1);
304 private const int DefaultBackgroundAlpha = 235;
306 private static readonly Color DefaultBackgroundColor = Color.FromArgb(DefaultBackgroundAlpha, 25, 28, 36);
307 private static readonly Color DefaultBorderColor = Color.FromArgb(255, 110, 120, 140);
309 private void DisablePageInput()
317 private void RefreshBackground()
322 private static Rectangle ValidateBounds(Rectangle bounds)
324 if (bounds.Width <= 0 || bounds.Height <= 0)
326 throw new ArgumentOutOfRangeException(
329 "Tab-page bounds must have positive width and height.");
335 private static string ValidateTitle(
string title)
337 ArgumentException.ThrowIfNullOrWhiteSpace(title);
341 private static void SetWidgetZOrder(
WidgetBase widget,
344 DirectDrawingBase[] visuals = EnumerateVisuals(widget).ToArray();
345 if (visuals.Length == 0)
348 int currentMinimum = visuals.Min(
static visual => visual.ZOrder);
349 int delta = zOrder - currentMinimum;
351 foreach (DirectDrawingBase visual
in visuals)
352 visual.ZOrder += delta;
355 private static IEnumerable<DirectDrawingBase> EnumerateVisuals(IDirectCompositeContainer container)
357 foreach (IDirectCompositeChild child
in container.
Children)
359 if (child is DirectDrawingBase drawing)
360 yield
return drawing;
362 if (child is IDirectCompositeContainer nestedContainer)
364 foreach (DirectDrawingBase nestedDrawing
in EnumerateVisuals(nestedContainer))
365 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.