From ea1783504decc58477a1487f421b8c8eb798d087 Mon Sep 17 00:00:00 2001 From: Francisco Tolmasky Date: Mon, 18 May 2009 22:57:39 -0700 Subject: [PATCH] Added HUD to Aristo. Reviewed by me. --- AppKit/Themes/Aristo/ThemeDescriptors.j | 51 ++++++++++++++ AppKit/Tools/BlendKit/BKShowcaseController.j | 72 +++++++++++++++++--- AppKit/Tools/blend/main.j | 8 +-- Tools/nib2cib/main.j | 6 +- 4 files changed, 119 insertions(+), 18 deletions(-) diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index 4e896255d..0b1449682 100644 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -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]; diff --git a/AppKit/Tools/BlendKit/BKShowcaseController.j b/AppKit/Tools/BlendKit/BKShowcaseController.j index 6eb8deb5e..4b5a15fa3 100644 --- a/AppKit/Tools/BlendKit/BKShowcaseController.j +++ b/AppKit/Tools/BlendKit/BKShowcaseController.j @@ -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 diff --git a/AppKit/Tools/blend/main.j b/AppKit/Tools/blend/main.j index ad3367094..716cf60c5 100755 --- a/AppKit/Tools/blend/main.j +++ b/AppKit/Tools/blend/main.j @@ -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 { diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 282377d76..fa46bfce7 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -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); }