Skip to content

Commit 51c4649

Browse files
authored
Merge pull request #134 from Rekkonnect/dev/stuff/a
Various code improvements and minor features
2 parents 19026e0 + 5390bcd commit 51c4649

36 files changed

Lines changed: 626 additions & 269 deletions

Syndiesis.InternalGenerators/SolidColorFieldGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void AppendHeaderText()
7979
const string header = """
8080
using Color = Avalonia.Media.Color;
8181
using SolidColorBrush = Avalonia.Media.SolidColorBrush;
82-
using LazilyUpdatedSolidBrush = Syndiesis.LazilyUpdatedSolidBrush;
82+
using LazilyUpdatedSolidBrush = Syndiesis.ColorHelpers.LazilyUpdatedSolidBrush;
8383
using JsonIncludeAttribute = System.Text.Json.Serialization.JsonIncludeAttribute;
8484
8585

Syndiesis/AppSettings.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,35 @@ public sealed class AppSettings
3434

3535
public int RecursiveExpansionDepth = 4;
3636

37+
public double CodeFontSize = 12;
38+
3739
public AnalysisNodeKind DefaultAnalysisTab = AnalysisNodeKind.Syntax;
3840
public AnalysisViewKind DefaultAnalysisView = AnalysisViewKind.Tree;
3941
#endregion
4042

43+
#region Events
44+
public static event Action? SettingsLoaded;
45+
#endregion
46+
4147
#region Persistence
4248
public static async Task<bool> TryLoad(string path = DefaultPath)
4349
{
4450
try
4551
{
4652
var json = await File.ReadAllTextAsync(path);
47-
var returned = await Dispatcher.UIThread.InvokeAsync(() =>
53+
var settings = await Dispatcher.UIThread.InvokeAsync(() =>
4854
{
4955
return JsonSerializer.Deserialize<AppSettings>(
5056
json, AppSettingsSerialization.DefaultOptions);
5157
});
52-
if (returned is null)
58+
if (settings is null)
5359
return false;
5460

55-
Instance = returned;
61+
Instance = settings;
5662
Log.Information($"Settings loaded from '{path}'");
63+
64+
_ = Dispatcher.UIThread.InvokeAsync(
65+
() => SettingsLoaded?.Invoke());
5766
return true;
5867
}
5968
catch (Exception ex)

Syndiesis/AppSettingsSerialization.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.Json;
1+
using Garyon.Objects;
2+
using System.Text.Json;
23
using System.Text.Json.Serialization;
34

45
namespace Syndiesis;
@@ -20,12 +21,12 @@ private static JsonSerializerOptions GetDefaultOptions()
2021
IgnoreReadOnlyProperties = true,
2122
Converters =
2223
{
23-
new AvaloniaColorJsonConverter(),
24+
Singleton<AvaloniaColorJsonConverter>.Instance,
2425
}
2526
};
2627
}
2728

28-
public class AvaloniaColorJsonConverter : JsonConverter<Color>
29+
private sealed class AvaloniaColorJsonConverter : JsonConverter<Color>
2930
{
3031
public override Color Read(
3132
ref Utf8JsonReader reader,
@@ -34,7 +35,7 @@ public override Color Read(
3435
{
3536
if (reader.TokenType is not JsonTokenType.String)
3637
return default;
37-
return Avalonia.Media.Color.Parse(reader.GetString()!);
38+
return Color.Parse(reader.GetString()!);
3839
}
3940

4041
public override void Write(

Syndiesis/FixedUpdatedSolidBrush.cs renamed to Syndiesis/ColorHelpers/FixedUpdatedSolidBrush.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Syndiesis.ColorHelpers;
2-
3-
namespace Syndiesis;
1+
namespace Syndiesis.ColorHelpers;
42

53
public sealed class FixedUpdatedSolidBrush : ILazilyUpdatedSolidBrush
64
{
@@ -23,7 +21,8 @@ public FixedUpdatedSolidBrush(SolidColorBrush brush)
2321
_brush = brush;
2422
}
2523

26-
public LazilyUpdatedHsvTransformedSolidBrush WithHsvTransformation(HsvTransformation transformation)
24+
public LazilyUpdatedHsvTransformedSolidBrush WithHsvTransformation(
25+
HsvTransformation transformation)
2726
{
2827
return new(this, transformation);
2928
}

Syndiesis/ColorHelpers/HslTransformation.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
namespace Syndiesis.ColorHelpers;
22

3-
public readonly record struct HslTransformation(double Alpha, double Hue, double Saturation, double Lightness)
3+
public readonly record struct HslTransformation(
4+
double Alpha = 0,
5+
double Hue = 0,
6+
double Saturation = 0,
7+
double Lightness = 0)
48
: IColorTransformation<HslColor>
59
{
610
public HslColor Transform(HslColor color)

Syndiesis/ILazilyUpdatedBrush.cs renamed to Syndiesis/ColorHelpers/ILazilyUpdatedBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Syndiesis;
1+
namespace Syndiesis.ColorHelpers;
22

33
public interface ILazilyUpdatedBrush
44
{

Syndiesis/ILazilyUpdatedSolidBrush.cs renamed to Syndiesis/ColorHelpers/ILazilyUpdatedSolidBrush.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace Syndiesis;
1+
namespace Syndiesis.ColorHelpers;
22

3-
// TODO Move to .Colors
43
public interface ILazilyUpdatedSolidBrush : ILazilyUpdatedBrush
54
{
65
public Color Color { get; }

Syndiesis/LazilyUpdatedGradientBrush.cs renamed to Syndiesis/ColorHelpers/LazilyUpdatedGradientBrush.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace Syndiesis;
1+
namespace Syndiesis.ColorHelpers;
22

3-
// TODO Move to .Colors
43
public sealed class LazilyUpdatedGradientBrush : ILazilyUpdatedBrush
54
{
65
private readonly LinearGradientBrush _brush;

Syndiesis/LazilyUpdatedGradientStop.cs renamed to Syndiesis/ColorHelpers/LazilyUpdatedGradientStop.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace Syndiesis;
1+
namespace Syndiesis.ColorHelpers;
22

3-
// TODO Move to .Colors
43
public sealed class LazilyUpdatedGradientStop(GradientStop stop)
54
{
65
private readonly GradientStop _stop = stop;

Syndiesis/LazilyUpdatedSolidBrush.cs renamed to Syndiesis/ColorHelpers/LazilyUpdatedSolidBrush.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using Syndiesis.ColorHelpers;
1+
namespace Syndiesis.ColorHelpers;
22

3-
namespace Syndiesis;
4-
5-
// TODO Move to .Colors
63
public sealed class LazilyUpdatedSolidBrush : ILazilyUpdatedSolidBrush
74
{
85
private readonly SolidColorBrush _brush = new();

0 commit comments

Comments
 (0)