20 private readonly
View _view;
22 private int _pointerOffsetPx = 12;
35 string? nickname =
null)
38 ArgumentNullException.ThrowIfNull(view);
43 Rectangle bounds =
new(Point.Empty, size);
46 Color.FromArgb(238, 30, 30, 36),
50 $
"{Nickname}.background")
62 .
SetFont(SKTypeface.Default, 14f, minSize: 11f)
63 .
SetColors(SKColors.White, SKColors.Transparent)
68 Add(
Background, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
69 Add(
Label, keepCurrentOffset:
false, explicitLocalOffsetPx: Vector2.Zero);
93 (
int)MathF.Round(position.X),
94 (
int)MathF.Round(position.Y),
108 ApplyBounds(
new Rectangle(
Bounds.Location, value));
115 get => _pointerOffsetPx;
116 set => _pointerOffsetPx = value >= 0
118 :
throw new ArgumentOutOfRangeException(nameof(value));
129 ArgumentNullException.ThrowIfNull(text);
132 ApplyBounds(ResolveBounds(screenPositionPx));
155 Background.ZOrder = zOrder;
156 Label.ZOrder = zOrder + 1;
160 private Rectangle ResolveBounds(Point pointer)
162 Rectangle viewport = _view.Viewport.TargetRectPx;
167 if (x + _size.Width > viewport.Right)
169 if (y + _size.Height > viewport.Bottom)
175 Math.Max(viewport.Left, viewport.Right - _size.Width));
179 Math.Max(viewport.Top, viewport.Bottom - _size.Height));
181 return new Rectangle(x, y, _size.Width, _size.Height);
184 private void ApplyBounds(Rectangle bounds)
187 Background.ScreenBounds = bounds;
188 Label.ScreenBounds = bounds;
191 private static void ValidateSize(
Size size)
193 if (size.Width <= 0 || size.Height <= 0)
194 throw new ArgumentOutOfRangeException(nameof(size), size,
"Tooltip size must be positive.");
bool Visible
Gets or sets the visibility of all descendants.
DirectComposite SetIsVisible(bool visible)
Applies one visibility value to every descendant.
View? View
Gets the view shared by all children in view mode.
Vector2 GetPosition()
Gets the current composite anchor.
virtual DirectComposite Add(IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
Adds a composite-compatible direct drawable as a child.
void SetPosition(Vector2 position)
Sets the composite anchor and repositions all children from their stored offsets.
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.
StrokeAlign
Defines how the stroke (outline) is positioned relative to the rectangle's boundary.
DirectRectangle SetStrokeWidth(float width)
Sets the width (thickness) of the rectangle's stroke (outline) in pixels.
DirectRectangle SetCornerRadius(float radius)
Sets the radius for rounded corners in pixels.
DirectRectangle SetStrokeAlign(StrokeAlign align)
Sets how the rectangle's stroke is positioned relative to its bounds.
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
TextBlock SetFont(SKTypeface typeface, float size, float? minSize=null)
Sets the font face and size (and optional minimum size for auto-shrink).
TextBlock EnableWrapping(bool enable=true)
Enables or disables word wrapping when laying out paragraphs.
TextBlock SetAlignment(SKTextAlign h, VerticalAlign v)
Sets the horizontal and vertical alignment used when drawing the laid-out lines within the bounds.
TextBlock SetPadding(float horizontal, float vertical)
Sets symmetric horizontal and vertical padding and invalidates cached layout.
VerticalAlign
Vertical alignment options for multi-line text within the control's bounds.
TextBlock SetColors(SKColor fg, SKColor bg)
Sets the foreground (text) and background colors using Skia colors.
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.