GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(domain,bar): add binding for bar padding
Lars Bergerb4ec7374fa6c
diff --git a/GlazeWM.Bar/BarViewModel.cs b/GlazeWM.Bar/BarViewModel.csindex 83fcce58..a8d01de0 100644--- a/GlazeWM.Bar/BarViewModel.cs+++ b/GlazeWM.Bar/BarViewModel.cs@@ -18,6 +18,7 @@ namespace GlazeWM.Barpublic string FontSize { get; set; }public string BorderColor { get; set; }public string BorderWidth { get; set; }+ public string Padding { get; set; }private readonly Dispatcher _dispatcher;private readonly Monitor _monitor;private readonly BarConfig _barConfig;@@ -35,24 +36,27 @@ namespace GlazeWM.BarFontFamily = _barConfig.FontFamily;FontSize = _barConfig.FontSize;BorderColor = _barConfig.BorderColor;- BorderWidth = FormatBorderWidth(_barConfig.BorderWidth);+ BorderWidth = ShorthandToXamlProperty(_barConfig.BorderWidth);+ Padding = ShorthandToXamlProperty(_barConfig.Padding);UpdateWorkspaces();}/// <summary>- /// Format border width from user config to be compatible with `BorderThickness`.+ /// Convert shorthand properties from user config (ie. `Padding`, `Margin`, and `BorderWidth`)+ /// to be compatible with their equivalent XAML properties (ie. `Padding`, `Margin`, and+ /// `BorderThickness`). Shorthand properties follow the 1-to-4 value syntax used in CSS./// </summary>- private string FormatBorderWidth(string borderWidth)+ private string ShorthandToXamlProperty(string shorthand){- var borderWidthParts = borderWidth.Split(" ");+ var shorthandParts = shorthand.Split(" ");- return borderWidthParts.Count() switch+ return shorthandParts.Count() switch{- 1 => borderWidth,- 2 => $"{borderWidthParts[1]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[0]}",- 3 => $"{borderWidthParts[1]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[2]}",- 4 => $"{borderWidthParts[3]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[2]}",+ 1 => shorthand,+ 2 => $"{shorthandParts[1]},{shorthandParts[0]},{shorthandParts[1]},{shorthandParts[0]}",+ 3 => $"{shorthandParts[1]},{shorthandParts[0]},{shorthandParts[1]},{shorthandParts[2]}",+ 4 => $"{shorthandParts[3]},{shorthandParts[0]},{shorthandParts[1]},{shorthandParts[2]}",_ => throw new ArgumentException(),};}diff --git a/GlazeWM.Bar/MainWindow.xaml b/GlazeWM.Bar/MainWindow.xamlindex b72baea4..553c5318 100644--- a/GlazeWM.Bar/MainWindow.xaml+++ b/GlazeWM.Bar/MainWindow.xaml@@ -19,7 +19,7 @@<BorderBorderThickness="{Binding BorderWidth}"BorderBrush="{Binding BorderColor}">- <DockPanel Margin="10">+ <DockPanel Margin="{Binding Padding}"><ItemsControl ItemsSource="{Binding Workspaces}"><ItemsControl.ItemsPanel><ItemsPanelTemplate>@@ -58,7 +58,7 @@<SetterTargetName="WorkspaceButton"Property="Background"- Value="Orange" />+ Value="#8192B3" /></DataTrigger></DataTemplate.Triggers></DataTemplate>diff --git a/GlazeWM.Domain/UserConfigs/BarConfig.cs b/GlazeWM.Domain/UserConfigs/BarConfig.csindex a4d0f8a7..13870262 100644--- a/GlazeWM.Domain/UserConfigs/BarConfig.cs+++ b/GlazeWM.Domain/UserConfigs/BarConfig.cs@@ -2,7 +2,7 @@ namespace GlazeWM.Domain.UserConfigs{public class BarConfig{- public int Height { get; set; } = 50;+ public int Height { get; set; } = 25;public string Background { get; set; } = "#101010";public string FontFamily { get; set; } = "Segoe UI";public string FontSize { get; set; } = "12";@@ -14,5 +14,10 @@ namespace GlazeWM.Domain.UserConfigs/// order./// </summary>public string BorderWidth { get; set; } = "0 0 0 0";++ /// <summary>+ /// Padding in pixels.+ /// </summary>+ public string Padding { get; set; } = "1 6 1 6";}}