diff --git a/Resources/Keyboard.png b/Resources/Keyboard.png new file mode 100644 index 0000000..7b677ed Binary files /dev/null and b/Resources/Keyboard.png differ diff --git a/Resources/btstack.png b/Resources/btstack.png new file mode 100644 index 0000000..b7b8f0d Binary files /dev/null and b/Resources/btstack.png differ diff --git a/Resources/colorAppleTVNameImage.png b/Resources/colorAppleTVNameImage.png new file mode 100644 index 0000000..2f376f7 Binary files /dev/null and b/Resources/colorAppleTVNameImage.png differ diff --git a/SMFColorSelectionMenu.h b/SMFColorSelectionMenu.h new file mode 100644 index 0000000..2a36b71 --- /dev/null +++ b/SMFColorSelectionMenu.h @@ -0,0 +1,24 @@ +// +// SMFColorSelectionMenu.h +// SMFramework +// +// Created by Thomas Cool on 11/22/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFMediaMenuController.h" +#import + +@protocol SMFColorSelectionDelegate +-(void)colorSelected:(NSArray *)rgba forKey:(NSString *)key; +@end + +@interface SMFColorSelectionMenu : SMFMediaMenuController { + iddelegate; + NSString *key; + NSArray *colors; +} ++(SMFColorSelectionMenu *)colorMenuForKey:(NSString *)k andDelegate:(id)del; +@property (assign) id delegate; +@property (retain) NSString * key; +@end diff --git a/SMFColorSelectionMenu.m b/SMFColorSelectionMenu.m new file mode 100644 index 0000000..0f5fe5c --- /dev/null +++ b/SMFColorSelectionMenu.m @@ -0,0 +1,98 @@ +// +// SMFColorSelectionMenu.m +// SMFramework +// +// Created by Thomas Cool on 11/22/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFColorSelectionMenu.h" +#import "SMFMenuItem.h" +#import "SMFBaseAsset.h" +#import "SMFMediaPreview.h" +#import "SMFThemeInfo.h" +#import +#define SMFFloat(val) [NSNumber numberWithFloat:(val)] +#define SMFFloatString(val) [NSString stringWithFormat:@"%.1f",(val)] +@implementation SMFColorSelectionMenu +@synthesize delegate; +@synthesize key; ++(SMFColorSelectionMenu *)colorMenuForKey:(NSString *)k andDelegate:(id)del +{ + SMFColorSelectionMenu *col = [[SMFColorSelectionMenu alloc] init]; + [col setDelegate:del]; + [col setKey:k]; + return [col autorelease]; +} +static float red[]= {0.0,0.0,0.6,0.0,0.33,0.0,0.66,1.0,1.0,0.5,1.0,1.0,1.0}; +static float green[]={0.0,0.0,0.4,1.0,0.33,1.0,0.66,0.0,0.5,0.0,0.0,1.0,1.0}; +static float blue[] ={0.0,1.0,0.2,1.0,0.33,0.0,0.66,1.0,0.0,0.5,0.0,1.0,0.0}; +-(id)previewControlForItem:(long)row +{ + if (row>=[_items count]) + return nil; + SMFMediaPreview *p = [[SMFMediaPreview alloc] init]; + SMFBaseAsset *a = [[SMFBaseAsset alloc] init]; + [a setCoverArt:[[SMFThemeInfo sharedTheme] colorAppleTVNameImage]]; + [a setTitle:[self titleForRow:row]]; + [a setCustomKeys:[NSArray arrayWithObjects:@"Red",@"Green",@"Blue",@"Alpha",nil] + forObjects:[NSArray arrayWithObjects:SMFFloatString(red[row]),SMFFloatString(green[row]), + SMFFloatString(blue[row]),SMFFloatString(1.0),nil]]; + [p setAsset:a]; + [a release]; + return [p autorelease]; +} + +-(id)init +{ + self=[super init]; + if (self) { + [self setListTitle:@"Select A Color"]; + NSArray *strings = [NSArray arrayWithObjects:@"Black",@"Blue",@"Brown",@"Cyan",@"Dark Gray",@"Green", + @"Light Gray",@"Magenta",@"Orange",@"Purple",@"Red",@"White",@"Yellow",nil]; + CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); + for(int i=0;i<[strings count];i++) + { + //UIColor*c = [[[UIColor alloc] initWithRed:red[i] green:green[i] blue:blue[i] alpha:1.0] autorelease]; + //NSLog(@"%@:%@",[strings objectAtIndex:i],c); + SMFMenuItem *it = [[SMFMenuItem alloc] init]; + NSMutableDictionary *d = [[[BRThemeInfo sharedTheme]menuItemTextAttributes] mutableCopy]; + + const CGFloat myColor[] = {red[i], green[i], blue[i], 1.0}; + CGColorRef color = CGColorCreate(rgb, myColor); + + [d setObject:color forKey:@"CTForegroundColor"]; + CGColorRelease(color); + [it setText:[strings objectAtIndex:i] withAttributes:d]; + [d release]; + [_items addObject:it]; + [it release]; + } + CGColorSpaceRelease(rgb); + + } + return self; +} +-(void)itemSelected:(long)selected +{ + if ([self.delegate conformsToProtocol:@protocol(SMFColorSelectionDelegate)]) + { + + NSArray *colorArray = [NSArray arrayWithObjects: + SMFFloat(red[selected]), + SMFFloat(green[selected]), + SMFFloat(blue[selected]), + SMFFloat(1.0), + nil]; + [[self delegate] colorSelected:colorArray forKey:[self key]]; + } +} +-(void)dealloc +{ + [colors release]; + colors=nil; + delegate=nil; + self.key=nil; + [super dealloc]; +} +@end diff --git a/SMFCommonTools.h b/SMFCommonTools.h index 9b77fde..4454b01 100644 --- a/SMFCommonTools.h +++ b/SMFCommonTools.h @@ -11,6 +11,16 @@ @interface SMFCommonTools : NSObject { } +/* + * Returns a SMFPopupInfo to show using showPopup + * @arg1: an NSArray with 1-3 NSStrings inside (can be nil) + * @arg2: a BRImage (cannot be nil) + */ +(id)popupControlWithLines:(NSArray *)array andImage:(BRImage *)image; + +/* + * Displays a popup using the BRPopupManager + * @arg1: a popup created using popupControlwithLines:andImage: + */ +(void)showPopup:(id)popup; @end diff --git a/SMFCommonTools.m b/SMFCommonTools.m index 4a9482b..25feca9 100644 --- a/SMFCommonTools.m +++ b/SMFCommonTools.m @@ -19,12 +19,12 @@ +(id)popupControlWithLines:(NSArray *)array andImage:(BRImage *)image NSDictionary *dict; if (array==nil) { dict = [NSDictionary dictionaryWithObjectsAndKeys: - [[BRThemeInfo sharedTheme]geniusIcon],@"Image", + image,@"Image", nil]; } else { dict = [NSDictionary dictionaryWithObjectsAndKeys: - [[BRThemeInfo sharedTheme]geniusIcon],@"Image", + image,@"Image", array,@"Lines",nil]; } diff --git a/SMFDebAsset.h b/SMFDebAsset.h new file mode 100644 index 0000000..fddf7a1 --- /dev/null +++ b/SMFDebAsset.h @@ -0,0 +1,16 @@ +// +// SMFDebAsset.h +// SMFramework +// +// Created by Thomas Cool on 12/12/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFBaseAsset.h" + + +@interface SMFDebAsset : SMFBaseAsset { + NSString *_path; +} + +@end diff --git a/SMFDebAsset.m b/SMFDebAsset.m new file mode 100644 index 0000000..8045f11 --- /dev/null +++ b/SMFDebAsset.m @@ -0,0 +1,37 @@ +// +// SMFDebAsset.m +// SMFramework +// +// Created by Thomas Cool on 12/12/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFDebAsset.h" + + +@implementation SMFDebAsset +-(id)initWithPath:(NSString *)path +{ + if ([[path pathExtension] localizedCaseInsensitiveCompare:@"deb" ]!=NSOrderedSame) + return nil; + self=[super init]; + if (self!=nil) { + char line[200]; + + NSString *commandString = [NSString stringWithFormat:@"dpkg-deb -I %@",path,nil]; + FILE* fp = popen([commandString UTF8String], "r"); + NSMutableArray *lines = [[NSMutableArray alloc]init]; + if (fp) + { + while (fgets(line, sizeof line, fp)) + { + NSString *s = [NSString stringWithCString:line]; + [lines addObject:s]; + NSLog(@"%@",s); + } + } + pclose(fp); + } + return self; +} +@end diff --git a/SMFEventManager.m b/SMFEventManager.m index 7675a45..54799f8 100644 --- a/SMFEventManager.m +++ b/SMFEventManager.m @@ -10,7 +10,8 @@ #import "SMFScreenCapture.h" #import "SMFEventConfiguration.h" #import "SMFPhotoMethods.h" -#define eventsPlist (CFStringRef)@"org.tomcool.eventManager" +#define eventsPlist (CFStringRef)@"org.tomcool.SMFramework.eventManager" +#define eventString @"org.tomcool.SMFramework.eventManager" #define remoteActionDict (CFStringRef)@"remoteActions" #define keyDict (CFStringRef)@"keyboardKeys" @@ -159,7 +160,7 @@ -(BOOL)actionDefinedForBREvent:(BREvent *)event } else if([event value]==0x01) { - return [self actionDefinedForKey:[event remoteAction]]; + return [self actionDefinedForAction:[event remoteAction]]; } return NO; } @@ -211,8 +212,8 @@ -(void)restartLowtide } -(void)actionForEvent:(SMFEvent *)event { - NSLog(@"%@ %@ %@ %@",kSMFEventDefaultScreenshot,kSMFEventDefaultRestartLowtide,kSMFEventDefaultSetup,kSMFEventDefaultSlideshow); - NSLog(@"event: %@ %@",event,[event name]); +// NSLog(@"%@ %@ %@ %@",kSMFEventDefaultScreenshot,kSMFEventDefaultRestartLowtide,kSMFEventDefaultSetup,kSMFEventDefaultSlideshow); +// NSLog(@"event: %@ %@",event,[event name]); if ([[event name] isEqualToString:kSMFEventDefaultScreenshot]) [self takeScreenshot]; diff --git a/SMFFolderBrowser.h b/SMFFolderBrowser.h index 618f7ba..25a1f95 100644 --- a/SMFFolderBrowser.h +++ b/SMFFolderBrowser.h @@ -7,22 +7,28 @@ // #import "SMFMediaMenuController.h" +#import "SMFPreferences.h" +#import "SMFPhotoMethods.h" +@protocol SMFFolderBrowserDelegate +-(BOOL)hasActionForFile:(NSString *)path; +-(void)executeActionForFile:(NSString *)path; +@end @interface SMFFolderBrowser : SMFMediaMenuController { - NSString * path; - NSMutableArray * _paths; - NSFileManager * _man; - NSMutableArray * _files; - NSMutableArray * _folders; - BOOL separate; - BOOL showHidden; - BOOL showOnlyFolders; - NSString *plistPath; - NSString *plistKey; - id delegate; - NSString *fpath; + NSString * path; + NSMutableArray * _paths; + NSFileManager * _man; + NSMutableArray * _files; + NSMutableArray * _folders; + BOOL separate; + BOOL showHidden; + BOOL showOnlyFolders; + + NSObject* delegate; + NSString * fpath; + } @@ -34,8 +40,9 @@ @property (assign) BOOL separate; @property (assign) BOOL showHidden; @property (assign) BOOL showOnlyFolders; -@property (retain) NSString *plistKey; -@property (retain) NSString *plistPath; -@property (retain) id delegate; + + +@property (retain) NSObject* delegate; @property (retain) NSString *fpath; + @end diff --git a/SMFFolderBrowser.m b/SMFFolderBrowser.m index 1eb5118..2b594cf 100644 --- a/SMFFolderBrowser.m +++ b/SMFFolderBrowser.m @@ -13,16 +13,53 @@ #import "SMFMediaPreview.h" #import "SMFMenuItem.h" #import "SMFThemeInfo.h" - +#import "SMFImageAsset.h" +#import "SMFDebAsset.h" @implementation SMFFolderBrowser @synthesize separate; @synthesize showHidden; @synthesize showOnlyFolders; @synthesize delegate; -@synthesize plistKey; -@synthesize plistPath; + @synthesize fpath; +-(id)previewControlForItem:(long)row +{ + if (separate && row <[_folders count]) { + int count = [SMFPhotoMethods imagesCountForPath:[_folders objectAtIndex:row]]; + if (count>1) { + NSArray *proxies = [SMFPhotoMethods imageProxiesForPath:[_folders objectAtIndex:row]]; + BRMediaParadeControl *ctrl = [[BRMediaParadeControl alloc] init]; + [ctrl setImageProxies:proxies]; + return [ctrl autorelease]; + } + BRImage *img = [SMFPhotoMethods firstPhotoForPath:[_folders objectAtIndex:row]]; + BRImageAndSyncingPreviewController *p = [[BRImageAndSyncingPreviewController alloc] init]; + [p setImage:img]; + return [p autorelease]; + + } + if (separate && (row-[_folders count])<([_files count])) { + NSString *f = [_files objectAtIndex:(row-[_folders count])]; + if ([SMFPhotoMethods isImageAtPath:f]) { + SMFImageAsset *a = [[SMFImageAsset alloc] initWithPath:f]; + SMFMediaPreview *p = [[SMFMediaPreview alloc]init]; + [p setAsset:a]; + [a release]; + return [p autorelease]; +// BRImage *img = [BRImage imageWithPath:[_files objectAtIndex:(row-[_folders count])]]; +// BRImageAndSyncingPreviewController *p = [[BRImageAndSyncingPreviewController alloc] init]; +// [p setImage:img]; +// return [p autorelease]; + } + if ([[f pathExtension] localizedCaseInsensitiveCompare:@"deb"]==NSOrderedSame) { + NSLog(@"***###***"); + SMFDebAsset *asset = [[SMFDebAsset alloc] initWithPath:f]; + } + } + return [super previewControlForItem:row]; +} + //- (id) previewControlForItem: (long) item //{ // ////NSLog(@"%@ %s", self, _cmd); @@ -91,9 +128,7 @@ -(void)reloadFiles [_paths removeAllObjects]; [_items removeAllObjects]; [_folders removeAllObjects]; - if (plistKey!=nil && plistPath!=nil ) { - [self setFpath:[SMFFolderBrowser stringForKey:plistKey inDomain:plistPath]]; - } + [[self list] removeDividers]; NSFileManager *man = [NSFileManager defaultManager]; @@ -140,23 +175,36 @@ -(void)rightActionForRow:(long)row { p=[_folders objectAtIndex:row]; } - else if(!separate && - [[NSFileManager defaultManager] fileExistsAtPath:[_folders objectAtIndex:row] isDirectory:&dir] - && dir) + else if(separate && (row-[_folders count])<[_files count]) { p=[_files objectAtIndex:row]; } - NSLog(@"p: %@",p); - NSLog(@"plistKey: %@",plistKey); - NSLog(@"plistPath: %@",plistPath); + else if(!separate) + { + p=[_files objectAtIndex:row]; + } + if (p) { - - if (plistKey!=nil && plistPath!=nil) { - [SMFFolderBrowser setString:p forKey:plistKey inDomain:plistPath]; - NSLog(@"plistKey and Path is good"); + if (delegate!=nil && [delegate conformsToProtocol:@protocol(SMFFolderBrowserDelegate)]) { + NSLog(@"delegate: %@ conforms to protocol",delegate); + if ([delegate hasActionForFile:p]) { + NSLog(@"delegate can use %@",p); + [delegate executeActionForFile:p]; + } } - NSLog(@"p is good"); +// if (prefs!=nil && prefKey!=nil) { +// [prefs setObject:p forKey:prefKey]; +// NSLog(@"writing %@ to %@ in %@",p,prefKey,prefs); +// if(popToController!=nil) +// { +// NSLog(@"popping to %@",popToController); +// [[self stack] popToController:popToController]; +// } +// } +// else if (plistKey!=nil && plistPath!=nil) { +// [SMFFolderBrowser setString:p forKey:plistKey inDomain:plistPath]; +// } } [self reloadFiles]; [[self list] reload]; @@ -169,8 +217,9 @@ -(void)itemSelected:(long)row { if (row<[_folders count]) { - NSString *newPath = [path stringByAppendingPathComponent:[_folders objectAtIndex:row]]; + NSString *newPath = [_folders objectAtIndex:row]; SMFFolderBrowser *p = [[SMFFolderBrowser alloc]initWithPath:newPath]; + p.delegate=self.delegate; [[self stack]pushController:p]; [p release]; } @@ -178,6 +227,7 @@ -(void)itemSelected:(long)row else { NSString *newPath = [_files objectAtIndex:row];//[path stringByAppendingPathComponent:[_files objectAtIndex:row]]; + BOOL isDir; if([man fileExistsAtPath:newPath isDirectory:&isDir] && isDir) { @@ -257,8 +307,13 @@ -(void)dealloc [_man release]; [_folders release]; [_files release]; + self.delegate=nil; [super dealloc]; } - +-(void)wasExhumed +{ + [self reloadFiles]; + [[self list] reload]; +} @end diff --git a/SMFImageAsset.h b/SMFImageAsset.h new file mode 100644 index 0000000..73e7407 --- /dev/null +++ b/SMFImageAsset.h @@ -0,0 +1,16 @@ +// +// SMFImageAsset.h +// SMFramework +// +// Created by Thomas Cool on 12/11/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFBaseAsset.h" + +@interface SMFImageAsset : SMFBaseAsset { + NSString *_path; +} +-(id)initWithPath:(NSString *)path; +-(NSString *)fileSize; +@end diff --git a/SMFImageAsset.m b/SMFImageAsset.m new file mode 100644 index 0000000..e97409d --- /dev/null +++ b/SMFImageAsset.m @@ -0,0 +1,62 @@ +// +// SMFImageAsset.m +// SMFramework +// +// Created by Thomas Cool on 12/11/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFImageAsset.h" +#import "SMFPhotoMethods.h" +#import "SMFMediaPreview.h" +@implementation SMFImageAsset +-(id)initWithPath:(NSString *)path +{ + if (![SMFPhotoMethods isImageAtPath:path]) + return nil; + self=[super init]; + [_image release]; + _image=[[BRImage imageWithPath:path] retain]; + _path = [path retain]; + [self setTitle:[_path lastPathComponent]]; + return self; + +} +-(NSDictionary *)orderedDictionary +{ + NSMutableDictionary *a=[[NSMutableDictionary alloc] init]; + if([_meta objectForKey:METADATA_TITLE]!=nil) + [a setObject:[_meta objectForKey:METADATA_TITLE] forKey:METADATA_TITLE]; + NSArray *keys = [NSArray arrayWithObjects:@"Width",@"Height",@"Size",nil]; + CGSize s = [_image pixelBounds]; + NSArray *objects = [NSArray arrayWithObjects: + [NSString stringWithFormat:@"%d Pixels",(int)s.width,nil], + [NSString stringWithFormat:@"%d Pixels",(int)s.height,nil], + [self fileSize], + nil]; + [a setObject:keys forKey:METADATA_CUSTOM_KEYS]; + [a setObject:objects forKey:METADATA_CUSTOM_OBJECTS]; + return [a autorelease]; +} +-(NSString *)fileSize +{ + NSDictionary *att = [[NSFileManager defaultManager] attributesOfItemAtPath:_path error:nil]; + double size = [[att objectForKey:NSFileSize] doubleValue]; + int mod=0; + while (size>1024.0f) { + size=size/1024.0f; + mod++; + } + NSString *ext=@"B"; + if (mod==1) + ext=@"KB"; + else if(mod==2) + ext=@"MB"; + else if(mod==2) + ext=@"GB"; + else if(mod==2) + ext=@"TB"; + return [NSString stringWithFormat:@"%.2f%@",size,ext,nil]; + +} +@end diff --git a/SMFMovieAsset.h b/SMFMovieAsset.h new file mode 100644 index 0000000..ed7fbe3 --- /dev/null +++ b/SMFMovieAsset.h @@ -0,0 +1,22 @@ +// +// SMMovieAsset.h +// SoftwareMenu +// +// Created by Thomas Cool on 4/16/10. +// Copyright 2010 Thomas Cool. All rights reserved. +// + + + + +@interface SMFMovieAsset : BRXMLMediaAsset { + BRImage *_image; + unsigned int resumeTime; +} +- (id)initWithMediaURL:(NSURL *)url; +-(void)setCoverArtPath:(NSString *)path; +-(void)setMediaSummary:(NSString *)summary; +-(void)setTitle:(NSString *)title; +-(void)setResumeTime:(unsigned int)time; +-(unsigned int)resumeTime; +@end diff --git a/SMFMovieAsset.m b/SMFMovieAsset.m new file mode 100644 index 0000000..d916d75 --- /dev/null +++ b/SMFMovieAsset.m @@ -0,0 +1,101 @@ +// +// SMMovieAsset.m +// SoftwareMenu +// +// Created by Thomas Cool on 4/16/10. +// Copyright 2010 Thomas Cool. All rights reserved. +// + +#import "SMFMovieAsset.h" + + +@implementation SMFMovieAsset +- (id)initWithMediaURL:(NSURL *)url +{ + //This is here to fix 2.2 + self = [super initWithMediaProvider:nil]; + NSString *urlString = [url absoluteString]; + NSString *filename = [url path]; + [self setObject:[filename lastPathComponent] forKey:@"id"]; + [self setObject:[BRMediaType movie] forKey:@"mediaType"]; + [self setObject:urlString forKey:@"mediaURL"]; + [self setObject:@"." forKey:@"mediaSummary"]; + [self setObject:[filename lastPathComponent] forKey:@"title"]; + _image=[[BRThemeInfo sharedTheme]tvShowFeaturedPlaceholderImage]; + NSLog(@"url: %@",[self mediaURL]); + [_image retain]; + return self; +} +-(BRImage *)coverArt +{ + return _image; +} +-(id)mediaType +{ + return [BRMediaType movie]; +} +- (BOOL)hasCoverArt +{ + return YES; +} +- (void)dealloc +{ + [_image release]; + [super dealloc]; +} + +- (void)setResumeTime:(unsigned int)time +{ + resumeTime = time; +} +-(unsigned int)resumeTime +{ + return resumeTime; +} +-(void)setCoverArtPath:(NSString *)path +{ + if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { + [_image release]; + _image=[[BRImage imageWithPath:path] retain]; + } +} +-(void)setMediaSummary:(NSString *)summary +{ + if (summary!=nil) { + [self setObject:summary forKey:@"mediaSummary"]; + } +} +-(void)setTitle:(NSString *)title +{ + if (title!=nil) { + [self setObject:title forKey:@"title"]; + } +} +/* Overrides the bookmark time */ +- (unsigned int)bookmarkTimeInSeconds +{ + /*Check for resume time and if none, return bookmark time*/ + if(time == 0) + return [super bookmarkTimeInSeconds]; + /*return resume time*/ + return resumeTime; +} +//-(id)mediaURL +//{ +// return @"/private/var/root/The A-Team (2010).m4v"; +//} +-(id)mediaSummary +{ + return @"Hello"; + //return [_info objectForKey:@"mediaSummary"]; +} +//-(id)mediaDescription +//{ +// return @"Hello"; +//} +-(id)title +{ + return @"Title"; + //return [_info objectForKey:@"title"]; +} +@end diff --git a/SMFPhotoMethods.h b/SMFPhotoMethods.h index 0d2ab68..331d637 100644 --- a/SMFPhotoMethods.h +++ b/SMFPhotoMethods.h @@ -12,15 +12,17 @@ @interface SMFPhotoMethods : NSObject { } ++(BOOL)isImageAtPath:(NSString *)path; +(NSArray *)mediaAssetsForPath:(id)path; +(NSArray *)photoPathsForPath:(id)path; +(NSArray *)imageProxiesForPath:(NSString *)path; +(NSMutableArray *)loadImagePathsForPath:(NSString *)path; -+(id)firstPhotoForPath:(NSString *)path; ++(BRImage *)firstPhotoForPath:(NSString *)path; +(id)photoCollectionForPath:(NSString *)path; +(BRDataStore *)dataStoreForAssets:(NSArray *)assets; +(BRDataStore *)dataStoreForPath:(NSString *)path; +(NSArray *)imageProxiesForPath:(NSString *)path nbImages:(NSInteger)nb; ++(int)imagesCountForPath:(NSString *)path; @end @interface SMFPhotoMediaCollection : BRPhotoMediaCollection diff --git a/SMFPopup.xm b/SMFPopup.xm index 38078c9..a4b8adc 100644 --- a/SMFPopup.xm +++ b/SMFPopup.xm @@ -5,35 +5,50 @@ // Created by Thomas Cool on 11/20/10. // Copyright 2010 tomcool.org. All rights reserved. // - +//%hook BRTrackInfoControl +//-(void)_updateCoverArt:(id)art +//{ +// NSLog(@"art: %@",art); +// return %orig; +// +//} +//%end %subclass SMFPopupInfo : BRTrackInfoControl - (id)_fetchCoverArt { - return [[BRThemeInfo sharedTheme] appleTVIcon]; } - (void)_updateTrackInfo { id l = MSHookIvar(self, "_layer"); + //BRImageControl *_layerArt = MSHookIvar(l,"_art"); id obj=[self object]; if(obj!=nil && [obj isKindOfClass:[NSDictionary class]]) { + //NSLog(@"obj: %@",obj); if([obj objectForKey:@"Image"]) { + //[self _updateCoverArt:[obj objectForKey:@"Image"]]; if([obj objectForKey:@"Lines"]) [l setLines:[obj objectForKey:@"Lines"] withImage:[obj objectForKey:@"Image"]]; else [l setImage:[obj objectForKey:@"Image"]]; + //[_layerArt setImage:[obj objectForKey:@"Image"]]; } else + { + //[self _updateCoverArt:[self _fetchCoverArt]]; [l setLines:[NSArray arrayWithObjects:@"error",nil] withImage:[self _fetchCoverArt]]; + } + } else [l setLines:[NSArray arrayWithObjects:@"error",nil] withImage:[self _fetchCoverArt]]; - +// [l _updateSublayers]; +// [l layoutSubcontrols]; //%orig; } %end \ No newline at end of file diff --git a/SMFPreferences.h b/SMFPreferences.h new file mode 100644 index 0000000..0eb68f0 --- /dev/null +++ b/SMFPreferences.h @@ -0,0 +1,20 @@ +// +// SMFPreferences.h +// SMFramework +// +// Created by Thomas Cool on 12/6/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + + + + +@interface SMFPreferences : NSUserDefaults { + NSString * _applicationID; + NSDictionary * _registrationDictionary; +} + +-(id)initWithPersistentDomainName:(NSString *)domainName; ++(SMFPreferences *)preferences; +@end + diff --git a/SMFPreferences.m b/SMFPreferences.m new file mode 100644 index 0000000..b2fdecb --- /dev/null +++ b/SMFPreferences.m @@ -0,0 +1,91 @@ +// +// SMFPreferences.m +// SMFramework +// +// Created by Thomas Cool on 12/6/10. +// Copyright 2010 tomcool.org. All rights reserved. +// + +#import "SMFPreferences.h" + + +@implementation SMFPreferences + ++(SMFPreferences *)preferences { + static SMFPreferences *_preferences = nil; + + if(!_preferences) + _preferences = [[self alloc] initWithPersistentDomainName:@"org.tomcool.SMFramework"]; + + return _preferences; +} + +-(id)initWithPersistentDomainName:(NSString *)domainName { + if((self = [super init])) { + _applicationID = [domainName copy]; + _registrationDictionary = nil; + } + + return self; +} + +-(void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_applicationID release]; + [_registrationDictionary release]; + [super dealloc]; +} + +-(id)objectForKey:(NSString *)defaultName { + id value = [(id)CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)_applicationID) autorelease]; + if(value == nil) + value = [_registrationDictionary objectForKey:defaultName]; + return value; +} + +-(void)setObject:(id)value forKey:(NSString *)defaultName { + CFPreferencesSetAppValue((CFStringRef)defaultName, (CFPropertyListRef)value, (CFStringRef)_applicationID); + [self synchronize]; +} + +-(void)removeObjectForKey:(NSString *)defaultName { + CFPreferencesSetAppValue((CFStringRef)defaultName, NULL, (CFStringRef)_applicationID); + [self synchronize]; +} +-(void)setBool:(BOOL)value forKey:(NSString *)defaultName +{ + CFPreferencesSetAppValue((CFStringRef)defaultName, (CFNumberRef)[NSNumber numberWithBool:value] , (CFStringRef)_applicationID); + [self synchronize]; +} +-(void)setInteger:(NSInteger)value forKey:(NSString *)defaultName +{ + CFPreferencesSetAppValue((CFStringRef)defaultName, (CFNumberRef)[NSNumber numberWithInteger:value], (CFStringRef)_applicationID); + [self synchronize]; +} +-(BOOL)boolForKey:(NSString *)defaultName +{ + id obj = [self objectForKey:defaultName]; + if(obj!=nil && [obj respondsToSelector:@selector(boolValue)]) + return [obj boolValue]; + return [[_registrationDictionary objectForKey:defaultName] boolValue]; +} +-(NSInteger)integerForKey:(NSString *)defaultName +{ + id obj = [self objectForKey:defaultName]; + if(obj!=nil && [obj respondsToSelector:@selector(integerValue)]) + return [obj integerValue]; + return [[_registrationDictionary objectForKey:defaultName] integerValue]; +} + +-(void)registerDefaults:(NSDictionary *)registrationDictionary { + [_registrationDictionary release]; + _registrationDictionary = [registrationDictionary retain]; +} + +-(BOOL)synchronize { + return CFPreferencesSynchronize((CFStringRef)_applicationID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); +} + + +@end diff --git a/SMFProgressBarMenuItem.h b/SMFProgressBarMenuItem.h new file mode 100644 index 0000000..a9d4299 --- /dev/null +++ b/SMFProgressBarMenuItem.h @@ -0,0 +1,44 @@ +// +// SMFProgressBarMenuItem.h +// SoftwareMenuFramework +// +// Created by Thomas Cool on 2/27/10. +// Copyright 2010 Thomas Cool. All rights reserved. +// + + +@class SMFProgressBarControl; +@interface SMFProgressBarMenuItem : BRMenuItem { + SMFProgressBarControl * _progressBar; + BOOL showBar; + float _leftBarIndent; //number from 0 -> 1 + float _rightBarIndent; //number from 0 -> 1 if leftBar>rightBar, default full bar is selected + //0 for left and 1 for right +} ++(SMFProgressBarMenuItem *)progressMenuItem; //Full bar, can be manually adjusted. ++(SMFProgressBarMenuItem *)menuItem; //no bar, like a BRTextImageMenuItemLayer ++(SMFProgressBarMenuItem *)rightProgressBarMenuItem; //with a bar taking up right 30% ++(SMFProgressBarMenuItem *)leftProgressBarMenuItem; //with a bar taking up left 75% ++(SMFProgressBarMenuItem *)centeredProgressBarMenuItem; //with a bar taking up center 50% + +-(id)init; +-(void)layoutSubcontrols; +-(void)dealloc; + + + +#pragma mark Progress Bar Methods +-(void)setLeftIndentFraction:(float)frac; +-(void)setRightIndentFraction:(float)frac; +-(float)leftIndentFraction; +-(float)rightIndentFraction; +-(void)setShowsBar:(BOOL)val; +-(BOOL)showsBar; +-(void)setProgressValue:(float)val; +-(void)setMaxProgressValue:(float)max; +-(void)setMinProgressValue:(float)min; +-(float)currentProgress; +-(float)maxProgressValue; +-(float)minProgressValue; +-(void)setNeedsDisplay:(BOOL)disp; +@end diff --git a/SMFProgressBarMenuItem.m b/SMFProgressBarMenuItem.m new file mode 100644 index 0000000..9803ef6 --- /dev/null +++ b/SMFProgressBarMenuItem.m @@ -0,0 +1,142 @@ +// +// SMFProgressBarMenuItem.m +// SoftwareMenuFramework +// +// Created by Thomas Cool on 2/27/10. +// Copyright 2010 Thomas Cool. All rights reserved. +// + +#import "SMFProgressBarMenuItem.h" +#import "SMFProgressBarControl.h" +@implementation SMFProgressBarMenuItem ++(SMFProgressBarMenuItem *)progressMenuItem +{ + SMFProgressBarMenuItem *a = [[SMFProgressBarMenuItem alloc]init]; + [a setShowsBar:YES]; + return [a autorelease]; +} ++(SMFProgressBarMenuItem *)menuItem +{ + SMFProgressBarMenuItem *a = [[SMFProgressBarMenuItem alloc]init]; + [a setShowsBar:NO]; + return [a autorelease]; +} ++(SMFProgressBarMenuItem *)rightProgressBarMenuItem +{ + SMFProgressBarMenuItem *a = [[SMFProgressBarMenuItem alloc] init]; + [a setShowsBar:YES]; + [a setLeftIndentFraction:0.75f]; + return [a autorelease]; +} ++(SMFProgressBarMenuItem *)leftProgressBarMenuItem +{ + SMFProgressBarMenuItem *a = [[SMFProgressBarMenuItem alloc] init]; + [a setShowsBar:YES]; + [a setRightIndentFraction:0.7f]; + return [a autorelease]; +} ++(SMFProgressBarMenuItem *)centeredProgressBarMenuItem +{ + SMFProgressBarMenuItem *a = [[SMFProgressBarMenuItem alloc] init]; + [a setShowsBar:YES]; + [a setLeftIndentFraction:0.75f]; + [a setRightIndentFraction:0.75f]; + return [a autorelease]; +} +-(id)init +{ + self = [super init]; + _progressBar = [[SMFProgressBarControl alloc]init]; + [_progressBar setMaxValue:100.0f]; + [_progressBar setMinValue:0.0f]; + [_progressBar setCurrentValue:0.f]; + [self setLeftIndentFraction:0.]; + [self setRightIndentFraction:1.]; + return self; +} +-(void)dealloc +{ + [_progressBar release]; + [super dealloc]; +} +-(void)layoutSubcontrols +{ + [super layoutSubcontrols]; + CGRect bounds = [self bounds]; + float b=0.3f; + float a=[[BRThemeInfo sharedTheme] textMenuItemLeftInsetAndRightInset:&b]; + bounds.origin.x=a; + bounds.size.width=bounds.size.width-a-b; + float width = bounds.size.width*([self rightIndentFraction]-[self leftIndentFraction]); + float x=bounds.size.width*[self leftIndentFraction]; + bounds.size.width=width; + bounds.origin.x=x+bounds.origin.x; + if ([self showsBar]) { + [self addControl:_progressBar]; + [_progressBar setFrame:bounds]; + } + else { + [_progressBar removeFromParent]; + } + + +} + +#pragma mark Progress Bar Methods +-(void)setLeftIndentFraction:(float)frac +{ + _leftBarIndent=frac; +} +-(void)setRightIndentFraction:(float)frac +{ + _rightBarIndent=frac; +} +-(float)leftIndentFraction +{ + return _leftBarIndent; +} +-(float)rightIndentFraction +{ + return _rightBarIndent; +} +-(void)setShowsBar:(BOOL)val +{ + showBar=val; +} +-(BOOL)showsBar +{ + return showBar; +} +-(void)setProgressValue:(float)val +{ + [_progressBar setCurrentValue:val]; + [self setNeedsDisplay:YES]; +} +-(void)setMaxProgressValue:(float)max +{ + [_progressBar setMaxValue:max]; + [self setNeedsDisplay:YES]; +} +-(void)setMinProgressValue:(float)min +{ + [_progressBar setMinValue:min]; + [self setNeedsDisplay:YES]; +} +-(float)currentProgress +{ + return [_progressBar currentValue]; +} +-(float)maxProgressValue +{ + return [_progressBar maxValue]; +} +-(float)minProgressValue +{ + return [_progressBar minValue]; +} +-(void)setNeedsDisplay:(BOOL)disp +{ + //[super setNeedsDisplay:disp]; + //[_progressBar setNeedsLayout:YES]; +} +@end diff --git a/SMFQueryMenu.m b/SMFQueryMenu.m index 3720768..7383a70 100644 --- a/SMFQueryMenu.m +++ b/SMFQueryMenu.m @@ -97,7 +97,6 @@ - (id)itemForRow:(long)row } - (id)titleForRow:(long)row { - return [_filteredArray objectAtIndex:row]; } -(void)itemSelected:(long)selected diff --git a/SMFThemeInfo.h b/SMFThemeInfo.h index e493e0a..84b8a76 100644 --- a/SMFThemeInfo.h +++ b/SMFThemeInfo.h @@ -13,4 +13,7 @@ } +(SMFThemeInfo *)sharedTheme; -(BRImage *)selectedImage; +-(BRImage *)colorAppleTVNameImage; +-(BRImage *)keyboardIcon; +-(BRImage *)btstackIcon; @end diff --git a/SMFThemeInfo.m b/SMFThemeInfo.m index fe595e2..c39e33f 100644 --- a/SMFThemeInfo.m +++ b/SMFThemeInfo.m @@ -15,4 +15,16 @@ -(BRImage *)selectedImage { return [BRImage imageWithPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"selsettings" ofType:@"png"]]; } +-(BRImage *)colorAppleTVNameImage +{ + return [BRImage imageWithPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"colorAppleTVNameImage" ofType:@"png"]]; +} +-(BRImage *)keyboardIcon +{ + return [BRImage imageWithPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"Keyboard" ofType:@"png"]]; +} +-(BRImage *)btstackIcon +{ + return [BRImage imageWithPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"btstack" ofType:@"png"]]; +} @end diff --git a/SMFramework.h b/SMFramework.h index 52ef508..6b20e2f 100644 --- a/SMFramework.h +++ b/SMFramework.h @@ -21,4 +21,8 @@ #import "SMFPhotoMethods.h" #import "SMFCommonTools.h" #import "SMFPhotoMethods.h" -#import "SMFQueryMenu.h" \ No newline at end of file +#import "SMFQueryMenu.h" +#import "SMFThemeInfo.h" +#import "SMFMenuItem.h" +#import "SMFPreferences.h" +#import "SMFImageAsset.h" \ No newline at end of file