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

Option for smaller Popover #177

Open
wants to merge 8 commits 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
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f237920f869d400b1819fdc4dd988f78ac218ef7

COCOAPODS: 1.5.3
COCOAPODS: 1.6.0
14 changes: 12 additions & 2 deletions SpotMenu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
64F112A821933CA400753E83 /* ScrollingTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64F112A621933ACB00753E83 /* ScrollingTextView.swift */; };
64F29A091F2E5F1100E48BBD /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 64F29A0B1F2E5F1100E48BBD /* Localizable.strings */; };
98C18916984B50AAD9E17661 /* Pods_SpotMenu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADFCF0607F980ADD8D5D03FA /* Pods_SpotMenu.framework */; };
A02DF2CF221BB1C700222929 /* PopOverSmall.xib in Resources */ = {isa = PBXBuildFile; fileRef = A02DF2CE221BB1C700222929 /* PopOverSmall.xib */; };
A02DF2D2221BCDB700222929 /* StaticFadeIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02DF2D1221BCDB700222929 /* StaticFadeIn.swift */; };
A02DF2D3221BCFCD00222929 /* StaticFadeIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02DF2D1221BCDB700222929 /* StaticFadeIn.swift */; };
DB2C500E2199F94000932042 /* ScrollingStatusItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB2C500D2199F94000932042 /* ScrollingStatusItemView.swift */; };
E2D35CCB1F60827B00EB5D67 /* CustomVisualEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648984831E5C21C200EA2234 /* CustomVisualEffect.swift */; };
E2D35CCE1F60879700EB5D67 /* NSViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2D35CCD1F60879700EB5D67 /* NSViewExtension.swift */; };
Expand Down Expand Up @@ -217,6 +220,8 @@
64F112A621933ACB00753E83 /* ScrollingTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollingTextView.swift; sourceTree = "<group>"; };
64F29A0F1F2E5FDD00E48BBD /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
6A999C2F782EFDE0675BE9DB /* Pods-SpotMenu.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpotMenu.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SpotMenu/Pods-SpotMenu.debug.xcconfig"; sourceTree = "<group>"; };
A02DF2CE221BB1C700222929 /* PopOverSmall.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PopOverSmall.xib; sourceTree = "<group>"; };
A02DF2D1221BCDB700222929 /* StaticFadeIn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaticFadeIn.swift; sourceTree = "<group>"; };
ADFCF0607F980ADD8D5D03FA /* Pods_SpotMenu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SpotMenu.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DB2C500D2199F94000932042 /* ScrollingStatusItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollingStatusItemView.swift; sourceTree = "<group>"; };
E2D35CCD1F60879700EB5D67 /* NSViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSViewExtension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -323,6 +328,7 @@
648984831E5C21C200EA2234 /* CustomVisualEffect.swift */,
64F112A621933ACB00753E83 /* ScrollingTextView.swift */,
DB2C500D2199F94000932042 /* ScrollingStatusItemView.swift */,
A02DF2D1221BCDB700222929 /* StaticFadeIn.swift */,
);
path = CustomViews;
sourceTree = "<group>";
Expand Down Expand Up @@ -350,6 +356,7 @@
643746621F76AEDD00B16214 /* PopOver.xib */,
213324381D79967B0060D48C /* PopOverVC.swift */,
64A8E1A31F83F45F00FFF6B1 /* Hidden.storyboard */,
A02DF2CE221BB1C700222929 /* PopOverSmall.xib */,
);
path = PopOver;
sourceTree = "<group>";
Expand Down Expand Up @@ -749,6 +756,7 @@
641226E61FD417A400BB119F /* GeneralPreferences.storyboard in Resources */,
64A8E1A41F83F45F00FFF6B1 /* Hidden.storyboard in Resources */,
6437466A1F76B0BB00B16214 /* MainMenu.xib in Resources */,
A02DF2CF221BB1C700222929 /* PopOverSmall.xib in Resources */,
641226E41FD416A200BB119F /* AboutPreferences.storyboard in Resources */,
641226E81FD417D700BB119F /* UpdatePreferences.storyboard in Resources */,
6437466B1F76B0BB00B16214 /* Preferences.storyboard in Resources */,
Expand Down Expand Up @@ -802,7 +810,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-SpotMenu/Pods-SpotMenu-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-SpotMenu/Pods-SpotMenu-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/LoginServiceKit/LoginServiceKit.framework",
"${PODS_ROOT}/Sparkle/Sparkle.framework",
"${PODS_ROOT}/Sparkle/Sparkle.framework.dSYM",
Expand All @@ -815,7 +823,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SpotMenu/Pods-SpotMenu-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SpotMenu/Pods-SpotMenu-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand All @@ -839,6 +847,7 @@
645F8E711F22AEDE007AEEE7 /* Toast.swift in Sources */,
645F8E701F22AEDE007AEEE7 /* SharedFunctionality.swift in Sources */,
6415E1391ED1BF8500051EB5 /* LaunchStarter.swift in Sources */,
A02DF2D2221BCDB700222929 /* StaticFadeIn.swift in Sources */,
64ED8B381F6C351500CAA1AA /* PreferencesWC.swift in Sources */,
647087D61F2299F40054CC48 /* DDHotKeyCenter.m in Sources */,
64A908081EB7754100566ED1 /* UserPreferences.swift in Sources */,
Expand All @@ -858,6 +867,7 @@
buildActionMask = 2147483647;
files = (
64BD97A61FDD713800209B2B /* UserPreferences.swift in Sources */,
A02DF2D3221BCFCD00222929 /* StaticFadeIn.swift in Sources */,
64F112A821933CA400753E83 /* ScrollingTextView.swift in Sources */,
E2D35CD11F60A08800EB5D67 /* PopOverVC.swift in Sources */,
E2D35CCF1F60882600EB5D67 /* NSViewExtension.swift in Sources */,
Expand Down
91 changes: 91 additions & 0 deletions SpotMenu.xcodeproj/xcshareddata/xcschemes/SpotMenu.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
108 changes: 108 additions & 0 deletions SpotMenu.xcodeproj/xcshareddata/xcschemes/SpotMenuToday.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64185C0B1F1B8DC400CA23A0"
BuildableName = "SpotMenuToday.appex"
BlueprintName = "SpotMenuToday"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64185C0B1F1B8DC400CA23A0"
BuildableName = "SpotMenuToday.appex"
BlueprintName = "SpotMenuToday"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "213324271D79801E0060D48C"
BuildableName = "SpotMenu.app"
BlueprintName = "SpotMenu"
ReferencedContainer = "container:SpotMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
28 changes: 24 additions & 4 deletions SpotMenu/AppDelegate/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
private var lastStatusTitle: String = ""
private var removeHudTimer: Timer?
private var musicPlayerManager: MusicPlayerManager!
private var lastPopOverViewName: String = ""
private var popoverVC: PopOverViewController!

private lazy var statusItem: NSStatusItem = {
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
Expand Down Expand Up @@ -64,6 +66,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
self.statusItem.length = Constants.statusItemLength
}
}

