diff --git a/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate b/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate index 3d6156920..312e7e52c 100644 Binary files a/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate and b/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/Core/Preferences/UserPreference.swift b/Source/Core/Preferences/UserPreference.swift index 8070ebae1..918b3b8bb 100644 --- a/Source/Core/Preferences/UserPreference.swift +++ b/Source/Core/Preferences/UserPreference.swift @@ -15,6 +15,8 @@ struct UserPreference { let defaultsKey: String let defaultValue: T + // TODO: Add a description field that can be used as a label tooltip in the Preferences UI ??? + var value: T { get { diff --git a/Source/UI/AppSetup/WindowLayoutSetup/PresetLayoutPreviewView.swift b/Source/UI/AppSetup/WindowLayoutSetup/PresetLayoutPreviewView.swift index 650f0fcf3..746a625fd 100644 --- a/Source/UI/AppSetup/WindowLayoutSetup/PresetLayoutPreviewView.swift +++ b/Source/UI/AppSetup/WindowLayoutSetup/PresetLayoutPreviewView.swift @@ -63,7 +63,7 @@ class PresetLayoutPreviewView: NSView { guard let layout = self.layout else {return} // Main Window - renderPreview(layout.mainWindowFrame.origin, 480, 200, .imgPlay.tintedWithColor(.white)) + renderPreview(layout.mainWindowFrame?.origin ?? .zero, 480, 200, .imgPlay.tintedWithColor(.white)) // Effects Window if let effectsWindowOrigin = layout.effectsWindowFrame?.origin { diff --git a/Source/UI/Menus/Base.lproj/MainMenu.xib b/Source/UI/Menus/Base.lproj/MainMenu.xib index c649bfc01..9f9b5e601 100644 --- a/Source/UI/Menus/Base.lproj/MainMenu.xib +++ b/Source/UI/Menus/Base.lproj/MainMenu.xib @@ -1094,54 +1094,6 @@ CA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/UI/Menus/ViewPopupMenu.xib b/Source/UI/Menus/ViewPopupMenu.xib index 5a979cbe0..898a02b1a 100644 --- a/Source/UI/Menus/ViewPopupMenu.xib +++ b/Source/UI/Menus/ViewPopupMenu.xib @@ -236,54 +236,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/UI/Menus/WindowLayoutPopupMenuController.swift b/Source/UI/Menus/WindowLayoutPopupMenuController.swift index cccba2e57..5891c2958 100644 --- a/Source/UI/Menus/WindowLayoutPopupMenuController.swift +++ b/Source/UI/Menus/WindowLayoutPopupMenuController.swift @@ -19,6 +19,23 @@ class WindowLayoutPopupMenuController: GenericPresetPopupMenuController { override var userDefinedPresets: [UserManagedObject] {windowLayoutsManager.userDefinedObjects} override var numberOfUserDefinedPresets: Int {windowLayoutsManager.numberOfUserDefinedObjects} + override func awakeFromNib() { + + super.awakeFromNib() + + if !builtInPresetsAdded { + + for preset in WindowLayoutPresets.allCases { + + theMenu.addItem(withTitle: preset.name, + action: #selector(applyPresetAction(_:)), + target: self) + } + + builtInPresetsAdded = true + } + } + override func presetExists(named name: String) -> Bool { windowLayoutsManager.objectExists(named: name) } diff --git a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayout.swift b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayout.swift index 80a1260cd..8c1d77c75 100644 --- a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayout.swift +++ b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayout.swift @@ -17,11 +17,14 @@ class WindowLayout { var mainWindow: LayoutWindow var auxiliaryWindows: [LayoutWindow] + var mainWindowFrame: NSRect? { + mainWindow.frame + } + var effectsWindowFrame: NSRect? { if let effectsWindow = auxiliaryWindows.first(where: {$0.id == .effects}) { -// return effectsWindow.frame - return .zero + return effectsWindow.frame } return nil @@ -30,8 +33,7 @@ class WindowLayout { var playQueueWindowFrame: NSRect? { if let playQueueWindow = auxiliaryWindows.first(where: {$0.id == .playQueue}) { -// return playQueueWindow.frame - return .zero + return playQueueWindow.frame } return nil @@ -93,6 +95,15 @@ struct LayoutWindow { let screenOffset: NSSize? let size: NSSize + var frame: NSRect? { + + if let screen, let screenOffset { + return screen.visibleFrame.offsetBy(dx: screenOffset.width, dy: screenOffset.height) + } + + return nil + } + init(id: WindowID, screen: NSScreen?, screenOffset: NSSize?, size: NSSize) { self.id = id diff --git a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets+Compute.swift b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets+Compute.swift index df84a5473..39afa4a26 100644 --- a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets+Compute.swift +++ b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets+Compute.swift @@ -1,22 +1,209 @@ // // WindowLayoutPresets+Compute.swift // Aural -// +// // Copyright © 2024 Kartik Venugopal. All rights reserved. -// +// // This software is licensed under the MIT software license. // See the file "LICENSE" in the project root directory for license terms. // import Foundation +fileprivate let playQueueHeight_verticalFullStack: CGFloat = 225 +fileprivate let playQueueHeight_verticalPlayerAndPlayQueue: CGFloat = 500 +fileprivate let playQueueHeight_bigBottomPlayQueue: CGFloat = 500 + extension WindowLayoutPresets { -// func computeLayout(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { -// -// } -// -// private func computeVerticalStack(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { -// -// } + func computeMinimal(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let xPadding = visibleFrame.width - Self.mainWindowWidth + let yPadding = visibleFrame.height - Self.mainWindowHeight + + let mainWindowOffset = NSMakeSize(xPadding / 2, + visibleFrame.height - (yPadding / 2) - Self.mainWindowHeight) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: []) + } + + func computeVerticalStack(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let twoGaps = 2 * gap + + let screenWidth = visibleFrame.width + let screenHeight = visibleFrame.height + + let playQueueHeight = min(playQueueHeight_verticalFullStack, + screenHeight - (Self.mainWindowHeight + Self.effectsWindowHeight + twoGaps)) + + let xPadding = screenWidth - Self.mainWindowWidth + let totalStackHeight = Self.mainWindowHeight + Self.effectsWindowHeight + twoGaps + playQueueHeight + let yPadding = screenHeight - totalStackHeight + + let mainWindowOffset = NSMakeSize(xPadding / 2, + screenHeight - (yPadding / 2) - Self.mainWindowHeight) + + let effectsWindowOffset = NSMakeSize(mainWindowOffset.width, mainWindowOffset.height - gap - Self.effectsWindowHeight) + + let playQueueWidth = Self.mainWindowWidth + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width, effectsWindowOffset.height - gap - playQueueHeight) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + let effectsWindow = LayoutWindow(id: .effects, screen: .main, screenOffset: effectsWindowOffset, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [effectsWindow, playQueueWindow]) + } + + func computeHorizontalStack(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let twoGaps = 2 * gap + + let playQueueWidth = max(visibleFrame.width - (Self.mainWindowWidth + Self.effectsWindowWidth + twoGaps), Self.minPlayQueueWidth) + let xPadding = visibleFrame.width - (Self.mainWindowWidth + Self.effectsWindowWidth + playQueueWidth + twoGaps) + let yPadding = visibleFrame.height - Self.mainWindowHeight + + let mainWindowOffset = NSMakeSize(max(xPadding / 2, 0), + yPadding / 2) + + let effectsWindowOffset = NSMakeSize(mainWindowOffset.width + Self.mainWindowWidth + gap, + mainWindowOffset.height) + + let playQueueHeight = Self.mainWindowHeight + + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width + Self.mainWindowWidth + Self.effectsWindowWidth + twoGaps, + mainWindowOffset.height) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let effectsWindow = LayoutWindow(id: .effects, screen: .main, screenOffset: effectsWindowOffset, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [effectsWindow, playQueueWindow]) + } + + func computeBigBottomPlayQueue(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let twoGaps = 2 * gap + + let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + Self.effectsWindowWidth) + let playQueueHeight = playQueueHeight_bigBottomPlayQueue + let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + playQueueHeight) + + let mainWindowOffset = NSMakeSize(xPadding / 2, + (yPadding / 2) + playQueueHeight + gap) + + let effectsWindowOffset = NSMakeSize(mainWindowOffset.width + Self.mainWindowWidth + gap, + mainWindowOffset.height) + + let playQueueWidth = Self.mainWindowWidth + gap + Self.effectsWindowWidth + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width, + mainWindowOffset.height - gap - playQueueHeight) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let effectsWindow = LayoutWindow(id: .effects, screen: .main, screenOffset: effectsWindowOffset, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [effectsWindow, playQueueWindow]) + } + + func computeBigLeftPlayQueue(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let playQueueWidth = Self.mainWindowWidth + let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + playQueueWidth) + let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + Self.effectsWindowHeight) + + let mainWindowOffset = NSMakeSize((xPadding / 2) + playQueueWidth + gap, + (yPadding / 2) + Self.effectsWindowHeight + gap) + + let effectsWindowOffset = NSMakeSize(mainWindowOffset.width, + mainWindowOffset.height - gap - Self.effectsWindowHeight) + + let playQueueHeight = Self.mainWindowHeight + gap + Self.effectsWindowHeight + + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width - gap - playQueueWidth, + mainWindowOffset.height - gap - Self.effectsWindowHeight) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let effectsWindow = LayoutWindow(id: .effects, screen: .main, screenOffset: effectsWindowOffset, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [effectsWindow, playQueueWindow]) + } + + func computeBigRightPlayQueue(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + Self.mainWindowWidth) + let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + Self.effectsWindowHeight) + + let mainWindowOffset = NSMakeSize((xPadding / 2), + (yPadding / 2) + Self.effectsWindowHeight + gap) + + let effectsWindowOffset = NSMakeSize(mainWindowOffset.width, + mainWindowOffset.height - gap - Self.effectsWindowHeight) + + let playQueueHeight = Self.mainWindowHeight + gap + Self.effectsWindowHeight + let playQueueWidth = Self.mainWindowWidth + + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width + Self.mainWindowWidth + gap, + mainWindowOffset.height - gap - Self.effectsWindowHeight) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let effectsWindow = LayoutWindow(id: .effects, screen: .main, screenOffset: effectsWindowOffset, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [effectsWindow, playQueueWindow]) + } + + func computeVerticalPlayerAndPlayQueue(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let xPadding = visibleFrame.width - Self.mainWindowWidth + + let playQueueHeight = playQueueHeight_verticalPlayerAndPlayQueue + let yPadding = (visibleFrame.height - Self.mainWindowHeight - playQueueHeight - gap) + let halfYPadding = yPadding / 2 + + let mainWindowOffset = NSMakeSize(xPadding / 2, + visibleFrame.height - halfYPadding - Self.mainWindowHeight) + + let playQueueWidth = Self.mainWindowWidth + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width, halfYPadding) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [playQueueWindow]) + } + + func computeHorizontalPlayerAndPlayQueue(visibleFrame: NSRect, gap: CGFloat) -> WindowLayout { + + let playQueueHeight = Self.mainWindowHeight + let playQueueWidth = Self.mainWindowWidth + + let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + playQueueWidth) + let yPadding = visibleFrame.height - Self.mainWindowHeight + + let mainWindowOffset = NSMakeSize(xPadding / 2, + yPadding / 2) + + let playQueueWindowOffset = NSMakeSize(mainWindowOffset.width + Self.mainWindowWidth + gap, + mainWindowOffset.height) + + let mainWindow = LayoutWindow(id: .main, screen: .main, screenOffset: mainWindowOffset, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) + + let playQueueWindow = LayoutWindow(id: .playQueue, screen: .main, screenOffset: playQueueWindowOffset, size: NSMakeSize(playQueueWidth, playQueueHeight)) + + return WindowLayout(name: self.name, systemDefined: true, mainWindow: mainWindow, auxiliaryWindows: [playQueueWindow]) + } } diff --git a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets.swift b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets.swift index c025ae4f2..26217a45c 100644 --- a/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets.swift +++ b/Source/UI/ModularPlayer/WindowManagement/Model/WindowLayoutPresets.swift @@ -18,10 +18,10 @@ fileprivate let playQueueHeight_verticalPlayerAndPlayQueue: CGFloat = 500 fileprivate let playQueueHeight_bigBottomPlayQueue: CGFloat = 500 enum WindowLayoutPresets: String, CaseIterable { - + + case minimal case verticalStack case horizontalStack - case compactCornered case bigBottomPlayQueue case bigLeftPlayQueue case bigRightPlayQueue @@ -71,8 +71,8 @@ enum WindowLayoutPresets: String, CaseIterable { case .horizontalStack: return "A horizontal arrangement of all 3 core components:\nPlayer, Effects, and Play Queue" - case .compactCornered: - return "Only the Player positioned at the top-left corner" + case .minimal: + return "Only the Player, centered on the screen" case .bigBottomPlayQueue: return "The Play Queue positioned below a horizontal arrangement of the Player and Effects" @@ -92,165 +92,80 @@ enum WindowLayoutPresets: String, CaseIterable { } var showEffects: Bool { - !self.equalsOneOf(.compactCornered, .verticalPlayerAndPlayQueue, .horizontalPlayerAndPlayQueue) + !self.equalsOneOf(.minimal, .verticalPlayerAndPlayQueue, .horizontalPlayerAndPlayQueue) } func layout(gap: CGFloat) -> WindowLayout { - let twoGaps = 2 * gap +// let twoGaps = 2 * gap // Compute this only once let visibleFrame = screenVisibleFrame - var mainWindowOrigin: NSPoint = .zero - var playQueueWindowOrigin: NSPoint? = nil - var effectsWindowOrigin: NSPoint? = nil - - var playQueueHeight: CGFloat = 0 - var playQueueWidth: CGFloat = 0 +// var mainWindowOrigin: NSPoint = .zero +// var playQueueWindowOrigin: NSPoint? = nil +// var effectsWindowOrigin: NSPoint? = nil +// +// var playQueueHeight: CGFloat = 0 +// var playQueueWidth: CGFloat = 0 switch self { // Top left corner - case .compactCornered: + case .minimal: - mainWindowOrigin = NSMakePoint(visibleFrame.minX, visibleFrame.maxY - Self.mainWindowHeight) + return computeMinimal(visibleFrame: visibleFrame, gap: gap) case .verticalStack: - playQueueHeight = min(playQueueHeight_verticalFullStack, - visibleFrame.height - (Self.mainWindowHeight + Self.effectsWindowHeight + twoGaps)) - - let xPadding = visibleFrame.width - Self.mainWindowWidth - let totalStackHeight = Self.mainWindowHeight + Self.effectsWindowHeight + twoGaps + playQueueHeight - let yPadding = visibleFrame.height - totalStackHeight - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2), - visibleFrame.maxY - (yPadding / 2) - Self.mainWindowHeight) - - effectsWindowOrigin = NSMakePoint(mainWindowOrigin.x, mainWindowOrigin.y - gap - Self.effectsWindowHeight) - - playQueueWidth = Self.mainWindowWidth - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x, effectsWindowOrigin!.y - gap - playQueueHeight) + return computeVerticalStack(visibleFrame: visibleFrame, gap: gap) case .horizontalStack: - // Sometimes, xPadding is negative, never go to the left of minX - playQueueWidth = max(visibleFrame.width - (Self.mainWindowWidth + Self.effectsWindowWidth + twoGaps), Self.minPlayQueueWidth) - let xPadding = visibleFrame.width - (Self.mainWindowWidth + Self.effectsWindowWidth + playQueueWidth + twoGaps) - let yPadding = visibleFrame.height - Self.mainWindowHeight - - mainWindowOrigin = NSMakePoint(max(visibleFrame.minX + (xPadding / 2), visibleFrame.minX), - visibleFrame.minY + (yPadding / 2)) - - effectsWindowOrigin = NSMakePoint(mainWindowOrigin.x + Self.mainWindowWidth + gap, - mainWindowOrigin.y) - - playQueueHeight = Self.mainWindowHeight - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x + Self.mainWindowWidth + Self.effectsWindowWidth + twoGaps, - mainWindowOrigin.y) + return computeHorizontalStack(visibleFrame: visibleFrame, gap: gap) case .bigBottomPlayQueue: - let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + Self.effectsWindowWidth) - playQueueHeight = playQueueHeight_bigBottomPlayQueue - let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + playQueueHeight) - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2), - visibleFrame.minY + (yPadding / 2) + playQueueHeight + gap) - - effectsWindowOrigin = NSMakePoint(mainWindowOrigin.x + Self.mainWindowWidth + gap, - mainWindowOrigin.y) - - playQueueWidth = Self.mainWindowWidth + gap + Self.effectsWindowWidth - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x, - mainWindowOrigin.y - gap - playQueueHeight) + return computeBigBottomPlayQueue(visibleFrame: visibleFrame, gap: gap) case .bigLeftPlayQueue: - let pWidth = Self.mainWindowWidth - let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + pWidth) - let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + Self.effectsWindowHeight) - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2) + pWidth + gap, - visibleFrame.minY + (yPadding / 2) + Self.effectsWindowHeight + gap) - - effectsWindowOrigin = NSMakePoint(mainWindowOrigin.x, - mainWindowOrigin.y - gap - Self.effectsWindowHeight) - - playQueueHeight = Self.mainWindowHeight + gap + Self.effectsWindowHeight - playQueueWidth = Self.mainWindowWidth - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x - gap - playQueueWidth, - mainWindowOrigin.y - gap - Self.effectsWindowHeight) + return computeBigLeftPlayQueue(visibleFrame: visibleFrame, gap: gap) case .bigRightPlayQueue: - let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + Self.mainWindowWidth) - let yPadding = visibleFrame.height - (Self.mainWindowHeight + gap + Self.effectsWindowHeight) - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2), - visibleFrame.minY + (yPadding / 2) + Self.effectsWindowHeight + gap) - - effectsWindowOrigin = NSMakePoint(mainWindowOrigin.x, mainWindowOrigin.y - gap - Self.effectsWindowHeight) - - playQueueHeight = Self.mainWindowHeight + gap + Self.effectsWindowHeight - playQueueWidth = Self.mainWindowWidth - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x + Self.mainWindowWidth + gap, - mainWindowOrigin.y - gap - Self.effectsWindowHeight) + return computeBigRightPlayQueue(visibleFrame: visibleFrame, gap: gap) case .verticalPlayerAndPlayQueue: - let xPadding = visibleFrame.width - Self.mainWindowWidth - - playQueueHeight = playQueueHeight_verticalPlayerAndPlayQueue - let yPadding = (visibleFrame.height - Self.mainWindowHeight - playQueueHeight - gap) - let halfYPadding = yPadding / 2 - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2), - visibleFrame.maxY - halfYPadding - Self.mainWindowHeight) - - - playQueueWidth = Self.mainWindowWidth - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x, visibleFrame.minY + halfYPadding) + return computeVerticalPlayerAndPlayQueue(visibleFrame: visibleFrame, gap: gap) case .horizontalPlayerAndPlayQueue: - playQueueHeight = Self.mainWindowHeight - playQueueWidth = Self.mainWindowWidth - - let xPadding = visibleFrame.width - (Self.mainWindowWidth + gap + playQueueWidth) - let yPadding = visibleFrame.height - Self.mainWindowHeight - - mainWindowOrigin = NSMakePoint(visibleFrame.minX + (xPadding / 2), visibleFrame.minY + (yPadding / 2)) - - playQueueWindowOrigin = NSMakePoint(mainWindowOrigin.x + Self.mainWindowWidth + gap, mainWindowOrigin.y) + return computeHorizontalPlayerAndPlayQueue(visibleFrame: visibleFrame, gap: gap) } - - let mainWindowFrame: NSRect = NSRect(origin: mainWindowOrigin, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) - - var displayedWindows: [LayoutWindow] = [] - - if let playQueueWindowOrigin = playQueueWindowOrigin { - - let playQueueWindowFrame: NSRect = NSMakeRect(playQueueWindowOrigin.x, playQueueWindowOrigin.y, playQueueWidth, playQueueHeight) - let playQueueWindow: LayoutWindow = .init(id: .playQueue, screen: .main!, screenOffset: .zero, size: .zero) - - displayedWindows.append(playQueueWindow) - } - - if let effectsWindowOrigin = effectsWindowOrigin { - - let effectsWindowFrame: NSRect = NSRect(origin: effectsWindowOrigin, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) - let effectsWindow: LayoutWindow = .init(id: .effects, screen: .main!, screenOffset: .zero, size: .zero) - - displayedWindows.append(effectsWindow) - } - - return WindowLayout(name: name, systemDefined: true, mainWindowFrame: mainWindowFrame, displayedWindows: displayedWindows) +// +// let mainWindowFrame: NSRect = NSRect(origin: mainWindowOrigin, size: NSMakeSize(Self.mainWindowWidth, Self.mainWindowHeight)) +// +// var displayedWindows: [LayoutWindow] = [] +// +// if let playQueueWindowOrigin = playQueueWindowOrigin { +// +// let playQueueWindowFrame: NSRect = NSMakeRect(playQueueWindowOrigin.x, playQueueWindowOrigin.y, playQueueWidth, playQueueHeight) +// let playQueueWindow: LayoutWindow = .init(id: .playQueue, screen: .main!, screenOffset: .zero, size: .zero) +// +// displayedWindows.append(playQueueWindow) +// } +// +// if let effectsWindowOrigin = effectsWindowOrigin { +// +// let effectsWindowFrame: NSRect = NSRect(origin: effectsWindowOrigin, size: NSMakeSize(Self.effectsWindowWidth, Self.effectsWindowHeight)) +// let effectsWindow: LayoutWindow = .init(id: .effects, screen: .main!, screenOffset: .zero, size: .zero) +// +// displayedWindows.append(effectsWindow) +// } +// +// return self.computeVerticalStack(visibleFrame: visibleFrame, gap: gap) +// return WindowLayout(name: name, systemDefined: true, mainWindowFrame: mainWindowFrame, displayedWindows: displayedWindows) } } diff --git a/Source/UI/ModularPlayer/WindowManagement/WindowLayoutsManager.swift b/Source/UI/ModularPlayer/WindowManagement/WindowLayoutsManager.swift index 0f98293ea..0461f95b4 100644 --- a/Source/UI/ModularPlayer/WindowManagement/WindowLayoutsManager.swift +++ b/Source/UI/ModularPlayer/WindowManagement/WindowLayoutsManager.swift @@ -166,7 +166,7 @@ class WindowLayoutsManager: UserManagedObjects, Destroyable, Resto let actualWindow = getWindow(forId: window.id) - if windowMagnetismEnabled { + if window.id != .main, windowMagnetismEnabled { mainWindow.addChildWindow(actualWindow, ordered: .below) } @@ -214,7 +214,17 @@ class WindowLayoutsManager: UserManagedObjects, Destroyable, Resto screenOffset: screenOffset, size: child.frame.size)) } - return WindowLayout(name: "_system_", systemDefined: true, mainWindowFrame: self.mainWindowFrame, auxiliaryWindows: windows) + let mainWindow = self.mainWindow + + var screenOffset: NSSize? = nil + + if let screen = mainWindow.screen { + screenOffset = mainWindow.frame.origin.distanceFrom(screen.frame.origin) + } + + return WindowLayout(name: "_system_", systemDefined: true, + mainWindow: LayoutWindow(id: .main, screen: mainWindow.screen, screenOffset: screenOffset, size: mainWindow.size), + auxiliaryWindows: windows) } // var isShowingEffects: Bool {