Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/joehewitt/three20
Browse files Browse the repository at this point in the history
  • Loading branch information
dhou committed Apr 10, 2009
2 parents 82be2c9 + caf14a9 commit fe17419
Show file tree
Hide file tree
Showing 42 changed files with 863 additions and 544 deletions.
5 changes: 3 additions & 2 deletions samples/TTCatalog/Classes/ActivityTestController.m
Expand Up @@ -8,8 +8,9 @@ - (void)loadView {
self.view = [[[UIView alloc] init] autorelease];
self.view.backgroundColor = [UIColor blackColor];

TTShinyLabel* label = [[[TTShinyLabel alloc] initWithFrame:CGRectMake(0,150,320,100)] autorelease];
label.text = @"One Shiny Label";
TTSearchlightLabel* label = [[[TTSearchlightLabel alloc] initWithFrame:CGRectMake(0,150,320,100)]
autorelease];
label.text = @"Searchlight Label";
label.font = [UIFont systemFontOfSize:25];
label.textAlignment = UITextAlignmentCenter;
label.contentMode = UIViewContentModeCenter;
Expand Down
8 changes: 4 additions & 4 deletions samples/TTCatalog/Classes/ButtonTestController.m
Expand Up @@ -30,8 +30,8 @@ - (TTStyle*)embossedButton:(UIControlState)state {
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(255, 255, 255)
color2:RGBCOLOR(216, 221, 231) next:
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, -1, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(4, 8, 4-1, 8) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:14]
color:TTSTYLEVAR(linkTextColor)
shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]];
Expand All @@ -43,8 +43,8 @@ - (TTStyle*)embossedButton:(UIControlState)state {
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(225, 225, 225)
color2:RGBCOLOR(196, 201, 221) next:
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, -1, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(4, 8, 4-1, 8) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:14]
color:[UIColor whiteColor] shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]];
} else {
Expand Down
10 changes: 6 additions & 4 deletions samples/TTCatalog/Classes/RootViewController.m
Expand Up @@ -54,10 +54,12 @@ - (void)viewDidLoad {
[nav addView:@"youTubeTest" controller:[YouTubeTestController class]];
[nav addView:@"imageTest2" controller:[TableImageTestController class]];
[nav addView:@"scrollViewTest" controller:[ScrollViewTestController class]];


#ifdef JOE
[self validateView];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:3];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:1 inSection:3];
[self.tableView touchRowAtIndexPath:indexPath animated:NO];
#endif
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -72,7 +74,7 @@ - (void)viewDidLoad {
url:@"tt://photoTest2"] autorelease],

@"Text Fields",
[[[TTTableField alloc] initWithText:@"Composer"
[[[TTTableField alloc] initWithText:@"Message Composer"
url:@"tt://composerTest"] autorelease],
[[[TTTableField alloc] initWithText:@"Search Bar"
url:@"tt://searchTest"] autorelease],
Expand Down Expand Up @@ -104,7 +106,7 @@ - (void)viewDidLoad {
url:@"tt://imageTest1"] autorelease],
[[[TTTableField alloc] initWithText:@"YouTube Player"
url:@"tt://youTubeTest"] autorelease],
[[[TTTableField alloc] initWithText:@"Activity Views"
[[[TTTableField alloc] initWithText:@"Activity Labels"
url:@"tt://activityTest"] autorelease],
[[[TTTableField alloc] initWithText:@"Scroll View"
url:@"tt://scrollViewTest"] autorelease],
Expand Down
2 changes: 1 addition & 1 deletion samples/TTCatalog/Classes/StyleTestController.m
Expand Up @@ -87,7 +87,7 @@ - (void)loadView {
width:1 lightSource:270 next:nil]]]]]],