private var popOverViewName: String {
get {
return UserPreferences.useSmallPopover ? "PopOverSmall" : "PopOver"
}
}

// MARK: - AppDelegate methods

Expand All @@ -81,11 +89,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let lastMusicPlayer = musicPlayerManager.existMusicPlayer(with: lastMusicPlayerName)
musicPlayerManager.currentPlayer = lastMusicPlayer

let popoverVC = PopOverViewController(nibName: NSNib.Name(rawValue: "PopOver"), bundle: nil)
popoverVC.setUpMusicPlayerManager()

hiddenController = (NSStoryboard(name: NSStoryboard.Name(rawValue: "Hidden"), bundle: nil).instantiateInitialController() as! NSWindowController)
hiddenController?.contentViewController = popoverVC

setupPopOverWithController(viewName: popOverViewName, controller: hiddenController)

hiddenController?.window?.isOpaque = false
hiddenController?.window?.backgroundColor = .clear
hiddenController?.window?.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.floatingWindow)))
Expand Down Expand Up @@ -309,9 +316,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return spotMenuIcon
}
}

private func setupPopOverWithController(viewName: String, controller: NSWindowController?) {
if lastPopOverViewName == viewName { return }
lastPopOverViewName = lastPopOverViewName == "" ? viewName : lastPopOverViewName

popoverVC = PopOverViewController(nibName: NSNib.Name(rawValue: viewName), bundle: nil)
popoverVC.setUpMusicPlayerManager()
controller?.contentViewController = popoverVC

lastPopOverViewName = viewName
}

private func showPopover(_: AnyObject?) {

setupPopOverWithController(viewName: popOverViewName, controller: hiddenController)

let rect = statusItem.button?.window?.convertToScreen((statusItem.button?.frame)!)
let xOffset = UserPreferences.fixPopoverToTheRight ? ((hiddenController?.window?.contentView?.frame.minX)! - (statusItem.button?.frame.minX)!) : ((hiddenController?.window?.contentView?.frame.midX)! - (statusItem.button?.frame.midX)!)
let x = (rect?.origin.x)! - xOffset
Expand Down
30 changes: 30 additions & 0 deletions SpotMenu/CustomViews/StaticFadeIn.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import AppKit
import Foundation

class StaticFadeIn: NSVisualEffectView {

// MARK: - Lifecycle methods

override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
setup()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setup()
}

deinit {
}

private func setup() {
fade()
}

// MARK: - Private helper methods

private func fade() {
alphaValue = CGFloat(1)
}
}
2 changes: 2 additions & 0 deletions SpotMenu/Localizable/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"When checked the playing icon (♫) will be shown in the menu bar if music is played." = "When checked the playing icon (♫) will be shown in the menu bar if music is played.";
"When checked the SpotMenu icon will be shown in the menu bar. Note: If there is no music information to be shown the SpotMenu icon will be visible." = "When checked the SpotMenu icon will be shown in the menu bar.\n\nNote:\nIf there is no music information to be shown the SpotMenu icon will be visible.";
"When checked the popover will be fixed to the right corner." = "When checked the popover will be fixed to the right corner.";
"When checked a small popover will be used instead." = "When checked a small popover will be used instead.";
"When checked SpotMenu will start automatically at login." = "When checked SpotMenu will start automatically at login.";
"Artist" = "Artist";
"Title" = "Title";
Expand All @@ -32,6 +33,7 @@
"Updates" = "Updates";
"Open at login" = "Open at login";
"Fix popover to the right" = "Fix popover to the right";
"Use small popover" = "Use small popover";
"Show SpotMenu icon" = "Show SpotMenu icon";
"Automatically check for updates" = "Automatically check for updates";
"Automatically download updates" = "Automatically download updates";
Expand Down
Loading