Skip to content

Commit

Permalink
fix: big sur menu bar layout change cause set wrong rating issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MainasuK committed Aug 5, 2020
1 parent 6288cb7 commit 9737a5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 10e6f5005867dbb3964c6d40690aff5abd64540b

COCOAPODS: 1.9.1
COCOAPODS: 1.9.3
10 changes: 8 additions & 2 deletions Song Rating/Controls/RatingControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ extension RatingControl {

// assert image center aligment without resize and leading & tariling margin added
let position = sender.convert(event.locationInWindow, to: nil) // leading margin | image | trailing margin
let systemLeftMargin = 0.5 * (width - imageWidth) // leading margin (default 4 on menu bar)
let positionX = position.x - systemLeftMargin // -leading margin ~ image.size.with
let systemLeftMargin: CGFloat = {
if #available(macOS 11.0, *) {
return 20 + 0.5 * (width - imageWidth) // big sur magic container width + leading margin
} else {
return 0.5 * (width - imageWidth) // leading margin (default 4)
}
}()
let positionX = position.x - systemLeftMargin // x in range: -leading margin ~ image.size.with

var rating: Int?
let array = Array(0..<5)
Expand Down

0 comments on commit 9737a5f

Please sign in to comment.