Skip to content

Commit

Permalink
#49 Initial support resize icons in menubar resize items
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Oct 9, 2023
1 parent 6e23656 commit 46735c3
Show file tree
Hide file tree
Showing 9 changed files with 531 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Loop/Assets.xcassets/SF Symbols/Window Resize/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"symbols" : [
{
"filename" : "rectangle.centerthird.inset.filled.svg",
"idiom" : "universal"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"symbols" : [
{
"filename" : "rectangle.lefttwothirds.inset.filled.svg",
"idiom" : "universal"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"symbols" : [
{
"filename" : "rectangle.righttwothirds.inset.filled.svg",
"idiom" : "universal"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Loop/MenuBarResizeButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ struct MenuBarResizeButton: View {
}
} label: {
HStack {
if let image = direction.image {
Image(nsImage: image)
}
Text(name)
}
}
Expand Down
33 changes: 33 additions & 0 deletions Loop/Window Management/WindowDirection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,39 @@ enum WindowDirection: CaseIterable, Identifiable {
}
}

var image: NSImage? {
switch self {
case .maximize: NSImage(systemSymbolName: "rectangle.inset.filled", accessibilityDescription: nil)
case .fullscreen: NSImage(systemSymbolName: "rectangle.fill", accessibilityDescription: nil)
// case .lastDirection:
case .center: NSImage(systemSymbolName: "rectangle.center.inset.filled", accessibilityDescription: nil)
case .initialFrame: NSImage(systemSymbolName: "macwindow", accessibilityDescription: nil)

case .topHalf: NSImage(systemSymbolName: "rectangle.tophalf.inset.filled", accessibilityDescription: nil)
case .rightHalf: NSImage(systemSymbolName: "rectangle.righthalf.inset.filled", accessibilityDescription: nil)
case .bottomHalf: NSImage(systemSymbolName: "rectangle.bottomhalf.inset.filled", accessibilityDescription: nil)
case .leftHalf: NSImage(systemSymbolName: "rectangle.lefthalf.inset.filled", accessibilityDescription: nil)

case .topLeftQuarter: NSImage(systemSymbolName: "rectangle.inset.topleft.filled", accessibilityDescription: nil)
case .topRightQuarter: NSImage(systemSymbolName: "rectangle.inset.topright.filled", accessibilityDescription: nil)
case .bottomRightQuarter: NSImage(systemSymbolName: "rectangle.inset.bottomright.filled", accessibilityDescription: nil)
case .bottomLeftQuarter: NSImage(systemSymbolName: "rectangle.inset.bottomleft.filled", accessibilityDescription: nil)

case .rightThird: NSImage(systemSymbolName: "rectangle.rightthird.inset.filled", accessibilityDescription: nil)
case .rightTwoThirds: NSImage(named: "rectangle.righttwothirds.inset.filled")
case .horizontalCenterThird: NSImage(named: "rectangle.centerthird.inset.filled")
case .leftThird: NSImage(systemSymbolName: "rectangle.leftthird.inset.filled", accessibilityDescription: nil)
case .leftTwoThirds: NSImage(named: "rectangle.lefttwothirds.inset.filled")

case .topThird: NSImage(systemSymbolName: "rectangle.topthird.inset.filled", accessibilityDescription: nil)
// case .topTwoThirds:
// case .verticalCenterThird:
case .bottomThird: NSImage(systemSymbolName: "rectangle.bottomthird.inset.filled", accessibilityDescription: nil)
// case .bottomTwoThirds:
default: nil
}
}

var edgesTouchingScreen: [Edge] {
switch self {
case .maximize: [.top, .bottom, .leading, .trailing]
Expand Down

0 comments on commit 46735c3

Please sign in to comment.