// New bubble
// Badge
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1.5, 1.5, 1.5, 1.5) next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.8) blur:2 offset:CGSizeMake(0, 5) next:
Expand Down
24 changes: 5 additions & 19 deletions samples/TTCatalog/Classes/TabBarTestController.m
Expand Up @@ -11,11 +11,11 @@ - (void)dealloc {

- (void)loadView {
self.view = [[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];
self.view.backgroundColor = RGBCOLOR(240, 242, 245);
self.view.backgroundColor = TTSTYLEVAR(tabTintColor);

_tabBar1 = [[TTTabBar alloc] initWithFrame:CGRectMake(0, -1, 320, 43)
style:TTTabBarStyleButtons];
_tabBar1.delegate = self;
_tabBar1 = [[TTTabBar alloc] initWithFrame:CGRectMake(0, 0, 320, 41)];
_tabBar1.tabStyle = @"tabRound:";
_tabBar1.style = TTSTYLE(tabBarSmall);
[self.view addSubview:_tabBar1];

_tabBar1.tabItems = [NSArray arrayWithObjects:
Expand All @@ -31,9 +31,7 @@ - (void)loadView {
[[[TTTabItem alloc] initWithTitle:@"Item 10"] autorelease],
nil];

_tabBar2 = [[TTTabBar alloc] initWithFrame:CGRectMake(0, 42, 320, 41)
style:TTTabBarStyleDark];
_tabBar2.delegate = self;
_tabBar2 = [[TTTabBar alloc] initWithFrame:CGRectMake(0, _tabBar1.bottom, 320, 40)];
_tabBar2.contentMode = UIViewContentModeScaleToFill;
[self.view addSubview:_tabBar2];

Expand All @@ -48,18 +46,6 @@ - (void)loadView {

TTTabItem* item = [_tabBar2.tabItems objectAtIndex:1];
item.badgeNumber = 2;

_tabBar3 = [[TTTabBar alloc] initWithFrame:CGRectMake(0, 100, 320, 41)
style:TTTabBarStyleLight];
_tabBar3.delegate = self;
_tabBar3.contentMode = UIViewContentModeScaleToFill;
[self.view addSubview:_tabBar3];

_tabBar3.tabItems = [NSArray arrayWithObjects:
[[[TTTabItem alloc] initWithTitle:@"Red"] autorelease],
[[[TTTabItem alloc] initWithTitle:@"Green"] autorelease],
[[[TTTabItem alloc] initWithTitle:@"Blue"] autorelease],
nil];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
54 changes: 54 additions & 0 deletions src/TTBadgeView.m
@@ -0,0 +1,54 @@
#import "Three20/TTBadgeView.h"
#import "Three20/TTDefaultStyleSheet.h"

///////////////////////////////////////////////////////////////////////////////////////////////////

@implementation TTBadgeView

@synthesize message = _message;

///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject

- (id)initWithMessage:(NSString*)message {
if (self = [self initWithFrame:CGRectZero]) {
self.message = message;
self.userInteractionEnabled = NO;
}
return self;
}

- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_message = nil;

self.style = TTSTYLE(badge);
self.backgroundColor = [UIColor clearColor];
}
return self;
}

- (void)dealloc {
[_message release];
[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// TTStyleDelegate

- (NSString*)textForLayerWithStyle:(TTStyle*)style {
return _message;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// public

- (void)setMessage:(NSString*)message {
if (message != _message) {
[_message release];
_message = [message copy];
[self setNeedsDisplay];
}
}

@end
49 changes: 30 additions & 19 deletions src/TTButton.m
Expand Up @@ -138,10 +138,10 @@ @implementation TTButton
///////////////////////////////////////////////////////////////////////////////////////////////////
// class public

+ (TTButton*)buttonWithStyle:(NSString*)className title:(NSString*)title {
+ (TTButton*)buttonWithStyle:(NSString*)selector title:(NSString*)title {
TTButton* button = [[[TTButton alloc] initWithFrame:CGRectZero] autorelease];
[button setTitle:title forState:UIControlStateNormal];
[button setStylesWithClassName:className];
[button setStylesWithSelector:selector];

return button;
}
Expand All @@ -156,7 +156,7 @@ - (UIFont*)defaultFont {
- (CGRect)rectForTitle:(NSString*)title forSize:(CGSize)size withFont:(UIFont*)font {
CGRect rect = CGRectZero;
if (self.contentHorizontalAlignment == UIControlContentHorizontalAlignmentLeft
&& self.contentHorizontalAlignment == UIControlContentVerticalAlignmentTop) {
&& self.contentVerticalAlignment == UIControlContentVerticalAlignmentTop) {
rect.size = size;
} else {
CGSize textSize = [title sizeWithFont:font];
Expand Down Expand Up @@ -222,10 +222,10 @@ - (TTButtonContent*)contentForState:(UIControlState)state {

- (TTButtonContent*)contentForCurrentState {
TTButtonContent* content = nil;
if (self.highlighted) {
content = [self contentForState:UIControlStateHighlighted];
} else if (self.selected) {
if (self.selected) {
content = [self contentForState:UIControlStateSelected];
} else if (self.highlighted) {
content = [self contentForState:UIControlStateHighlighted];
} else if (!self.enabled) {
content = [self contentForState:UIControlStateDisabled];
}
Expand Down Expand Up @@ -305,14 +305,21 @@ - (void)drawRect:(CGRect)rect {
}

- (CGSize)sizeThatFits:(CGSize)size {
NSString* title = [self titleForCurrentState];
UIFont* font = [self fontForCurrentState];
TTStyle* style = [self styleForCurrentState];
if (style) {
return [style addToSize:CGSizeZero delegate:self];
} else {
return size;
}

CGRect textRect = [self rectForTitle:title forSize:size withFont:font];
UIEdgeInsets insets = [self insetsForCurrentStateWithSize:textRect.size];

return CGSizeMake(textRect.size.width + insets.left + insets.right,
textRect.size.height + insets.top + insets.bottom);
// NSString* title = [self titleForCurrentState];
// UIFont* font = [self fontForCurrentState];
//
// CGRect textRect = [self rectForTitle:title forSize:size withFont:font];
// UIEdgeInsets insets = [self insetsForCurrentStateWithSize:textRect.size];
//
// return CGSizeMake(textRect.size.width + insets.left + insets.right,
// textRect.size.height + insets.top + insets.bottom);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -336,7 +343,7 @@ - (void)setEnabled:(BOOL)enabled {
///////////////////////////////////////////////////////////////////////////////////////////////////
// TTStyleDelegate

- (void)drawContent:(CGRect)rect withStyle:(TTStyle*)style shape:(TTShape*)shape {
- (void)drawLayer:(CGRect)rect withStyle:(TTStyle*)style shape:(TTShape*)shape {
NSString* title = [self titleForCurrentState];
UIEdgeInsets shapeInsets = [shape insetsForSize:rect.size];
CGRect innerRect = TTRectInset(rect, shapeInsets);
Expand Down Expand Up @@ -365,6 +372,10 @@ - (void)drawContent:(CGRect)rect withStyle:(TTStyle*)style shape:(TTShape*)shape
}
}

- (NSString*)textForLayerWithStyle:(TTStyle*)style {
return [self titleForCurrentState];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// public

Expand Down Expand Up @@ -403,19 +414,19 @@ - (void)setStyle:(TTStyle*)style forState:(UIControlState)state {
content.style = style;
}

- (void)setStylesWithClassName:(NSString*)className {
- (void)setStylesWithSelector:(NSString*)selector {
TTStyleSheet* ss = [TTStyleSheet globalStyleSheet];

TTStyle* normalStyle = [ss styleWithClassName:className forState:UIControlStateNormal];
TTStyle* normalStyle = [ss styleWithSelector:selector forState:UIControlStateNormal];
[self setStyle:normalStyle forState:UIControlStateNormal];

TTStyle* highlightedStyle = [ss styleWithClassName:className forState:UIControlStateHighlighted];
TTStyle* highlightedStyle = [ss styleWithSelector:selector forState:UIControlStateHighlighted];
[self setStyle:highlightedStyle forState:UIControlStateHighlighted];

TTStyle* selectedStyle = [ss styleWithClassName:className forState:UIControlStateSelected];
TTStyle* selectedStyle = [ss styleWithSelector:selector forState:UIControlStateSelected];
[self setStyle:selectedStyle forState:UIControlStateSelected];

TTStyle* disabledStyle = [ss styleWithClassName:className forState:UIControlStateDisabled];
TTStyle* disabledStyle = [ss styleWithSelector:selector forState:UIControlStateDisabled];
[self setStyle:disabledStyle forState:UIControlStateDisabled];
}

Expand Down

0 comments on commit fe17419

Please sign in to comment.