|
2 | 2 | using CelesteStudio.Util; |
3 | 3 | using System; |
4 | 4 | using System.Windows; |
5 | | -using System.Windows.Media; |
6 | 5 | using System.Windows.Media.Imaging; |
7 | 6 | using Eto.Wpf.Forms; |
8 | 7 | using SkiaSharp; |
9 | 8 | using System.Windows.Controls; |
10 | 9 | using Eto.Wpf; |
| 10 | +using Eto; |
| 11 | +using Eto.Drawing; |
| 12 | +using Eto.Forms; |
| 13 | +using System.Windows.Media; |
| 14 | +using EtoControl = Eto.Forms.Control; |
| 15 | +using EtoColor = Eto.Drawing.Color; |
| 16 | +using EtoColors = Eto.Drawing.Colors; |
11 | 17 |
|
12 | 18 | namespace CelesteStudio.WPF; |
13 | 19 |
|
@@ -53,7 +59,21 @@ protected override void OnRender(DrawingContext drawingContext) { |
53 | 59 |
|
54 | 60 | var canvas = surface.Canvas; |
55 | 61 | using (new SKAutoCanvasRestore(surface.Canvas, true)) { |
56 | | - canvas.Clear(drawable.BackgroundColor.ToSkia()); |
| 62 | + // Traverse transparent background color tree |
| 63 | + EtoControl? currWidget = drawable; |
| 64 | + EtoColor bgColor = drawable.BackgroundColor; |
| 65 | + while (bgColor.A <= 0.01f && currWidget != null) { |
| 66 | + currWidget = currWidget.Parent; |
| 67 | + bgColor = currWidget?.BackgroundColor ?? EtoColors.Transparent; |
| 68 | + } |
| 69 | + |
| 70 | + if (bgColor.A <= 0.01f) { |
| 71 | + // Use native background color |
| 72 | + canvas.Clear(Settings.Instance.Theme.DarkMode ? Settings.Instance.Theme.Background.ToSkia() : SKColors.White); |
| 73 | + } else { |
| 74 | + canvas.Clear(bgColor.ToSkia()); |
| 75 | + } |
| 76 | + |
57 | 77 | drawable.Draw(surface); |
58 | 78 | } |
59 | 79 | canvas.Flush(); |
@@ -81,7 +101,21 @@ protected override void OnRender(DrawingContext drawingContext) { |
81 | 101 |
|
82 | 102 | var canvas = surface.Canvas; |
83 | 103 | using (new SKAutoCanvasRestore(surface.Canvas, true)) { |
84 | | - canvas.Clear(drawable.BackgroundColor.ToSkia()); |
| 104 | + // Traverse transparent background color tree |
| 105 | + EtoControl? currWidget = drawable; |
| 106 | + EtoColor bgColor = drawable.BackgroundColor; |
| 107 | + while (bgColor.A <= 0.01f && currWidget != null) { |
| 108 | + currWidget = currWidget.Parent; |
| 109 | + bgColor = currWidget?.BackgroundColor ?? EtoColors.Transparent; |
| 110 | + } |
| 111 | + |
| 112 | + if (bgColor.A <= 0.01f) { |
| 113 | + // Use native background color |
| 114 | + canvas.Clear(Settings.Instance.Theme.DarkMode ? Settings.Instance.Theme.Background.ToSkia() : SKColors.White); |
| 115 | + } else { |
| 116 | + canvas.Clear(bgColor.ToSkia()); |
| 117 | + } |
| 118 | + |
85 | 119 | canvas.Translate(-drawable.DrawX, -drawable.DrawY); |
86 | 120 | drawable.Draw(surface); |
87 | 121 | } |
|
0 commit comments