Skip to content

Commit c1e7b84

Browse files
authored
Merge pull request #911 from Denny09310/develop
feat: updated 'TitleBarOverlay' property to be passed as object
2 parents d034580 + 9bb7dcf commit c1e7b84

File tree

8 files changed

+80
-8
lines changed

8 files changed

+80
-8
lines changed

src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using ElectronNET.Converter;
2+
using Newtonsoft.Json;
23
using Newtonsoft.Json.Converters;
34
using System.ComponentModel;
45

@@ -216,10 +217,16 @@ public class BrowserWindowOptions
216217
public TitleBarStyle TitleBarStyle { get; set; }
217218

218219
/// <summary>
219-
/// When using a frameless window this can be used to indicate if the
220-
/// standard control buttons should be shown. Default is false.
220+
/// Configures the window's title bar overlay when using a frameless window.
221+
/// Can be either:
222+
/// - false: No title bar overlay.
223+
/// - true: Enables the default title bar overlay.
224+
/// - An object defining custom overlay options (such as height, color, etc.).
225+
///
226+
/// Default is false.
221227
/// </summary>
222-
public bool TitleBarOverlay { get; set; }
228+
[JsonConverter(typeof(TitleBarOverlayConverter))]
229+
public TitleBarOverlay TitleBarOverlay { get; set; }
223230

224231
/// <summary>
225232
/// Shows the title in the tile bar in full screen mode on macOS for all
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace ElectronNET.API.Entities;
2+
3+
public class TitleBarOverlay
4+
{
5+
private readonly bool? _value;
6+
7+
public TitleBarOverlay()
8+
{
9+
}
10+
11+
private TitleBarOverlay(bool value) : this() => _value = value;
12+
13+
public string Color { get; set; }
14+
15+
public double Height { get; set; }
16+
17+
public string SymbolColor { get; set; }
18+
19+
public static implicit operator bool?(TitleBarOverlay titleBarOverlay) => titleBarOverlay?._value;
20+
21+
public static implicit operator TitleBarOverlay(bool value) => new(value);
22+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using ElectronNET.API.Entities;
2+
using Newtonsoft.Json;
3+
using System;
4+
5+
namespace ElectronNET.Converter;
6+
7+
public class TitleBarOverlayConverter : JsonConverter<TitleBarOverlay>
8+
{
9+
public override TitleBarOverlay ReadJson(JsonReader reader, Type objectType, TitleBarOverlay existingValue, bool hasExistingValue, JsonSerializer serializer)
10+
{
11+
if (reader.TokenType == JsonToken.Boolean)
12+
{
13+
return (bool)reader.Value;
14+
}
15+
else if (reader.TokenType == JsonToken.StartObject)
16+
{
17+
return serializer.Deserialize<TitleBarOverlay>(reader);
18+
}
19+
else
20+
{
21+
throw new JsonSerializationException("Invalid value for TitleBarOverlay. Expected true, false, or an object.");
22+
}
23+
}
24+
25+
public override void WriteJson(JsonWriter writer, TitleBarOverlay value, JsonSerializer serializer)
26+
{
27+
if (value is null)
28+
{
29+
writer.WriteUndefined();
30+
return;
31+
}
32+
33+
var @bool = (bool?)value;
34+
if (@bool.HasValue)
35+
{
36+
writer.WriteValue(@bool.Value);
37+
}
38+
else
39+
{
40+
serializer.Serialize(writer, value);
41+
}
42+
}
43+
}

src/ElectronNET.Host/api/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/autoUpdater.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/nativeTheme.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ElectronNET.Host/api/process.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)