Permalink
Browse files

* Merging a bunch of changes from dougbarth. Thanks, Doug!

  • Loading branch information...
1 parent 6724100 commit 85caca23093d781fe1badb46b6eaa90398d4a389 @joehewitt joehewitt committed Apr 18, 2009
View
@@ -0,0 +1,6 @@
+.DS_Store
+build
+*.pbxuser
+*.perspectivev3
+*.modelv3
+.DS_Store
View
@@ -107,6 +107,7 @@ - (void)imageViewDidLoadImage:(UIImage*)image {
if (!_photo.size.width) {
_photo.size = image.size;
+ [self.superview setNeedsLayout];
}
}
@@ -5,13 +5,14 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
static CGFloat kSpacing = 4;
-static CGFloat kThumbSize = 75;
+static CGFloat kDefaultThumbSize = 75;
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation TTThumbsTableViewCell
-@synthesize delegate = _delegate, photo = _photo;
+@synthesize delegate = _delegate, photo = _photo, thumbSize = _thumbSize,
+ thumbOrigin = _thumbOrigin;
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
@@ -43,33 +44,47 @@ - (void)thumbTouched:(TTThumbView*)thumbView {
[_delegate thumbsTableViewCell:self didSelectPhoto:photo];
}
+- (void)layoutThumbViews {
+ CGRect thumbFrame = CGRectMake(self.thumbOrigin.x, self.thumbOrigin.y,
+ self.thumbSize, self.thumbSize);
+ _thumbView1.frame = thumbFrame;
+
+ thumbFrame.origin.x = self.thumbOrigin.x + kSpacing + self.thumbSize;
+ _thumbView2.frame = thumbFrame;
+
+ thumbFrame.origin.x = self.thumbOrigin.x + 2*kSpacing + 2*self.thumbSize;
+ _thumbView3.frame = thumbFrame;
+
+ thumbFrame.origin.x = self.thumbOrigin.x + 3*kSpacing + 3*self.thumbSize;
+ _thumbView4.frame = thumbFrame;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)identifier {
if (self = [super initWithFrame:frame reuseIdentifier:identifier]) {
_photo = nil;
_delegate = nil;
- _thumbView1 = [[TTThumbView alloc]
- initWithFrame:CGRectMake(kSpacing, 0, kThumbSize, kThumbSize)];
+ _thumbSize = kDefaultThumbSize;
+ _thumbOrigin = CGPointMake(kSpacing, 0);
+
+ _thumbView1 = [[TTThumbView alloc] initWithFrame:CGRectZero];
[_thumbView1 addTarget:self action:@selector(thumbTouched:)
forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_thumbView1];
- _thumbView2 = [[TTThumbView alloc]
- initWithFrame:CGRectMake(kSpacing*2+kThumbSize, 0, kThumbSize, kThumbSize)];
+ _thumbView2 = [[TTThumbView alloc] initWithFrame:CGRectZero];
[_thumbView2 addTarget:self action:@selector(thumbTouched:)
forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_thumbView2];
- _thumbView3 = [[TTThumbView alloc]
- initWithFrame:CGRectMake(kSpacing*3+kThumbSize*2, 0, kThumbSize, kThumbSize)];
+ _thumbView3 = [[TTThumbView alloc] initWithFrame:CGRectZero];
[_thumbView3 addTarget:self action:@selector(thumbTouched:)
forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_thumbView3];
- _thumbView4 = [[TTThumbView alloc]
- initWithFrame:CGRectMake(kSpacing*4+kThumbSize*3, 0, kThumbSize, kThumbSize)];
+ _thumbView4 = [[TTThumbView alloc] initWithFrame:CGRectZero];
[_thumbView4 addTarget:self action:@selector(thumbTouched:)
forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_thumbView4];
@@ -89,6 +104,14 @@ - (void)dealloc {
[super dealloc];
}
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// UIView
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ [self layoutThumbViews];
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// TTTableViewCell
@@ -103,6 +126,16 @@ - (void)setObject:(id)object {
///////////////////////////////////////////////////////////////////////////////////////////////////
// public
+- (void)setThumbSize:(CGFloat)thumbSize {
+ _thumbSize = thumbSize;
+ [self setNeedsLayout];
+}
+
+- (void)setThumbOrigin:(CGPoint)thumbOrigin {
+ _thumbOrigin = thumbOrigin;
+ [self setNeedsLayout];
+}
+
- (void)setPhoto:(id<TTPhoto>)photo {
if (_photo != photo) {
[_photo release];
@@ -1,6 +1,5 @@
#import "Three20/TTThumbsViewController.h"
#import "Three20/TTPhotoViewController.h"
-#import "Three20/TTPhotoSource.h"
#import "Three20/TTURLRequest.h"
#import "Three20/TTUnclippedView.h"
#import "Three20/TTTableField.h"
@@ -15,15 +14,6 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-@interface TTThumbsDataSource : TTDataSource
- <TTPhotoSourceDelegate, TTThumbsTableViewCellDelegate> {
- TTThumbsViewController* _controller;
-}
-
-- (id)initWithController:(TTThumbsViewController*)controller;
-
-@end
-
@implementation TTThumbsDataSource
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -10,10 +10,14 @@
TTThumbView* _thumbView2;
TTThumbView* _thumbView3;
TTThumbView* _thumbView4;
+ CGFloat _thumbSize;
+ CGPoint _thumbOrigin;
}
@property(nonatomic,retain) id<TTPhoto> photo;
@property(nonatomic,assign) id<TTThumbsTableViewCellDelegate> delegate;
+@property(nonatomic) CGFloat thumbSize;
+@property(nonatomic) CGPoint thumbOrigin;
- (void)suspendLoading:(BOOL)suspended;
@@ -1,5 +1,6 @@
#import "Three20/TTTableViewController.h"
#import "Three20/TTThumbsTableViewCell.h"
+#import "Three20/TTPhotoSource.h"
@protocol TTThumbsViewControllerDelegate, TTPhotoSource;
@class TTPhotoViewController;
@@ -16,6 +17,19 @@
@end
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@interface TTThumbsDataSource : TTDataSource
+ <TTPhotoSourceDelegate, TTThumbsTableViewCellDelegate> {
+ TTThumbsViewController* _controller;
+}
+
+- (id)initWithController:(TTThumbsViewController*)controller;
+
+@end
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
@protocol TTThumbsViewControllerDelegate <NSObject>
- (void)thumbsViewController:(TTThumbsViewController*)controller didSelectPhoto:(id<TTPhoto>)photo;

0 comments on commit 85caca2

Please sign in to comment.