Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shorthand syntax to outer gaps #282

Merged
merged 1 commit into from
Jul 23, 2023
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
2 changes: 1 addition & 1 deletion GlazeWM.Domain/UserConfigs/CommandParsingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static List<string> ExtractProcessArgs(string processNameAndArgs)
return args.Where(arg => !string.IsNullOrWhiteSpace(arg)).ToList();
}

private static RectDelta ShorthandToRectDelta(string shorthand)
public static RectDelta ShorthandToRectDelta(string shorthand)
{
var shorthandParts = shorthand.Split(" ")
.Select(shorthandPart => UnitsHelper.TrimUnits(shorthandPart))
Expand Down
2 changes: 1 addition & 1 deletion GlazeWM.Domain/UserConfigs/GapsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace GlazeWM.Domain.UserConfigs
public class GapsConfig
{
public int InnerGap { get; set; } = 20;
public int OuterGap { get; set; } = 20;
public string OuterGap { get; set; } = "20px";
}
}
15 changes: 8 additions & 7 deletions GlazeWM.Domain/Workspaces/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using GlazeWM.Domain.UserConfigs;
using GlazeWM.Infrastructure;
using GlazeWM.Infrastructure.Utils;
using GlazeWM.Infrastructure.WindowsApi;

namespace GlazeWM.Domain.Workspaces
{
Expand Down Expand Up @@ -46,7 +47,7 @@ private int _yOffset
}
}

private int _outerGap => _userConfigService.GapsConfig.OuterGap;
private RectDelta _outerGaps => CommandParsingService.ShorthandToRectDelta(_userConfigService.GapsConfig.OuterGap);

private BarConfig barForMonitor => _userConfigService.GetBarConfigForMonitor(Parent as Monitor);
private int floatBarOffsetY => UnitsHelper.TrimUnits(barForMonitor.OffsetY);
Expand All @@ -57,25 +58,25 @@ public override int Height
{
if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
{
return Parent.Height - (_outerGap * 2);
return Parent.Height - _outerGaps.Top - _outerGaps.Bottom;
}

return Parent.Height - (_outerGap * 2) - floatBarOffsetY - _logicalBarHeight;
return Parent.Height - _outerGaps.Top - _outerGaps.Bottom - floatBarOffsetY - _logicalBarHeight;
}
}

public override int Width => Parent.Width - (_outerGap * 2);
public override int X => Parent.X + _outerGap;
public override int Width => Parent.Width - _outerGaps.Left - _outerGaps.Right;
public override int X => Parent.X + _outerGaps.Left;
public override int Y
{
get
{
if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
{
return Parent.Y + _outerGap;
return Parent.Y + _outerGaps.Top;
}

return Parent.Y + _outerGap + _yOffset + floatBarOffsetY;
return Parent.Y + _outerGaps.Top + _yOffset + floatBarOffsetY;
}
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ gaps:
# Gap between adjacent windows.
inner_gap: 20

# Gap between windows and the screen edge.
outer_gap: 20
# Gap between windows and the screen edge. See "Shorthand properties" for more info.
outer_gap: "20px 0 20px 0"
```

## Workspaces configuration
Expand Down