Gondwana Game Engine Development (master) - 2.7.0
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
LabelWidget.cs
1using System.Drawing;
2using System.Numerics;
7using SkiaSharp;
8
10
14public sealed class LabelWidget : WidgetBase
15{
16 private const int ScrollBarWidth = 12;
17 private const int ScrollBarMargin = 3;
18 private const int MinimumScrollBarThumbHeight = 18;
19
20 private SKColor _foregroundColor = SKColors.White;
21 private SKColor _backgroundColor = SKColors.Transparent;
22 private string _text;
23 private Size _size;
24 private ScrollBarVisibility _verticalScrollBarVisibility = ScrollBarVisibility.Never;
25 private int _mouseWheelScrollPixels = 48;
26 private float _verticalScrollOffsetPx;
27 private float _verticalScrollEndPaddingPx;
28 private float _maximumVerticalScrollOffsetPx;
29 private bool _isDraggingScrollBarThumb;
30 private float _scrollBarDragOffset;
31 private int? _scrollBarPointerId;
32
42 RenderSurfaceHostBase renderSurfaceHost,
43 View view,
44 Rectangle bounds,
45 string text = "",
46 string? nickname = null)
47 : base(
48 renderSurfaceHost,
50 ValidateBounds(bounds).Location,
51 nickname)
52 {
53 ArgumentNullException.ThrowIfNull(view);
54
55 _text = text ?? string.Empty;
56 _size = bounds.Size;
57
58 TextBlock = new TextBlock(
59 renderSurfaceHost,
60 view,
61 bounds,
62 $"{Nickname}.text")
63 .SetText(_text)
64 .SetColors(_foregroundColor, _backgroundColor);
65
66 VerticalScrollBarTrack = CreateScrollBarTrack(renderSurfaceHost, view, bounds);
67 VerticalScrollBarThumb = CreateScrollBarThumb(renderSurfaceHost, view, bounds);
68
69 Add(TextBlock, keepCurrentOffset: false, explicitLocalOffsetPx: Vector2.Zero);
72 CompleteInitialization();
73 }
74
84 RenderSurfaceHostBase renderSurfaceHost,
85 SceneLayer sceneLayer,
86 Rectangle bounds,
87 string text = "",
88 string? nickname = null)
89 : base(
90 renderSurfaceHost,
92 ValidateBounds(bounds).Location,
93 nickname)
94 {
95 ArgumentNullException.ThrowIfNull(sceneLayer);
96
97 _text = text ?? string.Empty;
98 _size = bounds.Size;
99
100 TextBlock = new TextBlock(
101 renderSurfaceHost,
102 sceneLayer,
103 view: null,
104 worldBounds: bounds,
105 nickname: $"{Nickname}.text")
106 .SetText(_text)
107 .SetColors(_foregroundColor, _backgroundColor);
108
109 VerticalScrollBarTrack = CreateScrollBarTrack(renderSurfaceHost, sceneLayer, bounds);
110 VerticalScrollBarThumb = CreateScrollBarThumb(renderSurfaceHost, sceneLayer, bounds);
111
112 Add(TextBlock, keepCurrentOffset: false, explicitLocalOffsetPx: Vector2.Zero);
115 CompleteInitialization();
116 }
117
121 public TextBlock TextBlock { get; }
122
125
128
132 public string Text => _text;
133
137 public Rectangle Bounds
138 {
139 get
140 {
141 Vector2 position = GetPosition();
142
143 return new Rectangle(
144 (int)MathF.Round(position.X),
145 (int)MathF.Round(position.Y),
146 _size.Width,
147 _size.Height);
148 }
149 }
150
154 public Size Size
155 {
156 get => Bounds.Size;
157 set
158 {
159 ValidateSize(value);
160 _size = value;
161 RefreshScrollState();
162 }
163 }
164
172 {
173 get => _verticalScrollBarVisibility;
174 set
175 {
176 if (!Enum.IsDefined(value))
177 throw new ArgumentOutOfRangeException(nameof(value));
178
179 if (_verticalScrollBarVisibility == value)
180 return;
181
182 _verticalScrollBarVisibility = value;
183 RefreshScrollState();
184 }
185 }
186
188 public bool IsVerticalScrollBarVisible => Visible && NeedsVerticalScrollBar;
189
192 {
193 get => _mouseWheelScrollPixels;
194 set => _mouseWheelScrollPixels = value > 0
195 ? value
196 : throw new ArgumentOutOfRangeException(
197 nameof(value),
198 "Mouse-wheel scrolling must advance at least one pixel.");
199 }
200
210 {
211 get => _verticalScrollEndPaddingPx;
212 set
213 {
214 if (!float.IsFinite(value) || value < 0f)
215 throw new ArgumentOutOfRangeException(nameof(value));
216
217 if (Math.Abs(_verticalScrollEndPaddingPx - value) < 0.001f)
218 return;
219
220 _verticalScrollEndPaddingPx = value;
222 RefreshScrollState();
223 }
224 }
225
228 {
229 get => _verticalScrollOffsetPx;
230 set
231 {
232 if (!float.IsFinite(value) || value < 0f)
233 throw new ArgumentOutOfRangeException(nameof(value));
234
235 SetVerticalScrollOffset(value);
236 }
237 }
238
240 public float MaximumVerticalScrollOffsetPx => _maximumVerticalScrollOffsetPx;
241
247 public LabelWidget SetText(string text)
248 {
249 _text = text ?? string.Empty;
250 TextBlock.SetText(_text);
251 RefreshScrollState();
252 return this;
253 }
254
262 public LabelWidget SetFont(SKTypeface typeface, float size, float? minSize = null)
263 {
264 ArgumentNullException.ThrowIfNull(typeface);
265 TextBlock.SetFont(typeface, size, minSize);
266 RefreshScrollState();
267 return this;
268 }
269
276 public LabelWidget SetColors(SKColor foreground, SKColor background)
277 {
278 _foregroundColor = foreground;
279 _backgroundColor = background;
280 TextBlock.SetColors(_foregroundColor, _backgroundColor);
281 return this;
282 }
283
289 public LabelWidget SetTextColor(SKColor color)
290 {
291 _foregroundColor = color;
292 TextBlock.SetColors(_foregroundColor, _backgroundColor);
293 return this;
294 }
295
301 public LabelWidget SetBackgroundColor(SKColor color)
302 {
303 _backgroundColor = color;
304 TextBlock.SetColors(_foregroundColor, _backgroundColor);
305 return this;
306 }
307
314 public LabelWidget SetAlignment(SKTextAlign horizontal, TextBlock.VerticalAlign vertical)
315 {
316 TextBlock.SetAlignment(horizontal, vertical);
317 return this;
318 }
319
325 public LabelWidget EnableWrapping(bool enabled = true)
326 {
327 TextBlock.EnableWrapping(enabled);
328 RefreshScrollState();
329 return this;
330 }
331
338 public LabelWidget SetPadding(float horizontal, float vertical)
339 {
340 if (!float.IsFinite(horizontal) || horizontal < 0f)
341 throw new ArgumentOutOfRangeException(nameof(horizontal));
342
343 if (!float.IsFinite(vertical) || vertical < 0f)
344 throw new ArgumentOutOfRangeException(nameof(vertical));
345
346 TextBlock.SetPadding(horizontal, vertical);
347 RefreshScrollState();
348 return this;
349 }
350
354 public LabelWidget SetLabelZOrder(int zOrder)
355 {
356 TextBlock.ZOrder = zOrder;
357 VerticalScrollBarTrack.ZOrder = zOrder + 1;
358 VerticalScrollBarThumb.ZOrder = zOrder + 2;
359 return this;
360 }
361
363 protected override void ProcessShown()
364 {
365 base.ProcessShown();
366 RefreshScrollState();
367 }
368
370 protected override void ProcessHidden()
371 {
372 _isDraggingScrollBarThumb = false;
373 _scrollBarPointerId = null;
374 base.ProcessHidden();
375 }
376
378 protected override void OnPointerDown(WidgetPointerEventArgs args)
379 {
380 base.OnPointerDown(args);
381
382 if (_scrollBarPointerId.HasValue || !args.IsPrimaryButton || !IsVerticalScrollBarVisible)
383 return;
384
385 PointF local = GetLocalPointerPosition(args);
386 Rectangle trackBounds = GetScrollBarTrackBounds();
387 Rectangle thumbBounds = GetScrollBarThumbBounds();
388
389 if (!trackBounds.Contains(Point.Round(local)))
390 return;
391
392 args.Handled = true;
393 _scrollBarPointerId = args.PointerId;
394
395 if (thumbBounds.Contains(Point.Round(local)))
396 {
397 _isDraggingScrollBarThumb = true;
398 _scrollBarDragOffset = local.Y - thumbBounds.Top;
399 return;
400 }
401
402 float page = Math.Max(1f, GetViewportContentHeight());
403 SetVerticalScrollOffset(_verticalScrollOffsetPx + (local.Y < thumbBounds.Top ? -page : page));
404 }
405
407 protected override void OnPointerMove(WidgetPointerEventArgs args)
408 {
409 base.OnPointerMove(args);
410
411 if (!_isDraggingScrollBarThumb ||
412 _scrollBarPointerId != args.PointerId ||
414 {
415 return;
416 }
417
418 Rectangle trackBounds = GetScrollBarTrackBounds();
419 Rectangle thumbBounds = GetScrollBarThumbBounds();
420 float travel = trackBounds.Height - thumbBounds.Height;
421 float maximumScroll = _maximumVerticalScrollOffsetPx;
422
423 if (travel <= 0f || maximumScroll <= 0f)
424 return;
425
426 float desiredTop = GetLocalPointerPosition(args).Y - _scrollBarDragOffset;
427 float fraction = Math.Clamp((desiredTop - trackBounds.Top) / travel, 0f, 1f);
428 SetVerticalScrollOffset(fraction * maximumScroll);
429 args.Handled = true;
430 }
431
433 protected override void OnPointerUp(WidgetPointerEventArgs args)
434 {
435 base.OnPointerUp(args);
436
437 if (_scrollBarPointerId != args.PointerId)
438 return;
439
440 _isDraggingScrollBarThumb = false;
441 _scrollBarPointerId = null;
442 args.Handled = true;
443 }
444
446 protected override void OnMouseWheel(WidgetMouseWheelEventArgs args)
447 {
448 base.OnMouseWheel(args);
449
450 float maximumScroll = _maximumVerticalScrollOffsetPx;
451
452 if (args.Delta == 0 || maximumScroll <= 0f)
453 return;
454
455 long notches = Math.Max(1, Math.Abs((long)args.Delta) / 120);
456 float change = notches * MouseWheelScrollPixels * (args.Delta > 0 ? -1f : 1f);
457 SetVerticalScrollOffset(_verticalScrollOffsetPx + change);
458 args.Handled = true;
459 }
460
461 private bool NeedsVerticalScrollBar =>
464 _maximumVerticalScrollOffsetPx > 0.5f);
465
466 private void CompleteInitialization()
467 {
468 VerticalScrollBarTrack.Visible = false;
469 VerticalScrollBarThumb.Visible = false;
471 RefreshScrollState();
472 }
473
474 private void RefreshScrollState()
475 {
476 bool scrollingEnabled = VerticalScrollBarVisibility != ScrollBarVisibility.Never;
477
478 Rectangle bounds = Bounds;
479 SetTextBlockBounds(bounds);
480
481 if (!scrollingEnabled)
482 {
483 _verticalScrollOffsetPx = 0f;
485 }
486
487 _maximumVerticalScrollOffsetPx = TextBlock.MeasureMaximumVerticalScrollOffsetPx();
488
489 bool showScrollBar = VerticalScrollBarVisibility == ScrollBarVisibility.Always ||
490 (VerticalScrollBarVisibility == ScrollBarVisibility.Auto &&
491 _maximumVerticalScrollOffsetPx > 0.5f);
492
493 if (showScrollBar)
494 {
495 Rectangle contentBounds = new(
496 bounds.Left,
497 bounds.Top,
498 Math.Max(1, bounds.Width - ScrollBarWidth - ScrollBarMargin * 2),
499 bounds.Height);
500
501 SetTextBlockBounds(contentBounds);
502 _maximumVerticalScrollOffsetPx = TextBlock.MeasureMaximumVerticalScrollOffsetPx();
503 }
504
505 IsInputEnabled = showScrollBar;
506 IsPointerInputEnabled = showScrollBar;
508 CanReceiveFocus = false;
509
510 SetVerticalScrollOffset(_verticalScrollOffsetPx);
511
512 bool visible = Visible && showScrollBar;
513 VerticalScrollBarTrack.Visible = visible;
514 VerticalScrollBarThumb.Visible = visible;
515
516 if (visible)
517 RefreshScrollBarBounds();
518 }
519
520 private void SetVerticalScrollOffset(float value)
521 {
522 _verticalScrollOffsetPx = Math.Clamp(value, 0f, _maximumVerticalScrollOffsetPx);
523 TextBlock.VerticalScrollOffsetPx = _verticalScrollOffsetPx;
524 RefreshScrollBarBounds();
525 }
526
527 private float GetViewportContentHeight()
528 {
529 Rectangle textBounds = Mode == DirectDrawingMode.View
530 ? TextBlock.ScreenBounds
531 : TextBlock.WorldBounds;
532
533 return Math.Max(0f, textBounds.Height - TextBlock.VerticalPadding * 2f);
534 }
535
536 private void RefreshScrollBarBounds()
537 {
539 return;
540
541 SetRectangleBounds(VerticalScrollBarTrack, GetScrollBarTrackBounds());
542 SetRectangleBounds(VerticalScrollBarThumb, GetScrollBarThumbBounds());
543 }
544
545 private Rectangle GetScrollBarTrackBounds()
546 {
547 return new Rectangle(
548 Bounds.Right - ScrollBarMargin - ScrollBarWidth,
549 Bounds.Top + ScrollBarMargin,
550 ScrollBarWidth,
551 Math.Max(1, Bounds.Height - ScrollBarMargin * 2));
552 }
553
554 private Rectangle GetScrollBarThumbBounds()
555 {
556 Rectangle trackBounds = GetScrollBarTrackBounds();
557 float maximumScroll = _maximumVerticalScrollOffsetPx;
558 float viewportHeight = GetViewportContentHeight();
559
560 if (maximumScroll <= 0f || viewportHeight <= 0f)
561 return trackBounds;
562
563 float contentHeight = viewportHeight + maximumScroll;
564
565 int thumbHeight = Math.Clamp(
566 (int)MathF.Round(trackBounds.Height * Math.Min(1f, viewportHeight / contentHeight)),
567 Math.Min(MinimumScrollBarThumbHeight, trackBounds.Height),
568 trackBounds.Height);
569
570 int travel = trackBounds.Height - thumbHeight;
571
572 int offset = maximumScroll <= 0f
573 ? 0
574 : (int)MathF.Round(travel * (_verticalScrollOffsetPx / maximumScroll));
575
576 return new Rectangle(
577 trackBounds.Left,
578 trackBounds.Top + offset,
579 trackBounds.Width,
580 thumbHeight);
581 }
582
583 private PointF GetLocalPointerPosition(WidgetPointerEventArgs args)
584 {
585 RectangleF screenBounds = TextBlock.GetDrawLocationScreen(args.View);
586
587 screenBounds.Offset(
588 args.WrappedOffsetWorldPx.X * args.View.Viewport.Zoom,
589 args.WrappedOffsetWorldPx.Y * args.View.Viewport.Zoom);
590
591 Rectangle textBounds = Mode == DirectDrawingMode.View
592 ? TextBlock.ScreenBounds
593 : TextBlock.WorldBounds;
594
595 float scaleX = screenBounds.Width / textBounds.Width;
596 float scaleY = screenBounds.Height / textBounds.Height;
597
598 return new PointF(
599 Bounds.Left + (args.ScreenPositionPx.X - screenBounds.Left) / scaleX,
600 Bounds.Top + (args.ScreenPositionPx.Y - screenBounds.Top) / scaleY);
601 }
602
603 private void SetTextBlockBounds(Rectangle bounds)
604 {
605 // Use TextBlock's size API so width changes invalidate wrapping/layout.
606 TextBlock.SetSize(bounds.Size);
607 TextBlock.SetPosition(new Vector2(bounds.X, bounds.Y));
608
609 Rectangle overallBounds = Bounds;
610
612 TextBlock,
613 new Vector2(bounds.X - overallBounds.X, bounds.Y - overallBounds.Y));
614 }
615
616 private void SetRectangleBounds(DirectRectangle rectangle, Rectangle bounds)
617 {
618 if (Mode == DirectDrawingMode.View)
619 rectangle.ScreenBounds = bounds;
620 else
621 rectangle.WorldBounds = bounds;
622
624 rectangle,
625 new Vector2(bounds.X - Bounds.X, bounds.Y - Bounds.Y));
626 }
627
628 private static DirectRectangle CreateScrollBarTrack(
629 RenderSurfaceHostBase host,
630 View view,
631 Rectangle bounds)
632 => ConfigureScrollBarTrack(
633 new DirectRectangle(
634 Color.FromArgb(
635 255,
636 26,
637 26,
638 32),
639 host,
640 view,
641 bounds));
642
643 private static DirectRectangle CreateScrollBarTrack(
644 RenderSurfaceHostBase host,
645 SceneLayer sceneLayer,
646 Rectangle bounds)
647 => ConfigureScrollBarTrack(
648 new DirectRectangle(
649 Color.FromArgb(
650 255,
651 26,
652 26,
653 32),
654 host,
655 sceneLayer,
656 bounds));
657
658 private static DirectRectangle ConfigureScrollBarTrack(DirectRectangle track)
659 => track.SetFilled(true).SetStrokeWidth(0f).SetCornerRadius(3f);
660
661 private static DirectRectangle CreateScrollBarThumb(
662 RenderSurfaceHostBase host,
663 View view,
664 Rectangle bounds)
665 => ConfigureScrollBarThumb(
666 new DirectRectangle(
667 Color.FromArgb(
668 255,
669 126,
670 126,
671 142),
672 host,
673 view,
674 bounds));
675
676 private static DirectRectangle CreateScrollBarThumb(
677 RenderSurfaceHostBase host,
678 SceneLayer sceneLayer,
679 Rectangle bounds)
680 => ConfigureScrollBarThumb(
681 new DirectRectangle(
682 Color.FromArgb(
683 255,
684 126,
685 126,
686 142),
687 host,
688 sceneLayer,
689 bounds));
690
691 private static DirectRectangle ConfigureScrollBarThumb(DirectRectangle thumb)
692 => thumb.SetFilled(true).SetStrokeWidth(0f).SetCornerRadius(3f);
693
694 private static Rectangle ValidateBounds(Rectangle bounds)
695 {
696 ValidateSize(bounds.Size);
697 return bounds;
698 }
699
700 private static void ValidateSize(Size size)
701 {
702 if (size.Width <= 0 || size.Height <= 0)
703 throw new ArgumentOutOfRangeException(nameof(size), size, "Label size must be positive.");
704 }
705}
bool Visible
Gets or sets the visibility of all descendants.
SceneLayer? SceneLayer
Gets the scene layer shared by all children in scene-layer mode.
DirectComposite SetLocalOffset(IDirectCompositeChild child, Vector2 newLocalOffsetPx)
Changes one child's local offset and reapplies its position.
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.
DirectDrawingMode Mode
Gets the coordinate mode shared by the composite and its children.
int ZOrder
Gets or sets the Z-order (depth) used for sorting this direct drawing relative to other drawables.
Renders a configurable rectangle with support for fill, border, rounded corners, dash patterns,...
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
Definition TextBlock.cs:44
TextBlock SetColors(SKColor fg, SKColor bg)
Sets the foreground (text) and background colors using Skia colors.
Definition TextBlock.cs:430
float VerticalScrollEndPaddingPx
Gets or sets extra scrollable space after the final laid-out line.
Definition TextBlock.cs:257
float MeasureMaximumVerticalScrollOffsetPx()
Measures the maximum vertical scroll offset required to expose all currently laid-out text.
Definition TextBlock.cs:279
float VerticalScrollOffsetPx
Gets or sets the vertical text-content scroll offset in native pixels.
Definition TextBlock.cs:234
TextBlock SetText(string text)
Sets the current text content and rebuilds layout as needed. If no reveal animation is active,...
Definition TextBlock.cs:378
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
float VerticalScrollOffsetPx
Gets or sets the current vertical text-content scroll offset.
bool IsVerticalScrollBarVisible
Gets whether the vertical scrollbar is currently visible.
DirectRectangle VerticalScrollBarTrack
Gets the vertical scrollbar track drawing.
LabelWidget SetText(string text)
Changes the displayed text.
override void OnPointerMove(WidgetPointerEventArgs args)
Called when pointer movement is routed to the widget.
override void OnPointerDown(WidgetPointerEventArgs args)
Called when a pointer press begins on the widget.
float MaximumVerticalScrollOffsetPx
Gets the maximum vertical text-content scroll offset for the current layout.
override void OnPointerUp(WidgetPointerEventArgs args)
Called when a pointer press is released for the widget.
LabelWidget SetTextColor(SKColor color)
Sets the foreground text color while preserving the background color.
LabelWidget(RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle bounds, string text="", string? nickname=null)
Creates a scene-layer label.
ScrollBarVisibility VerticalScrollBarVisibility
Gets or sets when the label displays its vertical scrollbar.
override void ProcessShown()
Performs processing when the widget is shown before notification callbacks are invoked.
Rectangle Bounds
Gets the label bounds in its native coordinate space.
override void ProcessHidden()
Performs processing when the widget is hidden before notification callbacks are invoked.
string Text
Gets the current label text.
LabelWidget SetFont(SKTypeface typeface, float size, float? minSize=null)
Configures the label typeface and size.
float VerticalScrollEndPaddingPx
Gets or sets additional space exposed after the last line when scrolled fully down.
LabelWidget SetColors(SKColor foreground, SKColor background)
Sets foreground and background colors.
override void OnMouseWheel(WidgetMouseWheelEventArgs args)
Called when mouse-wheel input is routed to the widget.
DirectRectangle VerticalScrollBarThumb
Gets the vertical scrollbar thumb drawing.
Size Size
Gets or sets the label size while preserving its current position.
LabelWidget(RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle bounds, string text="", string? nickname=null)
Creates a view-level label.
TextBlock TextBlock
Gets the underlying text drawing.
LabelWidget EnableWrapping(bool enabled=true)
Enables or disables wrapping.
int MouseWheelScrollPixels
Gets or sets the number of native pixels scrolled for one mouse-wheel notch.
LabelWidget SetPadding(float horizontal, float vertical)
Sets symmetric horizontal and vertical padding.
LabelWidget SetBackgroundColor(SKColor color)
Sets the text-block background color while preserving the foreground color.
LabelWidget SetAlignment(SKTextAlign horizontal, TextBlock.VerticalAlign vertical)
Configures horizontal and vertical text alignment.
LabelWidget SetLabelZOrder(int zOrder)
Sets the base Z-order used by the label text and optional scrollbar.
bool CanReceiveFocus
Gets or sets a value indicating whether the widget can receive keyboard focus.
bool IsPointerInputEnabled
Gets or sets a value indicating whether the widget can receive pointer input.
WidgetBase(RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
Initializes a new instance of the WidgetBase class.
Definition WidgetBase.cs:95
bool IsKeyboardInputEnabled
Gets or sets a value indicating whether the widget can receive keyboard input.
bool IsInputEnabled
Gets or sets a value indicating whether the widget can participate in input routing.
Event arguments for mouse-wheel input routed to a widget.
int Delta
Gets the wheel delta. Positive values scroll upward; negative values scroll downward.
Event arguments for pointer-based widget callbacks.
bool IsPrimaryButton
Gets whether the pointer event represents a primary-button interaction.
int PointerId
Gets the identifier of the pointer that produced the event.
@ 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.
ScrollBarVisibility
Specifies when a scrollable widget displays its vertical scrollbar.
@ Always
Always displays the scrollbar while the widget is visible.