diff --git a/Application/AppController.h b/Application/AppController.h index cdf0be4c1..76ef7f598 100644 --- a/Application/AppController.h +++ b/Application/AppController.h @@ -3,6 +3,7 @@ #import #import "NDHotKeyEvent.h" +#import "NowPlayingBarController.h" @class PlaybackController; @class PlaylistController; @@ -12,12 +13,15 @@ @interface AppController : NSObject { + IBOutlet NSObjectController *currentEntryController; + IBOutlet PlaybackController *playbackController; IBOutlet PlaylistController *playlistController; IBOutlet PlaylistLoader *playlistLoader; IBOutlet NSWindow *mainWindow; + IBOutlet NSSplitView *mainView; IBOutlet NSSegmentedControl *playbackButtons; IBOutlet NSButton *infoButton; @@ -46,6 +50,8 @@ NDHotKeyEvent *prevHotKey; NDHotKeyEvent *nextHotKey; NDHotKeyEvent *spamHotKey; + + NowPlayingBarController *nowPlaying; AppleRemote *remote; BOOL remoteButtonHeld; /* true as long as the user holds the left,right,plus or minus on the remote control */ diff --git a/Application/AppController.m b/Application/AppController.m index d7d5d9c55..ffdd7a010 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -271,6 +271,9 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ [playbackController playEntryAtIndex:lastIndex]; [playbackController seek:[NSNumber numberWithDouble:[[NSUserDefaults standardUserDefaults] floatForKey:@"lastTrackPosition"]]]; } + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterFullscreen) name:NSWindowDidEnterFullScreenNotification object:mainWindow]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitFullscreen) name:NSWindowDidExitFullScreenNotification object:mainWindow]; } - (void)applicationWillTerminate:(NSNotification *)aNotification @@ -513,6 +516,50 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ } } +- (void)enterFullscreen +{ + NSLog(@"Entering fullscreen"); + if (nil == nowPlaying) + { + nowPlaying = [[NowPlayingBarController alloc] init]; + [nowPlaying retain]; + + NSView *contentView = [mainWindow contentView]; + NSRect contentRect = [contentView frame]; + const NSSize windowSize = [contentView convertSize:[mainWindow frame].size fromView: nil]; + + NSRect nowPlayingFrame = [[nowPlaying view] frame]; + nowPlayingFrame.size.width = windowSize.width; + [[nowPlaying view] setFrame: nowPlayingFrame]; + + [contentView addSubview: [nowPlaying view]]; + [[nowPlaying view] setFrameOrigin: NSMakePoint(0.0, NSMaxY(contentRect) - nowPlayingFrame.size.height)]; + + NSRect mainViewFrame = [mainView frame]; + mainViewFrame.size.height -= nowPlayingFrame.size.height; + [mainView setFrame:mainViewFrame]; + + [[nowPlaying text] bind:@"value" toObject:currentEntryController withKeyPath:@"content.display" options:nil]; + } +} + +- (void)exitFullscreen +{ + NSLog(@"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)]; + + [[nowPlaying view] removeFromSuperview]; + [nowPlaying release]; + nowPlaying = nil; + } +} + - (void)clickPlay { [playbackController playPauseResume:self]; diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 52739dcad..bcc9ae7a4 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -148,6 +148,9 @@ 8359009D17FF06570060F3ED /* ArchiveSource.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8359FF3117FEF35D0060F3ED /* ArchiveSource.bundle */; }; 8360EF6D17F92E56005208A4 /* HighlyComplete.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8360EF0517F92B24005208A4 /* HighlyComplete.bundle */; }; 8375B36517FFEF130092A79F /* Opus.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8375B05717FFEA410092A79F /* Opus.bundle */; }; + 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 */; }; 8399D4E21805A55000B503B1 /* XmlContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8399D4E01805A55000B503B1 /* XmlContainer.m */; }; 83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94350D747F7B0064F138 /* FFMPEG.bundle */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; @@ -737,6 +740,11 @@ 8359FF2C17FEF35C0060F3ED /* ArchiveSource.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ArchiveSource.xcodeproj; path = Plugins/ArchiveSource/ArchiveSource.xcodeproj; sourceTree = ""; }; 8360EF0017F92B23005208A4 /* HighlyComplete.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HighlyComplete.xcodeproj; path = Plugins/HighlyComplete/HighlyComplete.xcodeproj; sourceTree = ""; }; 8375B05117FFEA400092A79F /* Opus.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Opus.xcodeproj; path = Plugins/Opus/Opus.xcodeproj; sourceTree = ""; }; + 8384911D1807F38A00E7332D /* NowPlayingBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarView.m; path = Window/NowPlayingBarView.m; sourceTree = ""; }; + 8384911E1807F38A00E7332D /* NowPlayingBarController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NowPlayingBarController.xib; path = Window/NowPlayingBarController.xib; sourceTree = ""; }; + 8384911F1807F38A00E7332D /* NowPlayingBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarController.m; path = Window/NowPlayingBarController.m; sourceTree = ""; }; + 838491201807F38A00E7332D /* NowPlayingBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarController.h; path = Window/NowPlayingBarController.h; sourceTree = ""; }; + 838491241807F75D00E7332D /* NowPlayingBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarView.h; path = Window/NowPlayingBarView.h; sourceTree = ""; }; 8399D4E01805A55000B503B1 /* XmlContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XmlContainer.m; sourceTree = ""; }; 8399D4E11805A55000B503B1 /* XmlContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlContainer.h; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; @@ -1174,6 +1182,10 @@ 17E0D5D20F520E75005B6FED /* Window */ = { isa = PBXGroup; children = ( + 8384911D1807F38A00E7332D /* NowPlayingBarView.m */, + 838491241807F75D00E7332D /* NowPlayingBarView.h */, + 8384911F1807F38A00E7332D /* NowPlayingBarController.m */, + 838491201807F38A00E7332D /* NowPlayingBarController.h */, 1752C36A0F59E00100F85F28 /* PlaybackButtons.h */, 1752C36B0F59E00100F85F28 /* PlaybackButtons.m */, 172A123A0F5912AE0078EF0C /* ShuffleTransformers.h */, @@ -1282,6 +1294,7 @@ 178456C00F6320B5007E8021 /* SpotlightPanel.xib */, 17E41E060C130DFF00AC744D /* Credits.html */, 17D1B1DA0F6330D400694C57 /* Feedback.xib */, + 8384911E1807F38A00E7332D /* NowPlayingBarController.xib */, ); name = Resources; sourceTree = ""; @@ -1821,6 +1834,7 @@ 1791005E0CB44D6D0070BC5C /* Cog.scriptSuite in Resources */, 1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */, 17D1B27D0CF8B2830028F5B5 /* cue.icns in Resources */, + 838491221807F38A00E7332D /* NowPlayingBarController.xib in Resources */, 17D1B27E0CF8B2830028F5B5 /* it.icns in Resources */, 17D1B27F0CF8B2830028F5B5 /* pls.icns in Resources */, 17D1B2800CF8B2830028F5B5 /* s3m.icns in Resources */, @@ -1894,6 +1908,7 @@ 8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */, 179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */, 1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */, + 838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */, 178BAB990CD4E1B700B33D47 /* GCOneShotEffectTimer.m in Sources */, 178BAB9A0CD4E1B700B33D47 /* GCWindowMenu.m in Sources */, 178BAB9B0CD4E1B700B33D47 /* PopupButton.m in Sources */, @@ -1923,6 +1938,7 @@ 07D971E60ED1DAA800E7602E /* TagEditorController.m in Sources */, 173A43A10F3FD26500676A7B /* ToolTipWindow.m in Sources */, 17E0D5E90F520F02005B6FED /* DualWindow.m in Sources */, + 838491231807F38A00E7332D /* NowPlayingBarController.m in Sources */, 17E0D5EA0F520F02005B6FED /* MainWindow.m in Sources */, 17E0D5EB0F520F02005B6FED /* MiniWindow.m in Sources */, 17E0D5EC0F520F02005B6FED /* PositionSlider.m in Sources */, diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index e2cb109ad..62fa75f36 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -82,7 +82,7 @@ - + @@ -1363,8 +1363,10 @@ Gw + + @@ -1648,7 +1650,7 @@ Gw - + YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T diff --git a/Window/NowPlayingBarController.h b/Window/NowPlayingBarController.h new file mode 100644 index 000000000..e2f7f7ca2 --- /dev/null +++ b/Window/NowPlayingBarController.h @@ -0,0 +1,19 @@ +// +// NowPlayingBarController.h +// Cog +// +// Created by Dmitry Promsky on 2/25/12. +// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved. +// + +#import + +@interface NowPlayingBarController : NSViewController +{ + IBOutlet NSTextField *text; +} + +- (NSTextField*)text; + +@end + diff --git a/Window/NowPlayingBarController.m b/Window/NowPlayingBarController.m new file mode 100644 index 000000000..e25ee1080 --- /dev/null +++ b/Window/NowPlayingBarController.m @@ -0,0 +1,30 @@ +// +// 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 + diff --git a/Window/NowPlayingBarController.xib b/Window/NowPlayingBarController.xib new file mode 100644 index 000000000..1aed41947 --- /dev/null +++ b/Window/NowPlayingBarController.xib @@ -0,0 +1,204 @@ + + + + 1070 + 11D50b + 1617 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1617 + + + NSCustomView + NSTextField + NSTextFieldCell + NSCustomObject + + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + NowPlayingBarController + + + FirstResponder + + + NSApplication + + + + 266 + + + + 266 + {{0, 4}, {480, 17}} + + + + _NS:3936 + YES + + 70385217 + 138413056 + + + LucidaGrande + 13 + 1044 + + _NS:3936 + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + {480, 24} + + + + NowPlayingBarView + + + + + + + view + + + + 2 + + + + text + + + + 6 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + + + + + + 3 + + + + + + + + 4 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 6 + + + + + NowPlayingBarController + NSViewController + + text + NSTextField + + + text + + text + NSTextField + + + + IBProjectSource + ./Classes/NowPlayingBarController.h + + + + NowPlayingBarView + NSView + + IBProjectSource + ./Classes/NowPlayingBarView.h + + + + + 0 + IBCocoaFramework + YES + 3 + + + diff --git a/Window/NowPlayingBarView.h b/Window/NowPlayingBarView.h new file mode 100644 index 000000000..5d9f92821 --- /dev/null +++ b/Window/NowPlayingBarView.h @@ -0,0 +1,16 @@ +// +// NowPlayingBarView.h +// Cog +// +// Created by Dmitry Promsky on 2/24/12. +// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved. +// + +#import + +@interface NowPlayingBarView : NSView +{ + NSGradient *gradient; +} +@end + diff --git a/Window/NowPlayingBarView.m b/Window/NowPlayingBarView.m new file mode 100644 index 000000000..aaab33989 --- /dev/null +++ b/Window/NowPlayingBarView.m @@ -0,0 +1,71 @@ +// +// 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 = [[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); + + if (NSIntersectsRect(lineBorderRect, rect)) + { + gridRects[count] = lineBorderRect; + 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; + 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 + [gradient drawInRect: gradientRect angle: 270.0]; + } + + NSRectFillListWithColors(gridRects, colorRects, count); +} + +- (void)dealloc +{ + [gradient release]; + [super dealloc]; +} + +@end +