Permalink
Browse files

* Minor code style tweaks and documentation updates

* Make TTSearchBar a bit more stylable using TTBackgroundView
* Fix conflict with Facebook Connect library
  • Loading branch information...
joehewitt committed Mar 25, 2009
1 parent 2dec911 commit 7bab43f03e0dcd0281498ea212a74e5545fa75c2
View
@@ -41,6 +41,9 @@ Three20 is compiled as a static library, and the easiest way to add it to your p
"Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click
it. Add the relative path from your project's directory to the "three20/src" directory. Then
go to "Other Linker Flags" under the "Linker" section, and add "-ObjC" to the list of flags.
+
+7. You're ready to go. Just #import "Three20/Three20.h" anywhere you want to use Three20 classes
+ in your project.
What's in Three20?
==================
View
@@ -6,13 +6,13 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-const void* RetainNoOp(CFAllocatorRef allocator, const void *value) { return value; }
-void ReleaseNoOp(CFAllocatorRef allocator, const void *value) { }
+static const void* TTRetainNoOp(CFAllocatorRef allocator, const void *value) { return value; }
+static void TTReleaseNoOp(CFAllocatorRef allocator, const void *value) { }
NSMutableArray* TTCreateNonRetainingArray() {
CFArrayCallBacks callbacks = kCFTypeArrayCallBacks;
- callbacks.retain = RetainNoOp;
- callbacks.release = ReleaseNoOp;
+ callbacks.retain = TTRetainNoOp;
+ callbacks.release = TTReleaseNoOp;
return (NSMutableArray*)CFArrayCreateMutable(nil, 0, &callbacks);
}
View
@@ -1129,7 +1129,6 @@ - (void)reloadData {
}
}
-
- (UIView*)pageAtIndex:(NSInteger)pageIndex {
return [self pageAtIndex:pageIndex create:NO];
}
View
@@ -18,8 +18,8 @@
@implementation TTSearchBar
-@synthesize boxView = _boxView, tintColor = _tintColor, showsCancelButton = _showsCancelButton,
- showsSearchIcon = _showsSearchIcon;
+@synthesize boxView = _boxView, tintColor = _tintColor,
+ showsCancelButton = _showsCancelButton, showsSearchIcon = _showsSearchIcon;
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
@@ -89,6 +89,8 @@ - (void)textFieldDidEndEditing {
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
+ _style = TTDrawReflection;
+
_boxView = [[TTBackgroundView alloc] initWithFrame:CGRectZero];
_boxView.backgroundColor = [UIColor clearColor];
_boxView.style = TTDrawRoundInnerShadow;
@@ -135,10 +137,12 @@ - (BOOL)resignFirstResponder {
// UIView
- (void)drawRect:(CGRect)rect {
- if (_tintColor && _tintColor != [UIColor clearColor]) {
+ if (_style == TTDrawReflection) {
UIColor* fill[] = {_tintColor};
[[TTAppearance appearance] draw:TTDrawReflection rect:rect
fill:fill fillCount:1 stroke:nil radius:0];
+ } else {
+ [super drawRect:rect];
}
}
View
@@ -49,7 +49,7 @@ - (void)releaseMask {
_maskData = nil;
}
-- (CGImageRef)createShinyMask:(CGRect)rect origin:(CGPoint)origin radius:(CGFloat)radius {
+- (CGImageRef)createSpotlightMask:(CGRect)rect origin:(CGPoint)origin radius:(CGFloat)radius {
CGContextClearRect(_maskContext, rect);
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
@@ -63,7 +63,7 @@ - (CGImageRef)createShinyMask:(CGRect)rect origin:(CGPoint)origin radius:(CGFloa
return CGBitmapContextCreateImage(_maskContext);
}
-- (void)updateShiny {
+- (void)updateSpotlight {
_spotlightPoint += 1.3/32;
if (_spotlightPoint > 2) {
_spotlightPoint = -0.5;
@@ -109,7 +109,7 @@ - (void)drawRect:(CGRect)rect {
y - ceil(self.font.capHeight/2));
CGFloat spotRadius = self.font.capHeight*2;
- CGImageRef mask = [self createShinyMask:rect origin:spotOrigin radius:spotRadius];
+ CGImageRef mask = [self createSpotlightMask:rect origin:spotOrigin radius:spotRadius];
CGContextClipToMask(context, rect, mask);
CGImageRelease(mask);
@@ -127,7 +127,7 @@ - (CGSize)sizeThatFits:(CGSize)size {
- (void)startAnimating {
if (!_timer) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1.0/32 target:self
- selector:@selector(updateShiny) userInfo:nil repeats:YES];
+ selector:@selector(updateSpotlight) userInfo:nil repeats:YES];
_spotlightPoint = -0.5;
[self createMask];
}
@@ -2,6 +2,9 @@
@interface NSArray (TTCategory)
+/**
+ * Calls performSelector on all objects in the array.
+ */
- (void)perform:(SEL)selector;
- (void)perform:(SEL)selector withObject:(id)p1;
- (void)perform:(SEL)selector withObject:(id)p1 withObject:(id)p2;
@@ -109,6 +109,8 @@
@end
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
@protocol TTScrollViewDelegate <NSObject>
/**
@@ -181,6 +183,8 @@
@end
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
@protocol TTScrollViewDataSource <NSObject>
/**
@@ -1,9 +1,9 @@
-#import "Three20/TTGlobal.h"
+#import "Three20/TTBackgroundView.h"
@protocol TTTableViewDataSource, TTSearchTextFieldDelegate;
-@class TTSearchTextField, TTBackgroundView;
+@class TTSearchTextField;
-@interface TTSearchBar : UIView {
+@interface TTSearchBar : TTBackgroundView {
TTSearchTextField* _searchField;
TTBackgroundView* _boxView;
UIColor* _tintColor;
@@ -38,6 +38,8 @@
@end
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
@protocol TTSearchTextFieldDelegate <UITextFieldDelegate>
- (void)textField:(TTSearchTextField*)textField didSelectObject:(id)object;
View
@@ -108,7 +108,7 @@
- (void)storeData:(NSData*)data forKey:(NSString*)key;
/**
- * Stores an image the memory cache.
+ * Stores an image in the memory cache.
*/
- (void)storeImage:(UIImage*)image forURL:(NSString*)url;
- (void)storeImage:(UIImage*)image forKey:(NSString*)key;
@@ -17,8 +17,8 @@
* Gets the flag that determines if new load requests are allowed to reach the network.
*
* Because network requests tend to slow down performance, this property can be used to
- * temporary delay them. All requests made while suspended is true are queued, and when suspended
- * becomes false again they are executed.
+ * temporarily delay them. All requests made while suspended are queued, and when
+ * suspended becomes false again they are executed.
*/
@property(nonatomic) BOOL suspended;
@@ -10,7 +10,7 @@
* If the data is not valid, return an error. The data will not be cached if there is an error.
*/
- (NSError*)request:(TTURLRequest*)request processResponse:(NSHTTPURLResponse*)response
- data:(NSData*)data;
+ data:(NSData*)data;
@end
@@ -5,8 +5,14 @@
- (UIColor*)transformHue:(CGFloat)hd saturation:(CGFloat)sd value:(CGFloat)vd;
+/**
+ * Uses transformHue to create a lighter version of the color.
+ */
- (UIColor*)highlight;
+/**
+ * Uses transformHue to create a darker version of the color.
+ */
- (UIColor*)shadow;
@end
@@ -29,7 +29,7 @@
- (UIView*)findChildWithDescendant:(UIView*)descendant;
/**
- *
+ * Removes all subviews.
*/
- (void)removeSubviews;
@@ -39,9 +39,15 @@
@interface UINavigationController (TTCategory)
+/**
+ * Pushes a view controller with a transition other than the standard sliding animation.
+ */
- (void)pushViewController:(UIViewController*)controller
- withTransition:(UIViewAnimationTransition)transition;
+ withTransition:(UIViewAnimationTransition)transition;
+/**
+ * Pops a view controller with a transition other than the standard sliding animation.
+ */
- (void)popViewControllerWithTransition:(UIViewAnimationTransition)transition;
@end

0 comments on commit 7bab43f

Please sign in to comment.