Skip to content

Commit

Permalink
Lyrics view sizing + validations
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-venugopal committed Jan 6, 2025
1 parent 800bd60 commit 94040a3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 8 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/UI/AppModeManagement/UnifiedAppModeController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UnifiedAppModeController: AppModeController {
}

var isShowingLyrics: Bool {
true
windowController?.isShowingLyrics ?? false
}

var isShowingEffects: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension CompactPlayerWindowController {
}

var isShowingLyrics: Bool {
true
compactPlayerUIState.displayedView == .lyrics
}

var isShowingEffects: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ class CompactPlayerLyricsViewController: LyricsViewController {
// The desired row height is the maximum of the two heights, plus some padding
return max(30, rowHeight + 5)
}

override func trackTransitioned(_ notif: TrackTransitionNotification) {

guard appModeManager.isShowingLyrics else {return}

updateForTrack(notif.endTrack)

if notif.endTrack == nil {
messenger.publish(.View.CompactPlayer.showPlayer)
}
}
}
10 changes: 10 additions & 0 deletions Source/UI/Effects/SheetView/EffectsSheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class EffectsSheetViewController: NSViewController {
effectsViewController.showTab(.master)
}

override func viewDidAppear() {

super.viewDidAppear()

// Disable resizing of the view
let contentSize = effectsViewController.view.frame.size
view.window?.minSize = contentSize
view.window?.maxSize = contentSize
}

@IBAction func closeAction(_ sender: NSButton) {
endSheet()
}
Expand Down
4 changes: 2 additions & 2 deletions Source/UI/Lyrics/LyricsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class LyricsViewController: NSViewController {
tabView.selectedIndex == 1
}

private func updateForTrack(_ track: Track?) {
func updateForTrack(_ track: Track?) {

self.track = track

Expand Down Expand Up @@ -105,7 +105,7 @@ class LyricsViewController: NSViewController {
}
}

private func trackTransitioned(_ notif: TrackTransitionNotification) {
func trackTransitioned(_ notif: TrackTransitionNotification) {

if appModeManager.isShowingLyrics {
updateForTrack(notif.endTrack)
Expand Down
9 changes: 9 additions & 0 deletions Source/UI/Lyrics/SheetView/LyricsSheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ class LyricsSheetViewController: NSViewController {
@IBOutlet weak var btnClose: TintedImageButton!
@IBOutlet weak var lyricsViewController: LyricsViewController!

private static let windowMinSize: NSSize = NSMakeSize(400, 200)

override func viewDidLoad() {

super.viewDidLoad()
view.addSubview(lyricsViewController.view)

lyricsViewController.view.anchorToSuperview()

btnClose.bringToFront()
Expand All @@ -29,6 +32,12 @@ class LyricsSheetViewController: NSViewController {
colorSchemesManager.registerPropertyObserver(self, forProperty: \.buttonColor, changeReceiver: btnClose)
}

override func viewDidAppear() {

super.viewDidAppear()
view.window?.minSize = Self.windowMinSize
}

@IBAction func closeAction(_ sender: NSButton) {
endSheet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class LyricsPreferencesViewController: NSViewController, PreferencesViewProtocol

private var lyricsFilesFolder: URL?

private static let disabledControlTooltip: String = "<This preference is only applicable to the \"Modular\" and \"Unified\" app modes>"

var preferencesView: NSView {
view
}
Expand All @@ -40,6 +42,16 @@ class LyricsPreferencesViewController: NSViewController, PreferencesViewProtocol
} else {
lblLyricsFolder.stringValue = ""
}

disableIrrelevantControls()
}

private func disableIrrelevantControls() {

guard let currentMode = appModeManager.currentMode, !currentMode.equalsOneOf(.modular, .unified) else {return}

btnEnableAutoShowWindow.disable()
btnEnableAutoShowWindow.toolTip = Self.disabledControlTooltip
}

@IBAction func chooseLyricsFolderAction(_ sender: NSButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class ViewPreferencesViewController: NSViewController, PreferencesViewProtocol {

btnShowLyricsTranslation.onIf(viewPrefs.showLyricsTranslation.value)

if appModeManager.currentMode != .modular {
disableIrrelevantControls()
}
disableIrrelevantControls()
}

private func disableIrrelevantControls() {

guard appModeManager.currentMode != .modular else {return}

[btnSnapToWindows, gapStepper].forEach {

$0?.toolTip = Self.disabledControlTooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ extension UnifiedPlayerWindowController {
}

var isShowingEffects: Bool {
attachedSheetViewController != nil
attachedSheetViewController == effectsSheetViewController
}

var isShowingChaptersList: Bool {
tabGroup.selectedIndex == 1
}

var isShowingLyrics: Bool {
attachedSheetViewController == lyricsSheetViewController
}

// TODO: Viz
var isShowingVisualizer: Bool {
false
Expand Down

0 comments on commit 94040a3

Please sign in to comment.