Skip to content

Commit

Permalink
Fix for scrollers not updating properly.
Browse files Browse the repository at this point in the history
[cappuccino#35 state:resolved]

Reviewed by ross.
  • Loading branch information
Francisco Ryan Tolmasky I committed Oct 4, 2008
1 parent 9da107f commit ac4faf3
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions AppKit/CPScrollView.j
Expand Up @@ -235,7 +235,7 @@ import "CPScroller.j"
var value = [_verticalScroller floatValue],
contentBounds = [_contentView bounds];

contentBounds.origin.y = value * (_CGRectGetHeight([[_contentView documentView] frame]) - _CGRectGetHeight(contentBounds));
contentBounds.origin.y = value * (_CGRectGetHeight([documentView frame]) - _CGRectGetHeight(contentBounds));

[_contentView scrollToPoint:contentBounds.origin];
}
Expand All @@ -246,7 +246,7 @@ import "CPScroller.j"
var value = [_horizontalScroller floatValue],
contentBounds = [_contentView bounds];

contentBounds.origin.x = value * (_CGRectGetWidth([[_contentView documentView] frame]) - _CGRectGetWidth(contentBounds));
contentBounds.origin.x = value * (_CGRectGetWidth([documentView frame]) - _CGRectGetWidth(contentBounds));

[_contentView scrollToPoint:contentBounds.origin];
}
Expand All @@ -272,7 +272,10 @@ import "CPScroller.j"

[_horizontalScroller setTarget:self];
[_horizontalScroller setAction:@selector(_horizontalScrollerDidScroll:)];

[self addSubview:_horizontalScroller];

[self reflectScrolledClipView:_contentView];
}

/*
Expand All @@ -288,14 +291,22 @@ import "CPScroller.j"
@param hasHorizontalScroller <code>YES</code> lets the scroll view
allocate a horizontal scroller if necessary.
*/
- (void)setHasHorizontalScroller:(BOOL)hasHorizontalScroller
- (void)setHasHorizontalScroller:(BOOL)shouldHaveHorizontalScroller
{
_hasHorizontalScroller = hasHorizontalScroller;
if (_hasHorizontalScroller == shouldHaveHorizontalScroller)
return;

_hasHorizontalScroller = shouldHaveHorizontalScroller;

if (_hasHorizontalScroller && !_horizontalScroller)
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CPRectMake(0.0, 0.0, CPRectGetWidth([self bounds]), [CPScroller scrollerWidth])]];
else if (!hasHorizontalScroller && _horizontalScroller)

else if (!_hasHorizontalScroller && _horizontalScroller)
{
[_horizontalScroller setHidden:YES];

[self reflectScrolledClipView:_contentView];
}
}

/*
Expand Down Expand Up @@ -324,7 +335,10 @@ import "CPScroller.j"

[_verticalScroller setTarget:self];
[_verticalScroller setAction:@selector(_verticalScrollerDidScroll:)];

[self addSubview:_verticalScroller];

[self reflectScrolledClipView:_contentView];
}

/*
Expand All @@ -341,14 +355,22 @@ import "CPScroller.j"
@param hasVerticalScroller <code>YES</code> allows
the scroll view to display a vertical scroller
*/
- (void)setHasVerticalScroller:(BOOL)hasVerticalScroller
- (void)setHasVerticalScroller:(BOOL)shouldHaveVerticalScroller
{
_hasVerticalScroller = hasVerticalScroller;

if (_hasVerticalScroller == shouldHaveVerticalScroller)
return;

_hasVerticalScroller = shouldHaveVerticalScroller;

if (_hasVerticalScroller && !_verticalScroller)
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:CPRectMake(0.0, 0.0, [CPScroller scrollerWidth], CPRectGetHeight([self bounds]))]];
else if (!hasVerticalScroller && _verticalScroller)

else if (!_hasVerticalScroller && _verticalScroller)
{
[_verticalScroller setHidden:YES];

[self reflectScrolledClipView:_contentView];
}
}

/*
Expand Down

0 comments on commit ac4faf3

Please sign in to comment.