Added HUD to Aristo.

Reviewed by me.
This commit is contained in:
Francisco Tolmasky
2009-05-18 22:57:39 -07:00
parent 8391f593d9
commit ea1783504d
4 changed files with 119 additions and 18 deletions
+51
View File
@@ -501,6 +501,57 @@
@end
@implementation AristoHUDThemeDescriptor : CPObject
{
}
+ (CPString)themeName
{
return @"Aristo-HUD";
}
+ (CPColor)themeShowcaseBackgroundColor
{
return [CPColor blackColor];
}
+ (CPButton)themedButton
{
var button = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 20.0)],
bezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-left.png" size:CGSizeMake(13.0, 20.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-center.png" size:CGSizeMake(1.0, 20.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-right.png" size:CGSizeMake(13.0, 20.0)]
]
isVertical:NO]],
highlightedBezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-highlighted-left.png" size:CGSizeMake(13.0, 20.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-highlighted-center.png" size:CGSizeMake(1.0, 20.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/button-bezel-highlighted-right.png" size:CGSizeMake(13.0, 20.0)]
]
isVertical:NO]];
[button setTitle:@"Cancel"];
[button setValue:[CPFont systemFontOfSize:11.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
[button setValue:[CPColor whiteColor] forThemeAttribute:@"text-color"];
[button setValue:CPLineBreakByTruncatingTail forThemeAttribute:@"line-break-mode"];
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[button setValue:highlightedBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered|CPThemeStateHighlighted];
[button setValue:CGInsetMake(2.0, 5.0, 4.0, 5.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
[button setValue:20.0 forThemeAttribute:@"default-height"];
return button;
}
@end
function PatternColor(anImage)
{
return [CPColor colorWithPatternImage:anImage];
+61 -11
View File
@@ -22,11 +22,12 @@
[contentView addSubview:tabView];
var count = [themeDescriptorClasses count];
var index = 0,
count = [themeDescriptorClasses count];
while (count--)
for (; index < count; ++index)
{
var theClass = themeDescriptorClasses[count],
var theClass = themeDescriptorClasses[index],
item = [[CPTabViewItem alloc] initWithIdentifier:[theClass themeName]],
templates = BKThemeObjectTemplatesForClass(theClass),
templatesCount = [templates count],
@@ -56,12 +57,18 @@
}
}
itemSize.height += 30;
itemSize.width += 20.0;
itemSize.height += 30.0;
var collectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()],
collectionViewItem = [[CPCollectionViewItem alloc] init];
[collectionViewItem setView:[[BKShowcaseCell alloc] init]];
var backgroundColor = nil;
if ([theClass respondsToSelector:@selector(themeShowcaseBackgroundColor)])
backgroundColor = [theClass themeShowcaseBackgroundColor];
[collectionViewItem setView:[[BKShowcaseCell alloc] initWithShowcaseBackgroundColor:backgroundColor]];
[collectionView setItemPrototype:collectionViewItem];
[collectionView setMinItemSize:itemSize];
@@ -83,10 +90,23 @@
@implementation BKShowcaseCell : CPView
{
CPColor _showcaseBackgroundColor;
CPView _backgroundView;
CPView _view;
CPTextField _label;
}
- (id)initWithShowcaseBackgroundColor:(CPColor)aColor
{
self = [super init];
if (self)
_showcaseBackgroundColor = aColor;
return self;
}
- (void)setSelected:(BOOL)isSelected
{
}
@@ -110,16 +130,46 @@
[_label setFrame:CGRectMake(0.0, CGRectGetHeight([self bounds]) - CGRectGetHeight([_label frame]),
CGRectGetWidth([self bounds]), CGRectGetHeight([_label frame]))];
if (!_backgroundView)
{
_backgroundView = [[CPView alloc] init];
[_backgroundView setBackgroundColor:_showcaseBackgroundColor];
[self addSubview:_backgroundView];
}
[_backgroundView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth([self bounds]), CGRectGetMinY([_label frame]))];
[_backgroundView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
if (_view)
[_view removeFromSuperview];
_view = [anObject valueForKey:@"themedObject"];
[_view setTheme:nil];
[_view setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[_view setFrameOrigin:CGPointMake((CGRectGetWidth([self bounds]) - CGRectGetWidth([_view frame])) / 2.0, (CGRectGetMinY([_label frame]) - CGRectGetHeight([_view frame])) / 2.0)];
[self addSubview:_view];
[_view setFrameOrigin:CGPointMake((CGRectGetWidth([_backgroundView bounds]) - CGRectGetWidth([_view frame])) / 2.0,
(CGRectGetHeight([_backgroundView bounds]) - CGRectGetHeight([_view frame])) / 2.0)];
[_backgroundView addSubview:_view];
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
_showcaseBackgroundColor = [aCoder decodeObjectForKey:@"showcase-background-color"];
return self
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_showcaseBackgroundColor forKey:@"showcase-background-color"];
}
@end
+4 -4
View File
@@ -60,7 +60,7 @@ function main()
while (count--)
{
var theClass = themeDescriptorClasses[count],
themeTemplate = [[AKThemeTemplate alloc] init];
themeTemplate = [[BKThemeTemplate alloc] init];
[themeTemplate setValue:[theClass themeName] forKey:@"name"];
@@ -182,7 +182,7 @@ function themeFromCibFile(aFile)
templates = templates.concat([object blendThemeObjectTemplates]);
if ([object isKindOfClass:[AKThemeTemplate class]])
if ([object isKindOfClass:[BKThemeTemplate class]])
theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]];
}
@@ -250,7 +250,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
{
var theClass = [self class];
if ([theClass isKindOfClass:[AKThemeObjectTemplate class]])
if ([theClass isKindOfClass:[BKThemeObjectTemplate class]])
return [self];
if ([theClass isKindOfClass:[CPView class]])
@@ -270,7 +270,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
@end
@implementation AKThemeObjectTemplate (BlendAdditions)
@implementation BKThemeObjectTemplate (BlendAdditions)
- (void)blendAddThemedObjectAttributesToTheme:(CPTheme)aTheme
{
+3 -3
View File
@@ -223,8 +223,8 @@ function main()
outputFileName = cibExtension(inputFileName);
if (frameworkPaths.length)
loadFrameworks(frameworkPaths, function() { convert(inputFileName, outputFileName, resourcesPath); print ("done");});
loadFrameworks(frameworkPaths, function() { convert(inputFileName, outputFileName, resourcesPath); });
else{
convert(inputFileName, outputFileName, resourcesPath);print ("done");}
else
convert(inputFileName, outputFileName, resourcesPath);
}