parent
1ddce2395b
commit
b08263159e
|
@ -2,8 +2,6 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "NowPlayingBarController.h"
|
||||
|
||||
@class FileTreeViewController;
|
||||
@class PlaybackController;
|
||||
@class PlaylistController;
|
||||
|
@ -47,8 +45,6 @@
|
|||
IBOutlet NSWindowController *spotlightWindowController;
|
||||
|
||||
IBOutlet FileTreeViewController *fileTreeViewController;
|
||||
|
||||
NowPlayingBarController *nowPlaying;
|
||||
|
||||
AppleRemote *remote;
|
||||
BOOL remoteButtonHeld; /* true as long as the user holds the left,right,plus or minus on the remote control */
|
||||
|
@ -60,6 +56,9 @@
|
|||
BOOL miniMode;
|
||||
}
|
||||
|
||||
@property (strong) IBOutlet NSButton *nowPlayingBar;
|
||||
@property (nonatomic) BOOL isNowPlayingHidden;
|
||||
|
||||
- (IBAction)openURL:(id)sender;
|
||||
|
||||
- (IBAction)openFiles:(id)sender;
|
||||
|
@ -98,9 +97,6 @@
|
|||
- (void)nodeExpanded:(NSNotification*)notification;
|
||||
- (void)nodeCollapsed:(NSNotification*)notification;
|
||||
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)notification;
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification;
|
||||
|
||||
- (IBAction)toggleMiniMode:(id)sender;
|
||||
- (IBAction)toggleToolbarStyle:(id)sender;
|
||||
|
||||
|
|
|
@ -22,6 +22,16 @@
|
|||
#import <MASShortcut/Shortcut.h>
|
||||
#import "Shortcuts.h"
|
||||
|
||||
void* kAppControllerContext = &kAppControllerContext;
|
||||
|
||||
|
||||
@interface AppController ()
|
||||
|
||||
@property (nonatomic) BOOL isNowPlayingForceShown;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation AppController {
|
||||
BOOL _isFullToolbarStyle;
|
||||
}
|
||||
|
@ -223,6 +233,23 @@
|
|||
[outlineView expandItem:pn];
|
||||
}
|
||||
}
|
||||
|
||||
[self addObserver:self
|
||||
forKeyPath:@"playbackController.playbackStatus"
|
||||
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
|
||||
context:kAppControllerContext];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary<NSKeyValueChangeKey,id> *)change
|
||||
context:(void *)context {
|
||||
if ([keyPath isEqualToString:@"playbackController.playbackStatus"]) {
|
||||
NSValueTransformer *transformer =
|
||||
[NSValueTransformer valueTransformerForName:@"PlaybackStatusToHiddenTransformer"];
|
||||
NSNumber *value = [transformer transformedValue:@(playbackController.playbackStatus)];
|
||||
self.isNowPlayingHidden = value.boolValue;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)nodeExpanded:(NSNotification*)notification
|
||||
|
@ -437,56 +464,13 @@
|
|||
- (void)windowDidEnterFullScreen:(NSNotification *)notification
|
||||
{
|
||||
DLog(@"Entering fullscreen");
|
||||
if (nil == nowPlaying)
|
||||
{
|
||||
nowPlaying = [[NowPlayingBarController alloc] init];
|
||||
|
||||
NSView *contentView = [mainWindow contentView];
|
||||
NSRect contentRect = [contentView frame];
|
||||
const NSSize windowSize = [contentView convertSize:[mainWindow frame].size fromView: nil];
|
||||
|
||||
[contentView addSubview: [nowPlaying view]];
|
||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
|
||||
[context setDuration:0.25];
|
||||
NSRect nowPlayingFrame = [[self->nowPlaying view] frame];
|
||||
nowPlayingFrame.size.width = windowSize.width;
|
||||
[[self->nowPlaying view] setFrame: nowPlayingFrame];
|
||||
[[self->nowPlaying view] setFrameOrigin: NSMakePoint(0.0, NSMaxY(contentRect) - nowPlayingFrame.size.height)];
|
||||
|
||||
NSRect mainViewFrame = [self->mainView frame];
|
||||
mainViewFrame.size.height -= nowPlayingFrame.size.height;
|
||||
[[self->mainView animator] setFrame:mainViewFrame];
|
||||
|
||||
} completionHandler:^{
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
[[nowPlaying text] bind:@"value" toObject:currentEntryController withKeyPath:@"content.display" options:nil];
|
||||
}
|
||||
self.isNowPlayingForceShown = YES;
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification
|
||||
{
|
||||
DLog(@"Exiting fullscreen");
|
||||
if (nowPlaying)
|
||||
{
|
||||
NSRect nowPlayingFrame = [[nowPlaying view] frame];
|
||||
NSRect mainViewFrame = [mainView frame];
|
||||
mainViewFrame.size.height += nowPlayingFrame.size.height;
|
||||
//[mainView setFrame:mainViewFrame];
|
||||
// [mainView setFrameOrigin:NSMakePoint(0.0, 0.0)];
|
||||
|
||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
|
||||
[context setDuration:0.25];
|
||||
[[self->mainView animator] setFrame:mainViewFrame];
|
||||
|
||||
} completionHandler:^{
|
||||
[[self->nowPlaying view] removeFromSuperview];
|
||||
self->nowPlaying = nil;
|
||||
}];
|
||||
}
|
||||
self.isNowPlayingForceShown = NO;
|
||||
}
|
||||
|
||||
- (void)clickPlay
|
||||
|
@ -580,6 +564,8 @@
|
|||
miniWindow.toolbarStyle = style;
|
||||
}
|
||||
|
||||
[self.nowPlayingBar setHidden:full];
|
||||
|
||||
NSWindowTitleVisibility visibility = full ? NSWindowTitleVisible : NSWindowTitleHidden;
|
||||
mainWindow.titleVisibility = visibility;
|
||||
miniWindow.titleVisibility = visibility;
|
||||
|
@ -588,4 +574,17 @@
|
|||
[miniWindow setContentSize:NSMakeSize(miniWindow.frame.size.width, 0)];
|
||||
}
|
||||
|
||||
- (BOOL)isNowPlayingHidden {
|
||||
if (_isNowPlayingForceShown) {
|
||||
return NO;
|
||||
}
|
||||
return _isNowPlayingHidden;
|
||||
}
|
||||
|
||||
- (void)setIsNowPlayingForceShown:(BOOL)isNowPlayingForceShown {
|
||||
[self willChangeValueForKey:@"isNowPlayingHidden"];
|
||||
_isNowPlayingForceShown = isNowPlayingForceShown;
|
||||
[self didChangeValueForKey:@"isNowPlayingHidden"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18121" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18121"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" topStrut="YES"/>
|
||||
<rect key="contentRect" x="331" y="367" width="847" height="400"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
|
||||
<value key="minSize" type="size" width="400" height="200"/>
|
||||
<stackView key="contentView" orientation="vertical" alignment="centerX" spacing="4" hasEqualSpacing="YES" detachesHiddenViews="YES" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="847" height="400"/>
|
||||
|
@ -35,11 +35,7 @@
|
|||
<connections>
|
||||
<action selector="scrollToCurrentEntry:" target="207" id="e2T-5R-8Eo"/>
|
||||
<binding destination="1897" name="title" keyPath="content.display" id="fno-Aq-DvV"/>
|
||||
<binding destination="705" name="hidden" keyPath="playbackStatus" id="Kl1-lE-Z5C">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">PlaybackStatusToHiddenTransformer</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="226" name="hidden" keyPath="isNowPlayingHidden" id="nmX-cN-bua"/>
|
||||
</connections>
|
||||
</button>
|
||||
<splitView fixedFrame="YES" dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2123">
|
||||
|
@ -585,7 +581,7 @@
|
|||
<window title="Cog" separatorStyle="none" allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="Mini Window" animationBehavior="default" titlebarAppearsTransparent="YES" toolbarStyle="expanded" id="2234" userLabel="Mini Window (Window)" customClass="MiniWindow">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="192" y="547" width="480" height="0.0"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1792" height="1095"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
|
||||
<view key="contentView" hidden="YES" wantsLayer="YES" id="2235">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="0.0"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
@ -1454,6 +1450,7 @@ Gw
|
|||
<string>status</string>
|
||||
<mutableString>queued</mutableString>
|
||||
</declaredKeys>
|
||||
<classReference key="objectClass" className="PlaylistEntry"/>
|
||||
<connections>
|
||||
<outlet property="playbackController" destination="705" id="2121"/>
|
||||
<outlet property="playlistLoader" destination="1319" id="1321"/>
|
||||
|
@ -1482,6 +1479,7 @@ Gw
|
|||
<outlet property="mainView" destination="2123" id="2458"/>
|
||||
<outlet property="mainWindow" destination="21" id="359"/>
|
||||
<outlet property="miniWindow" destination="2234" id="2517"/>
|
||||
<outlet property="nowPlayingBar" destination="gev-jg-41I" id="Fqh-sm-eiO"/>
|
||||
<outlet property="playbackController" destination="705" id="1300"/>
|
||||
<outlet property="playlistController" destination="218" id="236"/>
|
||||
<outlet property="playlistLoader" destination="1319" id="1322"/>
|
||||
|
@ -1772,6 +1770,7 @@ Gw
|
|||
<mutableString>title</mutableString>
|
||||
<mutableString>artist</mutableString>
|
||||
</declaredKeys>
|
||||
<classReference key="objectClass" className="PlaylistEntry"/>
|
||||
<connections>
|
||||
<binding destination="218" name="contentObject" keyPath="currentEntry" id="1902"/>
|
||||
</connections>
|
||||
|
@ -1783,6 +1782,7 @@ Gw
|
|||
<string>artist</string>
|
||||
<string>album</string>
|
||||
</declaredKeys>
|
||||
<classReference key="objectClass" className="PlaylistEntry"/>
|
||||
<connections>
|
||||
<binding destination="218" name="contentArray" keyPath="arrangedObjects" id="2039"/>
|
||||
<binding destination="218" name="selectionIndexes" keyPath="selectionIndexes" id="2041"/>
|
||||
|
@ -1963,7 +1963,7 @@ oCGoIashsCG4AAAAAAAAAgEAAAAAAAAAQwAAAAAAAAAAAAAAAAAAIbs
|
|||
<image name="nextTemplate" width="20" height="19"/>
|
||||
<image name="playTemplate" width="16" height="16"/>
|
||||
<image name="previousTemplate" width="20" height="19"/>
|
||||
<image name="randomizeTemplate" width="17" height="16"/>
|
||||
<image name="randomizeTemplate" width="16" height="17"/>
|
||||
<image name="repeatModeOffTemplate" width="20" height="19"/>
|
||||
<image name="shuffleOffTemplate" width="20" height="19"/>
|
||||
<image name="stopTemplate" width="16" height="16"/>
|
||||
|
|
|
@ -131,9 +131,6 @@
|
|||
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */; };
|
||||
836F5BF91A357A01002730CC /* sidplay.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8314D6411A354DFF00EEE8E6 /* sidplay.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
836FB5A718206F2500B3AD2D /* Hively.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 836FB5471820538800B3AD2D /* Hively.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8384911D1807F38A00E7332D /* NowPlayingBarView.m */; };
|
||||
838491221807F38A00E7332D /* NowPlayingBarController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8384911E1807F38A00E7332D /* NowPlayingBarController.xib */; };
|
||||
838491231807F38A00E7332D /* NowPlayingBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8384911F1807F38A00E7332D /* NowPlayingBarController.m */; };
|
||||
8384913C1808217300E7332D /* randomize.png in Resources */ = {isa = PBXBuildFile; fileRef = 8384913B1808217300E7332D /* randomize.png */; };
|
||||
8384914018083E4E00E7332D /* filetype.icns in Resources */ = {isa = PBXBuildFile; fileRef = 8384913D18083E4E00E7332D /* filetype.icns */; };
|
||||
8384915918083EAB00E7332D /* infoTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 8384914318083EAB00E7332D /* infoTemplate.pdf */; };
|
||||
|
@ -886,11 +883,6 @@
|
|||
836F6B2518BDB80D0095E648 /* vgmstream.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = vgmstream.xcodeproj; path = Plugins/vgmstream/vgmstream.xcodeproj; sourceTree = "<group>"; };
|
||||
836FB5421820538700B3AD2D /* Hively.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Hively.xcodeproj; path = Plugins/Hively/Hively.xcodeproj; sourceTree = "<group>"; };
|
||||
8375B05117FFEA400092A79F /* OpusPlugin.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OpusPlugin.xcodeproj; path = Plugins/Opus/OpusPlugin.xcodeproj; sourceTree = "<group>"; };
|
||||
8384911D1807F38A00E7332D /* NowPlayingBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarView.m; path = Window/NowPlayingBarView.m; sourceTree = "<group>"; };
|
||||
8384911E1807F38A00E7332D /* NowPlayingBarController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NowPlayingBarController.xib; path = Window/NowPlayingBarController.xib; sourceTree = "<group>"; };
|
||||
8384911F1807F38A00E7332D /* NowPlayingBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarController.m; path = Window/NowPlayingBarController.m; sourceTree = "<group>"; };
|
||||
838491201807F38A00E7332D /* NowPlayingBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarController.h; path = Window/NowPlayingBarController.h; sourceTree = "<group>"; };
|
||||
838491241807F75D00E7332D /* NowPlayingBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarView.h; path = Window/NowPlayingBarView.h; sourceTree = "<group>"; };
|
||||
8384912518080F2D00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = "<group>"; };
|
||||
8384913B1808217300E7332D /* randomize.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = randomize.png; path = Images/randomize.png; sourceTree = "<group>"; };
|
||||
8384913D18083E4E00E7332D /* filetype.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = filetype.icns; sourceTree = "<group>"; };
|
||||
|
@ -1334,10 +1326,6 @@
|
|||
836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */,
|
||||
17E0D5E30F520F02005B6FED /* MiniWindow.h */,
|
||||
17E0D5E40F520F02005B6FED /* MiniWindow.m */,
|
||||
838491201807F38A00E7332D /* NowPlayingBarController.h */,
|
||||
8384911F1807F38A00E7332D /* NowPlayingBarController.m */,
|
||||
838491241807F75D00E7332D /* NowPlayingBarView.h */,
|
||||
8384911D1807F38A00E7332D /* NowPlayingBarView.m */,
|
||||
1752C36A0F59E00100F85F28 /* PlaybackButtons.h */,
|
||||
1752C36B0F59E00100F85F28 /* PlaybackButtons.m */,
|
||||
17E0D5E50F520F02005B6FED /* PositionSlider.h */,
|
||||
|
@ -1447,7 +1435,6 @@
|
|||
178456C00F6320B5007E8021 /* SpotlightPanel.xib */,
|
||||
17E41E060C130DFF00AC744D /* Credits.html */,
|
||||
17D1B1DA0F6330D400694C57 /* Feedback.xib */,
|
||||
8384911E1807F38A00E7332D /* NowPlayingBarController.xib */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2185,7 +2172,6 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
838491221807F38A00E7332D /* NowPlayingBarController.xib in Resources */,
|
||||
83BC5AC420E4CE9000631CD4 /* Feedback.xib in Resources */,
|
||||
83BC5AC320E4CE8D00631CD4 /* SpotlightPanel.xib in Resources */,
|
||||
83BC5AC220E4CE8A00631CD4 /* FileTree.xib in Resources */,
|
||||
|
@ -2314,7 +2300,6 @@
|
|||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */,
|
||||
EDAAA41F25A665C000731773 /* PositionSliderToolbarItem.swift in Sources */,
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
|
||||
838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */,
|
||||
5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */,
|
||||
5604D4F60D60726E004F5C5D /* SpotlightPlaylistEntry.m in Sources */,
|
||||
56462EAF0D6341F6000AB68C /* SpotlightTransformers.m in Sources */,
|
||||
|
@ -2338,7 +2323,6 @@
|
|||
179D03280E0CB2500064A77A /* SmartFolderNode.m in Sources */,
|
||||
173855FF0E0CC81F00488CD4 /* FileTreeOutlineView.m in Sources */,
|
||||
07D971E60ED1DAA800E7602E /* TagEditorController.m in Sources */,
|
||||
838491231807F38A00E7332D /* NowPlayingBarController.m in Sources */,
|
||||
17E0D5EA0F520F02005B6FED /* MainWindow.m in Sources */,
|
||||
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */,
|
||||
17E0D5EB0F520F02005B6FED /* MiniWindow.m in Sources */,
|
||||
|
|
|
@ -9,27 +9,32 @@ import Foundation
|
|||
|
||||
class PlaybackStatusToHiddenTransformer : ValueTransformer {
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSObject.self
|
||||
return NSNumber.self
|
||||
}
|
||||
|
||||
|
||||
override class func allowsReverseTransformation() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
let titleShown = UserDefaults.standard.bool(forKey: "toolbarStyleFull");
|
||||
if titleShown {
|
||||
return NSNumber(booleanLiteral: true)
|
||||
}
|
||||
|
||||
guard let intValue = value as? Int,
|
||||
let status = CogStatus(rawValue: intValue) else {
|
||||
return true;
|
||||
return NSNumber(booleanLiteral: true)
|
||||
}
|
||||
switch status {
|
||||
case .stopped:
|
||||
return true
|
||||
return NSNumber(booleanLiteral: true)
|
||||
case .paused,
|
||||
.playing,
|
||||
.stopping:
|
||||
return false
|
||||
return NSNumber(booleanLiteral: false)
|
||||
@unknown default:
|
||||
return false;
|
||||
return NSNumber(booleanLiteral: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// NowPlayingBarController.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Dmitry Promsky on 2/25/12.
|
||||
// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NowPlayingBarController : NSViewController
|
||||
{
|
||||
IBOutlet NSTextField *text;
|
||||
}
|
||||
|
||||
- (NSTextField*)text;
|
||||
|
||||
@end
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
//
|
||||
// NowPlayingBarController.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Dmitry Promsky on 2/25/12.
|
||||
// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NowPlayingBarController.h"
|
||||
|
||||
@implementation NowPlayingBarController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super initWithNibName:@"NowPlayingBarController" bundle:nil];
|
||||
if (self)
|
||||
{
|
||||
// Initialization code here.
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSTextField*)text
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NowPlayingBarController">
|
||||
<connections>
|
||||
<outlet property="text" destination="3" id="6"/>
|
||||
<outlet property="view" destination="1" id="2"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="1" customClass="NowPlayingBarView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3">
|
||||
<rect key="frame" x="0.0" y="4" width="480" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" alignment="center" id="4">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="139" y="154"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// NowPlayingBarView.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Dmitry Promsky on 2/24/12.
|
||||
// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NowPlayingBarView : NSView
|
||||
{
|
||||
NSGradient *gradient_light, *gradient_dark;
|
||||
}
|
||||
@end
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
//
|
||||
// NowPlayingBarView.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Dmitry Promsky on 2/24/12.
|
||||
// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NowPlayingBarView.h"
|
||||
|
||||
@implementation NowPlayingBarView
|
||||
|
||||
- (id)initWithFrame:(NSRect)rect
|
||||
{
|
||||
if ((self = [super initWithFrame: rect]))
|
||||
{
|
||||
NSColor *lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0];
|
||||
NSColor *darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0];
|
||||
gradient_light = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
|
||||
|
||||
lightColor = [NSColor colorWithCalibratedRed: 56.0/255.0 green: 56.0/255.0 blue: 56.0/255.0 alpha: 1.0];
|
||||
darkColor = [NSColor colorWithCalibratedRed: 64.0/255.0 green: 64.0/255.0 blue: 64.0/255.0 alpha: 1.0];
|
||||
gradient_dark = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
{
|
||||
const BOOL active = [[self window] isMainWindow];
|
||||
|
||||
NSInteger count = 0;
|
||||
NSRect gridRects[2];
|
||||
NSColor * colorRects[2];
|
||||
|
||||
NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
|
||||
|
||||
Boolean isDarkMode = NO;
|
||||
if (@available(macOS 10.14, *)) {
|
||||
NSAppearance * appearance = [[NSApplication sharedApplication] effectiveAppearance];
|
||||
NSAppearanceName basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
||||
if ([basicAppearance isEqualToString:NSAppearanceNameDarkAqua]) {
|
||||
isDarkMode = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
if (isDarkMode)
|
||||
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.40 alpha: 1.0];
|
||||
else
|
||||
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0];
|
||||
++count;
|
||||
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
|
||||
lineBorderRect.origin.y = 0.0;
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
if (isDarkMode)
|
||||
colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.60 alpha: 1.0] : [NSColor colorWithCalibratedWhite: 0.4 alpha: 1.0];
|
||||
else
|
||||
colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
|
||||
: [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
|
||||
++count;
|
||||
|
||||
rect.origin.y += 1.0;
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
|
||||
if (!NSIsEmptyRect(rect))
|
||||
{
|
||||
const NSRect gradientRect = NSMakeRect(NSMinX(rect), 1.0, NSWidth(rect), NSHeight([self bounds]) - 1.0 - 1.0); //proper gradient requires the full height of the bar
|
||||
if (isDarkMode)
|
||||
[gradient_dark drawInRect: gradientRect angle: 270.0];
|
||||
else
|
||||
[gradient_light drawInRect: gradientRect angle: 270.0];
|
||||
}
|
||||
|
||||
NSRectFillListWithColors(gridRects, colorRects, count);
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue