Skip to content

Commit

Permalink
fix: wrap thumbnail buttons when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
decodism authored and lwouis committed Oct 14, 2022
1 parent d207f86 commit ea05c03
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ui/main-window/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,21 @@ class ThumbnailView: NSStackView {
isShowingWindowControls = shouldShow
let target = (window_?.isWindowlessApp ?? true) ? windowlessIcon : thumbnail
target.addSubview(quitIcon, positioned: .above, relativeTo: nil)
var offset = CGFloat(0)
var xOffset = CGFloat(3)
var yOffset = CGFloat(2 + ThumbnailView.windowsControlSize)
[quitIcon, closeIcon, minimizeIcon, maximizeIcon].forEach { icon in
icon.isHidden = !shouldShow ||
((window_?.isWindowlessApp ?? true) && icon.type != .quit) ||
(icon.type == .quit && window_?.application.runningApplication.bundleIdentifier == "com.apple.finder" && !Preferences.finderShowsQuitMenuItem)
if !icon.isHidden {
icon.setFrameOrigin(NSPoint(
x: 3 + (ThumbnailView.windowsControlSpacing + ThumbnailView.windowsControlSize) * offset,
y: target.frame.height - ThumbnailView.windowsControlSize - 2))
offset += 1
x: xOffset,
y: target.frame.height - yOffset))
xOffset += ThumbnailView.windowsControlSize + ThumbnailView.windowsControlSpacing
if xOffset + ThumbnailView.windowsControlSize > target.frame.width {
xOffset = 3
yOffset += ThumbnailView.windowsControlSize + ThumbnailView.windowsControlSpacing
}
}
}
}
Expand Down

0 comments on commit ea05c03

Please sign in to comment.