feat: improve switcher layout and presentation
This commit is contained in:
1 parent
649a5cb86a
commit
545b5db143
1 file changed
+22
-12
+22
-12
@@ -14,8 +14,8 @@ class Appearance {
|
|||||||
static var windowMaxWidthInRow = CGFloat(0)
|
static var windowMaxWidthInRow = CGFloat(0)
|
||||||
static var iconSize = CGFloat(0)
|
static var iconSize = CGFloat(0)
|
||||||
static var fontHeight = CGFloat(0)
|
static var fontHeight = CGFloat(0)
|
||||||
static var maxWidthOnScreen = CGFloat(0)
|
static var maxWidthOnScreen = CGFloat(0.8)
|
||||||
static var maxHeightOnScreen = CGFloat(0)
|
static var maxHeightOnScreen = CGFloat(0.8)
|
||||||
|
|
||||||
// theme
|
// theme
|
||||||
static var material = NSVisualEffectView.Material.dark
|
static var material = NSVisualEffectView.Material.dark
|
||||||
@@ -72,6 +72,24 @@ class Appearance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate windowMinWidthInRow and windowMaxWidthInRow such that:
|
||||||
|
// * fullscreen windows fill their tile vertically
|
||||||
|
// * narrow windows have enough width that a few words can be read from their title
|
||||||
|
private static func calculateGoodValuesForThumbnailsWidthMinMax() -> (CGFloat, CGFloat) {
|
||||||
|
let aspectRatio = NSScreen.preferred().ratio()
|
||||||
|
let minRatio: CGFloat
|
||||||
|
let maxRatio: CGFloat
|
||||||
|
if aspectRatio >= 1 {
|
||||||
|
minRatio = 0.7 / (aspectRatio * rowsCount)
|
||||||
|
maxRatio = 1.5 / (aspectRatio * rowsCount)
|
||||||
|
} else {
|
||||||
|
minRatio = 1.3 / rowsCount
|
||||||
|
maxRatio = 2.1 / rowsCount
|
||||||
|
}
|
||||||
|
// Make sure the values are clamped between some reasonable bounds
|
||||||
|
return (max(0.09, minRatio), min(0.3, maxRatio))
|
||||||
|
}
|
||||||
|
|
||||||
private static func thumbnailsSize(_ isHorizontalScreen: Bool) {
|
private static func thumbnailsSize(_ isHorizontalScreen: Bool) {
|
||||||
hideThumbnails = false
|
hideThumbnails = false
|
||||||
windowPadding = 18
|
windowPadding = 18
|
||||||
@@ -80,10 +98,6 @@ class Appearance {
|
|||||||
intraCellPadding = 5
|
intraCellPadding = 5
|
||||||
interCellPadding = 1
|
interCellPadding = 1
|
||||||
edgeInsetsSize = 12
|
edgeInsetsSize = 12
|
||||||
maxWidthOnScreen = 0.9
|
|
||||||
maxHeightOnScreen = 0.8
|
|
||||||
windowMinWidthInRow = 0.1
|
|
||||||
windowMaxWidthInRow = 0.15
|
|
||||||
switch currentSize {
|
switch currentSize {
|
||||||
case .small:
|
case .small:
|
||||||
rowsCount = isHorizontalScreen ? 5 : 8
|
rowsCount = isHorizontalScreen ? 5 : 8
|
||||||
@@ -95,11 +109,10 @@ class Appearance {
|
|||||||
fontHeight = 13
|
fontHeight = 13
|
||||||
case .large:
|
case .large:
|
||||||
rowsCount = isHorizontalScreen ? 3 : 6
|
rowsCount = isHorizontalScreen ? 3 : 6
|
||||||
windowMinWidthInRow = 0.15
|
|
||||||
windowMaxWidthInRow = 0.3
|
|
||||||
iconSize = 32
|
iconSize = 32
|
||||||
fontHeight = 16
|
fontHeight = 16
|
||||||
}
|
}
|
||||||
|
(windowMinWidthInRow, windowMaxWidthInRow) = calculateGoodValuesForThumbnailsWidthMinMax()
|
||||||
if currentVisibility == .highest {
|
if currentVisibility == .highest {
|
||||||
edgeInsetsSize = 10
|
edgeInsetsSize = 10
|
||||||
cellCornerRadius = 12
|
cellCornerRadius = 12
|
||||||
@@ -114,8 +127,6 @@ class Appearance {
|
|||||||
intraCellPadding = 5
|
intraCellPadding = 5
|
||||||
interCellPadding = 1
|
interCellPadding = 1
|
||||||
edgeInsetsSize = 5
|
edgeInsetsSize = 5
|
||||||
maxWidthOnScreen = 0.95
|
|
||||||
maxHeightOnScreen = 0.9
|
|
||||||
windowMinWidthInRow = 0.04
|
windowMinWidthInRow = 0.04
|
||||||
windowMaxWidthInRow = 0.3
|
windowMaxWidthInRow = 0.3
|
||||||
rowsCount = 1
|
rowsCount = 1
|
||||||
@@ -141,8 +152,7 @@ class Appearance {
|
|||||||
intraCellPadding = 5
|
intraCellPadding = 5
|
||||||
interCellPadding = 1
|
interCellPadding = 1
|
||||||
edgeInsetsSize = 7
|
edgeInsetsSize = 7
|
||||||
maxWidthOnScreen = isHorizontalScreen ? 0.6 : 0.85
|
maxWidthOnScreen = isHorizontalScreen ? 0.6 : 0.8
|
||||||
maxHeightOnScreen = 0.8
|
|
||||||
windowMinWidthInRow = 0.6
|
windowMinWidthInRow = 0.6
|
||||||
windowMaxWidthInRow = 0.9
|
windowMaxWidthInRow = 0.9
|
||||||
rowsCount = 1
|
rowsCount = 1
|
||||||
|
|||||||
Reference in new issue
Block a user