Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cd0c55
commit 2575a7f
Showing
26 changed files
with
827 additions
and
46 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 <UIKit/UIColor.h> | |||
|
|||
@protocol SMFColorSelectionDelegate | |||
-(void)colorSelected:(NSArray *)rgba forKey:(NSString *)key; | |||
@end | |||
|
|||
@interface SMFColorSelectionMenu : SMFMediaMenuController { | |||
id<SMFColorSelectionDelegate>delegate; | |||
NSString *key; | |||
NSArray *colors; | |||
} | |||
+(SMFColorSelectionMenu *)colorMenuForKey:(NSString *)k andDelegate:(id<SMFColorSelectionDelegate>)del; | |||
@property (assign) id<SMFColorSelectionDelegate> delegate; | |||
@property (retain) NSString * key; | |||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 <UIKit/UIColor.h> | |||
#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<SMFColorSelectionDelegate>)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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.