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

Fix lyrics offset on macOS Big Sur and later #578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion LyricsX/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<connections>
<outlet property="lyricsOffsetStepper" destination="FwA-Sj-odc" id="Wpt-Xo-ryF"/>
<outlet property="lyricsOffsetTextField" destination="BE8-Ux-QD2" id="U25-Zx-LxS"/>
<outlet property="lyricsOffsetView" destination="LV9-pp-2tz" id="XY6-hn-HAX"/>
<outlet property="statusBarMenu" destination="OCV-Y8-x1C" id="zHx-WQ-Hu4"/>
</connections>
</customObject>
Expand Down Expand Up @@ -451,7 +452,7 @@
<constraints>
<constraint firstItem="DG2-8b-vTy" firstAttribute="centerY" secondItem="LV9-pp-2tz" secondAttribute="centerY" id="5gA-e2-0RM"/>
<constraint firstItem="BE8-Ux-QD2" firstAttribute="leading" secondItem="DG2-8b-vTy" secondAttribute="trailing" constant="8" id="66I-Ch-hG0"/>
<constraint firstItem="DG2-8b-vTy" firstAttribute="leading" secondItem="LV9-pp-2tz" secondAttribute="leading" constant="21" id="826-cy-w1T"/>
<constraint firstItem="DG2-8b-vTy" firstAttribute="leading" secondItem="LV9-pp-2tz" secondAttribute="leading" constant="21" identifier="lyricsOffsetConstraint" id="826-cy-w1T"/>
<constraint firstItem="FwA-Sj-odc" firstAttribute="leading" secondItem="BE8-Ux-QD2" secondAttribute="trailing" constant="5" id="9G1-eA-c8X"/>
<constraint firstItem="BE8-Ux-QD2" firstAttribute="top" secondItem="LV9-pp-2tz" secondAttribute="top" constant="2" id="Jw4-sr-Qu8"/>
<constraint firstItem="0ii-PC-ZCl" firstAttribute="centerY" secondItem="LV9-pp-2tz" secondAttribute="centerY" id="Yhp-74-yJR"/>
Expand Down
16 changes: 16 additions & 0 deletions LyricsX/Component/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation, NSMenu
return NSApplication.shared.delegate as? AppDelegate
}

@IBOutlet weak var lyricsOffsetView: NSView!
@IBOutlet weak var lyricsOffsetTextField: NSTextField!
@IBOutlet weak var lyricsOffsetStepper: NSStepper!
@IBOutlet weak var statusBarMenu: NSMenu!
Expand Down Expand Up @@ -140,6 +141,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation, NSMenu
menu.item(withTag: 202)?.isEnabled = AppController.shared.currentLyrics != nil
}

func menuWillOpen(_ menu: NSMenu) {
if #available(macOS 10.16, *) {
let menuHasOnState = statusBarMenu.items.filter { menuItem in
return menuItem.state == .on
}.count > 0

let lyricsOffsetConstraint = lyricsOffsetView.constraints.first(where: {$0.identifier == "lyricsOffsetConstraint"})

lyricsOffsetConstraint?.constant = 14
if menuHasOnState {
lyricsOffsetConstraint?.constant += 10
}
}
}

// MARK: - Menubar Action

var lyricsHUD: NSWindowController?
Expand Down