Gondwana Game Engine Development (master) - 2.6.1
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
MenuIndicatorDrawing.cs
1using System.Drawing;
6using SkiaSharp;
7
9
10// Geometry avoids depending on whether the platform default font contains menu symbols.
11internal sealed class MenuIndicatorDrawing : DirectDrawingMovableBase
12{
13 internal enum Shape
14 {
18 Check,
22 Radio,
26 Arrow
27 }
28 private readonly Shape _shape;
29 private readonly MenuBarTheme _theme;
30 private bool _active;
31 private SKColor _color;
32
33 internal MenuIndicatorDrawing(RenderSurfaceHostBase host, View view, Rectangle bounds,
34 Shape shape, MenuBarTheme theme, string nickname)
35 : base(host, DirectDrawingMode.View, null, view, bounds, null, nickname)
36 {
37 _shape = shape;
38 _theme = theme;
39 }
40
41 internal void SetState(bool active, SKColor color)
42 {
43 _active = active;
44 _color = color;
45 ForceRefresh();
46 }
47
49 protected override void OnDraw(BackbufferBase backbuffer, RectangleF destRectScreen)
50 {
51 if (!_active) return;
52 float size = Math.Min(_theme.IndicatorSize, Math.Min(destRectScreen.Width, destRectScreen.Height));
53 float x = destRectScreen.X + (destRectScreen.Width - size) / 2;
54 float y = destRectScreen.Y + (destRectScreen.Height - size) / 2;
55 using var paint = new SKPaint
56 {
57 Color = _color,
58 IsAntialias = true,
59 StrokeWidth = _theme.IndicatorStrokeWidth,
60 StrokeCap = SKStrokeCap.Round,
61 StrokeJoin = SKStrokeJoin.Round,
62 Style = _shape == Shape.Radio ? SKPaintStyle.Fill : SKPaintStyle.Stroke
63 };
64 if (_shape == Shape.Radio)
65 {
66 backbuffer.Canvas.DrawCircle(x + size / 2, y + size / 2, size / 4, paint);
67 return;
68 }
69 using var path = new SKPath();
70 if (_shape == Shape.Check)
71 {
72 path.MoveTo(x + size * .15f, y + size * .5f);
73 path.LineTo(x + size * .4f, y + size * .75f);
74 path.LineTo(x + size * .85f, y + size * .2f);
75 }
76 else
77 {
78 path.MoveTo(x + size * .35f, y + size * .2f);
79 path.LineTo(x + size * .65f, y + size * .5f);
80 path.LineTo(x + size * .35f, y + size * .8f);
81 }
82 backbuffer.Canvas.DrawPath(path, paint);
83 }
84}
View? View
Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode...
SKCanvas Canvas
Gets the SkiaSharp canvas used for drawing operations on this backbuffer.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
record MenuBarTheme
Defines the dimensions and colors used by menu bar widgets.