Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Continue thrashing, trying to get the layout to work correctly.

  • Loading branch information...
commit 7f4bfc51e1aafb87becb9e124ab97d3ed57099e1 1 parent 59ae329
@hlship authored
View
10 src/main/webapp/app/TwitView.j
@@ -8,28 +8,26 @@
- (void) setRepresentedObject:(JSONObject)obj
{
- CPLog.debug("Adding status: " + obj.text);
-
if (!_label)
{
_label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_label setFont:[CPFont systemFontOfSize:12]];
[_label setTextColor:[CPColor whiteColor]];
+ [_label setAutoresizingMask:CPViewWidthSizable];
[self addSubview:_label];
}
[_label setStringValue:obj.text];
- [_label setFrameSize:CGSizeMake(600, 60)];
- [_label setFrameOrigin:CGPointMake(10, 0)];
+ [_label setFrameSize:CGSizeMake(200, 60)];
[_label setLineBreakMode:CPLineBreakByWordWrapping];
}
- (void)setSelected:(BOOL)isSelected
{
- var color = isSelected ? [CPColor blueColor] : nil;
-
+ var color = isSelected ? [CPColor blueColor] :nil;
+
[self setBackgroundColor:color];
}
View
47 src/main/webapp/app/TwitterController.j
@@ -9,6 +9,7 @@
{
CPPanel _panel;
CPTextField _field;
+ CPScollView _scrollView;
CPCollectionView _timelineView;
}
@@ -35,15 +36,14 @@
[_field setAction:@selector(startSearch:)];
[_field setAutoresizingMask:CPViewWidthSizable];
- var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(3, 40,
+ _scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(3, 40,
CGRectGetWidth([content bounds]) - 10,
CGRectGetHeight([content bounds]) - 50)];
- [scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
- [scrollView setAutohidesScrollers:YES];
- [scrollView setBackgroundColor:[CPColor greenColor]]; // TEMP
+ [_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
+ [_scrollView setAutohidesScrollers:YES];
- var scrollViewBounds = [[scrollView contentView] bounds];
+ var scrollViewBounds = [[_scrollView contentView] bounds];
var itemPrototype = [[CPCollectionViewItem alloc] init];
[itemPrototype setView:[[TwitView alloc] initWithFrame:CGRectMakeZero()]];
@@ -53,22 +53,40 @@
[_timelineView setItemPrototype:itemPrototype];
[_timelineView setDelegate:self];
[_timelineView setMaxNumberOfColumns:1];
-
- [_timelineView setBackgroundColor:[CPColor darkGrayColor]]; // TEMP
-
- [_timelineView setMinItemSize:CGSizeMake(100, 60)];
- [_timelineView setMaxItemSize:CGSizeMake(1000, 60)];
+
[_timelineView setAutoresizingMask:CPViewWidthSizable];
+
+ [_scrollView setDocumentView:_timelineView];
- [scrollView setDocumentView:_timelineView];
+ [[CPNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(scrollViewDidResize:)
+ name:CPViewFrameDidChangeNotification
+ object:_scrollView];
+
+ // Will fire an initial notification because the value changed.
+ [_scrollView setPostsFrameChangedNotifications:YES];
[content addSubview:label];
[content addSubview:_field];
- [content addSubview:scrollView];
+ [content addSubview:_scrollView];
+
return self;
}
+- (void)scrollViewDidResize:(id)notification
+{
+ var bounds = [_scrollView bounds];
+
+ CPLog.debug("new size: " + CPRectGetWidth(bounds) + " x " + CPRectGetHeight(bounds));
+
+ var newSize = CGSizeMake(CPRectGetWidth(bounds), 60);
+
+ [_timelineView setMinItemSize:newSize];
+ [_timelineView setMaxItemSize:newSize];
+}
+
- (void)show
{
[_panel orderFront:self];
@@ -99,4 +117,9 @@
CPLog.error(error);
}
+- (void)adjustTimelineSize
+{
+
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.