Skip to content

Commit

Permalink
#118 Computation of preset win layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-venugopal committed Dec 8, 2024
1 parent 67aa33d commit 502c19e
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 241 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/Core/Preferences/UserPreference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct UserPreference<T> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
48 changes: 0 additions & 48 deletions Source/UI/Menus/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1094,54 +1094,6 @@ CA
<menu key="submenu" title=" Window Layout" id="fGS-p2-B4l">
<items>
<menuItem isSeparatorItem="YES" id="m3b-U9-DmA"/>
<menuItem title="Vertical full stack" id="895-XH-ur7">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="7ca-Kg-QMb"/>
</connections>
</menuItem>
<menuItem title="Horizontal full stack" id="4XH-HT-2V4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="EOx-cD-KnW"/>
</connections>
</menuItem>
<menuItem title="Big bottom play queue" id="jDD-h3-g2d">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="jgC-0a-GFT"/>
</connections>
</menuItem>
<menuItem title="Big right play queue" id="BwZ-En-aiD">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="dls-cs-Cbe"/>
</connections>
</menuItem>
<menuItem title="Big left play queue" id="EA2-lX-2f0">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="GSN-on-k6C"/>
</connections>
</menuItem>
<menuItem title="Vertical player and play queue" id="j0t-qu-Gbz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="Fxu-UD-flD"/>
</connections>
</menuItem>
<menuItem title="Horizontal player and play queue" id="ybr-qf-bha">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="GYQ-aB-KxY"/>
</connections>
</menuItem>
<menuItem title="Compact cornered" id="HA6-0R-MMo">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="ARU-wE-JsS" id="Y0L-IE-sGa"/>
</connections>
</menuItem>
</items>
<connections>
<outlet property="delegate" destination="ARU-wE-JsS" id="bYN-tb-9Z4"/>
Expand Down
48 changes: 0 additions & 48 deletions Source/UI/Menus/ViewPopupMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -236,54 +236,6 @@
<menu key="submenu" title="Window layout" id="Sih-We-V6Y">
<items>
<menuItem isSeparatorItem="YES" id="Klx-0i-JS2"/>
<menuItem title="Vertical stack" id="r4O-rz-kay">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="QJh-aa-I6Z"/>
</connections>
</menuItem>
<menuItem title="Horizontal stack" id="zRU-2h-GBc">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="eST-gU-K7G"/>
</connections>
</menuItem>
<menuItem title="Big bottom play queue" id="X3p-Q6-OXe">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="gC4-tl-Ard"/>
</connections>
</menuItem>
<menuItem title="Big right play queue" id="yZa-D1-rl5">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="txt-l5-F6v"/>
</connections>
</menuItem>
<menuItem title="Big left play queue" id="iuJ-f8-sgb">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="1Hr-UD-B41"/>
</connections>
</menuItem>
<menuItem title="Vertical player and play queue" id="sc6-5a-W9n">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="IUz-Xa-U97"/>
</connections>
</menuItem>
<menuItem title="Horizontal player and play queue" id="a1D-m8-YXX">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="PMG-WR-7b6"/>
</connections>
</menuItem>
<menuItem title="Compact cornered" id="01s-xv-cgd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="applyPresetAction:" target="Qe0-75-TrI" id="IRZ-Pj-B7C"/>
</connections>
</menuItem>
</items>
<connections>
<outlet property="delegate" destination="Qe0-75-TrI" id="mHu-nn-jsw"/>
Expand Down
17 changes: 17 additions & 0 deletions Source/UI/Menus/WindowLayoutPopupMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
19 changes: 15 additions & 4 deletions Source/UI/ModularPlayer/WindowManagement/Model/WindowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 502c19e

Please sign in to comment.