16 private bool _isPointerOver;
18 private bool _isMenuBarActive;
20 internal event Action<MenuHeaderWidget>? Invoked;
21 internal event Action<MenuHeaderWidget>? Hovered;
28 string? nickname =
null,
char? mnemonic =
null)
32 _theme = theme ??
throw new ArgumentNullException(nameof(theme));
33 Text = text ??
throw new ArgumentNullException(nameof(text));
36 _theme.HeaderNormalColor,
40 $
"{Nickname}.background")
50 .
SetFont(SKTypeface.Default, _theme.FontSize, _theme.MinimumFontSize)
51 .
SetColors(ToSkColor(_theme.TextColor), SKColors.Transparent)
67 public string Text {
get;
private set; }
81 public MenuHeaderWidget
SetText(
string text)
83 Text = text ??
throw new ArgumentNullException(nameof(text));
88 internal void SetOpen(
bool isOpen)
94 internal void SetMenuBarActive(
bool isActive)
96 _isMenuBarActive = isActive;
99 internal void SetHeaderZOrder(
int zOrder)
101 Background.ZOrder = zOrder;
102 Label.ZOrder = zOrder + 1;
105 internal void SetBounds(Rectangle bounds)
109 Background.ScreenBounds =
new Rectangle(
113 Label.ScreenBounds =
new Rectangle(
121 base.OnPointerEnter(args);
122 _isPointerOver =
true;
124 Hovered?.Invoke(
this);
130 base.OnPointerLeave(args);
131 _isPointerOver =
false;
138 base.OnPointerDown(args);
141 SetBackgroundColor(_theme.HeaderPressedColor);
147 base.OnPointerUp(args);
154 base.OnPointerClick(args);
160 Invoked?.Invoke(
this);
166 base.OnKeyboardInput(args);
173 if (_isMenuBarActive)
177 if (args.
Key is not 13 and not 32 and not 40)
181 Invoked?.Invoke(
this);
184 private void UpdateVisualState()
186 Color color = _isOpen
187 ? _theme.HeaderOpenColor
189 ? _theme.HeaderHoverColor
190 : _theme.HeaderNormalColor;
192 SetBackgroundColor(color);
195 private void SetBackgroundColor(Color color)
201 private static SKColor ToSkColor(Color color)
203 return new SKColor(color.R, color.G, color.B, color.A);
View? View
Gets the view shared by all children in view mode.
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.
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 SetColor(Color color)
Sets the base color used for both fill and stroke (unless a distinct border color is specified).
DirectRectangle SetStrokeWidth(float width)
Sets the width (thickness) of the rectangle's stroke (outline) in pixels.
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.
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.
TextBlock SetText(string text)
Sets the current text content and rebuilds layout as needed. If no reveal animation is active,...
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.