16 private bool _isPointerOver;
18 private bool _isMenuBarActive;
20 internal event Action<MenuHeaderWidget>? Invoked;
21 internal event Action<MenuHeaderWidget>? Hovered;
23 internal MenuHeaderWidget(
29 string? nickname =
null,
30 char? mnemonic =
null)
38 _theme = theme ??
throw new ArgumentNullException(nameof(theme));
39 Text = text ??
throw new ArgumentNullException(nameof(text));
42 _theme.HeaderNormalColor,
46 $
"{Nickname}.background")
56 .
SetFont(SKTypeface.Default, _theme.FontSize, _theme.MinimumFontSize)
57 .
SetColors(ToSkColor(_theme.TextColor), SKColors.Transparent)
73 public string Text {
get;
private set; }
87 public MenuHeaderWidget
SetText(
string text)
89 Text = text ??
throw new ArgumentNullException(nameof(text));
94 internal void SetOpen(
bool isOpen)
100 internal void SetMenuBarActive(
bool isActive)
102 _isMenuBarActive = isActive;
105 internal void SetHeaderZOrder(
int zOrder)
107 Background.ZOrder = zOrder;
108 Label.ZOrder = zOrder + 1;
111 internal void SetBounds(Rectangle bounds)
115 Background.ScreenBounds =
new Rectangle(
119 Label.ScreenBounds =
new Rectangle(
127 base.OnPointerEnter(args);
128 _isPointerOver =
true;
130 Hovered?.Invoke(
this);
136 base.OnPointerLeave(args);
137 _isPointerOver =
false;
144 base.OnPointerDown(args);
147 SetBackgroundColor(_theme.HeaderPressedColor);
153 base.OnPointerUp(args);
160 base.OnPointerClick(args);
166 Invoked?.Invoke(
this);
172 base.OnKeyboardInput(args);
179 if (_isMenuBarActive)
183 if (args.
Key is not 13 and not 32 and not 40)
187 Invoked?.Invoke(
this);
190 private void UpdateVisualState()
192 Color color = _isOpen
193 ? _theme.HeaderOpenColor
195 ? _theme.HeaderHoverColor
196 : _theme.HeaderNormalColor;
198 SetBackgroundColor(color);
201 private void SetBackgroundColor(Color color)
207 private static SKColor ToSkColor(Color color)
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.