From 8b04fe8bdec5f0f52c76ebf02d58870ead7db43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Thu, 10 Aug 2023 09:34:32 +0200 Subject: [PATCH] Theme improvements --- .../ITheme.cs | 6 +++++- .../FileTime.ConsoleUI.App/MainWindow.cs | 19 ++++++++++-------- .../FileTime.ConsoleUI.Styles/DefaultTheme.cs | 20 +++++++++++++++---- .../InfoProviders/ColorSchema.cs | 2 +- src/Library/TerminalUI/Color/Colors.cs | 10 +++++----- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App.Abstractions/ITheme.cs b/src/ConsoleApp/FileTime.ConsoleUI.App.Abstractions/ITheme.cs index 4e21269..efd29a9 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App.Abstractions/ITheme.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App.Abstractions/ITheme.cs @@ -8,6 +8,10 @@ public interface ITheme IColor? DefaultBackgroundColor { get; } IColor? ElementColor { get; } IColor? ContainerColor { get; } - IColor? MarkedItemColor { get; } + IColor? MarkedItemForegroundColor { get; } + IColor? MarkedItemBackgroundColor { get; } + IColor? MarkedSelectedItemForegroundColor { get; } + IColor? MarkedSelectedItemBackgroundColor { get; } + IColor? SelectedItemColor { get; } IColor? SelectedTabBackgroundColor { get; } } \ No newline at end of file diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/MainWindow.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/MainWindow.cs index 3faa617..471a738 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/MainWindow.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/MainWindow.cs @@ -45,6 +45,9 @@ public class MainWindow ChildInitializer = { new TextBlock() + { + Foreground = _theme.ContainerColor + } .Setup(t => t.Bind( t, @@ -88,13 +91,13 @@ public class MainWindow { var textBlock = item.CreateChild>(); textBlock.Foreground = _theme.DefaultForegroundColor; - + textBlock.Bind( textBlock, dc => dc.TabNumber.ToString(), tb => tb.Text, fallbackValue: "?"); - + textBlock.Bind( textBlock, dc => dc.IsSelected.Value ? _theme.SelectedTabBackgroundColor : null, @@ -319,10 +322,10 @@ public class MainWindow (ItemViewMode.Alternative, AbsolutePathType.Container) => _theme.ContainerColor, (ItemViewMode.Default, _) => _theme.ElementColor, (ItemViewMode.Alternative, _) => _theme.ElementColor, - (ItemViewMode.Selected, _) => ToBackgroundColor(ItemViewMode.Default, absolutePathType)?.AsForeground(), - (ItemViewMode.Marked, _) => _theme.MarkedItemColor, - (ItemViewMode.MarkedSelected, _) => ToBackgroundColor(ItemViewMode.Marked, absolutePathType)?.AsForeground(), - (ItemViewMode.MarkedAlternative, _) => _theme.MarkedItemColor, + (ItemViewMode.Selected, _) => _theme.SelectedItemColor, + (ItemViewMode.Marked, _) => _theme.MarkedItemForegroundColor, + (ItemViewMode.MarkedSelected, _) => _theme.SelectedItemColor, + (ItemViewMode.MarkedAlternative, _) => _theme.MarkedItemForegroundColor, _ => throw new NotImplementedException() }; @@ -332,9 +335,9 @@ public class MainWindow (ItemViewMode.Default, _) => _theme.DefaultBackgroundColor, (ItemViewMode.Alternative, _) => _theme.DefaultBackgroundColor, (ItemViewMode.Selected, _) => ToForegroundColor(ItemViewMode.Default, absolutePathType)?.AsBackground(), - (ItemViewMode.Marked, _) => _theme.MarkedItemColor, + (ItemViewMode.Marked, _) => _theme.MarkedItemBackgroundColor, (ItemViewMode.MarkedSelected, _) => ToForegroundColor(ItemViewMode.Marked, absolutePathType)?.AsBackground(), - (ItemViewMode.MarkedAlternative, _) => _theme.MarkedItemColor, + (ItemViewMode.MarkedAlternative, _) => _theme.MarkedItemBackgroundColor, _ => throw new NotImplementedException() }; } \ No newline at end of file diff --git a/src/ConsoleApp/FileTime.ConsoleUI.Styles/DefaultTheme.cs b/src/ConsoleApp/FileTime.ConsoleUI.Styles/DefaultTheme.cs index 6ab5533..5e8416b 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.Styles/DefaultTheme.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.Styles/DefaultTheme.cs @@ -8,7 +8,11 @@ public record Theme( IColor? DefaultBackgroundColor, IColor? ElementColor, IColor? ContainerColor, - IColor? MarkedItemColor, + IColor? MarkedItemForegroundColor, + IColor? MarkedItemBackgroundColor, + IColor? MarkedSelectedItemForegroundColor, + IColor? MarkedSelectedItemBackgroundColor, + IColor? SelectedItemColor, IColor? SelectedTabBackgroundColor, Type? ForegroundColors, Type? BackgroundColors) : ITheme, IColorSampleProvider; @@ -20,7 +24,11 @@ public static class DefaultThemes DefaultBackgroundColor: null, ElementColor: Color256Colors.Foregrounds.Gray, ContainerColor: Color256Colors.Foregrounds.Blue, - MarkedItemColor: Color256Colors.Foregrounds.Black, + MarkedItemForegroundColor: Color256Colors.Foregrounds.Yellow, + MarkedItemBackgroundColor: null, + MarkedSelectedItemForegroundColor: Color256Colors.Foregrounds.Black, + MarkedSelectedItemBackgroundColor: Color256Colors.Foregrounds.Yellow, + SelectedItemColor: Color256Colors.Foregrounds.Black, SelectedTabBackgroundColor: Color256Colors.Backgrounds.Green, ForegroundColors: typeof(Color256Colors.Foregrounds), BackgroundColors: typeof(Color256Colors.Backgrounds) @@ -28,10 +36,14 @@ public static class DefaultThemes public static Theme ConsoleColorTheme => new( DefaultForegroundColor: ConsoleColors.Foregrounds.Gray, - DefaultBackgroundColor: ConsoleColors.Backgrounds.Black, + DefaultBackgroundColor: null, ElementColor: ConsoleColors.Foregrounds.Gray, ContainerColor: ConsoleColors.Foregrounds.Blue, - MarkedItemColor: ConsoleColors.Foregrounds.Black, + MarkedItemForegroundColor: ConsoleColors.Foregrounds.Yellow, + MarkedItemBackgroundColor: null, + MarkedSelectedItemForegroundColor: ConsoleColors.Foregrounds.Black, + MarkedSelectedItemBackgroundColor: ConsoleColors.Foregrounds.Yellow, + SelectedItemColor: ConsoleColors.Foregrounds.Black, SelectedTabBackgroundColor: ConsoleColors.Backgrounds.Green, ForegroundColors: typeof(ConsoleColors.Foregrounds), BackgroundColors: typeof(ConsoleColors.Backgrounds) diff --git a/src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs b/src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs index db4b765..10620da 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs @@ -79,7 +79,7 @@ public static class ColorSchema .OrderBy(v => v.Key) .ToDictionary(k => k.Key, v => v.Value); - consoleDriver.Write("Color theme for " + paletteName + Environment.NewLine); + consoleDriver.Write("Color palette for " + paletteName + Environment.NewLine); if (colors.Count == 0) { diff --git a/src/Library/TerminalUI/Color/Colors.cs b/src/Library/TerminalUI/Color/Colors.cs index bdf9b6a..399b458 100644 --- a/src/Library/TerminalUI/Color/Colors.cs +++ b/src/Library/TerminalUI/Color/Colors.cs @@ -14,11 +14,11 @@ public static class Color256Colors public static readonly Color256 DarkMagenta = new(5, ColorType.Background); public static readonly Color256 DarkRed = new(1, ColorType.Background); public static readonly Color256 DarkYellow = new(3, ColorType.Background); - public static readonly Color256 Gray = new(15, ColorType.Background); + public static readonly Color256 Gray = new(7, ColorType.Background); public static readonly Color256 Green = new(10, ColorType.Background); public static readonly Color256 Magenta = new(13, ColorType.Background); public static readonly Color256 Red = new(9, ColorType.Background); - public static readonly Color256 White = new(7, ColorType.Background); + public static readonly Color256 White = new(15, ColorType.Background); public static readonly Color256 Yellow = new(11, ColorType.Background); } public static class Foregrounds @@ -33,12 +33,12 @@ public static class Color256Colors public static readonly Color256 DarkMagenta = new(5, ColorType.Foreground); public static readonly Color256 DarkRed = new(1, ColorType.Foreground); public static readonly Color256 DarkYellow = new(3, ColorType.Foreground); - public static readonly Color256 Gray = new(15, ColorType.Foreground); + public static readonly Color256 Gray = new(7, ColorType.Foreground); public static readonly Color256 Green = new(10, ColorType.Foreground); public static readonly Color256 Magenta = new(13, ColorType.Foreground); public static readonly Color256 Red = new(9, ColorType.Foreground); - public static readonly Color256 White = new(7, ColorType.Foreground); - public static readonly Color256 Yellow = new(11, ColorType.Background); + public static readonly Color256 White = new(15, ColorType.Foreground); + public static readonly Color256 Yellow = new(11, ColorType.Foreground); } }