Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using ElectronNET.Converter;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;

Expand Down Expand Up @@ -216,10 +217,16 @@ public class BrowserWindowOptions
public TitleBarStyle TitleBarStyle { get; set; }

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

/// <summary>
/// Shows the title in the tile bar in full screen mode on macOS for all
Expand Down
22 changes: 22 additions & 0 deletions src/ElectronNET.API/API/Entities/TitleBarOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace ElectronNET.API.Entities;

public class TitleBarOverlay
{
private readonly bool? _value;

public TitleBarOverlay()
{
}

private TitleBarOverlay(bool value) : this() => _value = value;

public string Color { get; set; }

public double Height { get; set; }

public string SymbolColor { get; set; }

public static implicit operator bool?(TitleBarOverlay titleBarOverlay) => titleBarOverlay?._value;

public static implicit operator TitleBarOverlay(bool value) => new(value);
}
43 changes: 43 additions & 0 deletions src/ElectronNET.API/Converter/TitleBarOverlayConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using System;

namespace ElectronNET.Converter;

public class TitleBarOverlayConverter : JsonConverter<TitleBarOverlay>
{
public override TitleBarOverlay ReadJson(JsonReader reader, Type objectType, TitleBarOverlay existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Boolean)
{
return (bool)reader.Value;
}
else if (reader.TokenType == JsonToken.StartObject)
{
return serializer.Deserialize<TitleBarOverlay>(reader);
}
else
{
throw new JsonSerializationException("Invalid value for TitleBarOverlay. Expected true, false, or an object.");
}
}

public override void WriteJson(JsonWriter writer, TitleBarOverlay value, JsonSerializer serializer)
{
if (value is null)
{
writer.WriteUndefined();
return;
}

var @bool = (bool?)value;
if (@bool.HasValue)
{
writer.WriteValue(@bool.Value);
}
else
{
serializer.Serialize(writer, value);
}
}
}
2 changes: 1 addition & 1 deletion src/ElectronNET.Host/api/app.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ElectronNET.Host/api/autoUpdater.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ElectronNET.Host/api/nativeTheme.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ElectronNET.Host/api/process.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/ElectronNET/build/ElectronNET.Build.dll
Binary file not shown.