Skip to content

Commit

Permalink
Hopefully finally fixed the problem with CPScrollView/CPScroller init…
Browse files Browse the repository at this point in the history
…ialization. Fixes cappuccino#1485.
  • Loading branch information
aparajita committed Apr 22, 2012
1 parent 48ef639 commit bd691d5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
11 changes: 3 additions & 8 deletions AppKit/CPScrollView.j
Original file line number Diff line number Diff line change
Expand Up @@ -1506,9 +1506,6 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
_scrollTimer = nil;
_implementedDelegateMethods = 0;

// Due to the anything goes nature of decoding, our subviews may not exist yet, so layout at the end of the run loop when we're sure everything is in a correct state.
[[CPRunLoop currentRunLoop] performSelector:@selector(_updateCornerAndHeaderView) target:self argument:_contentView order:0 modes:[CPDefaultRunLoopMode]];

_scrollerStyle = [aCoder decodeIntForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal;
_scrollerKnobStyle = [aCoder decodeIntForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault;

Expand All @@ -1522,14 +1519,12 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
}

/*!
@ignore
Make sure the scroller style is updated. This can only be done after awakening.
Do final init that can only be done when we are sure all subviews have been initialized.
*/
- (id)awakeAfterUsingCoder:(CPCoder)aCoder
- (void)awakeFromCib
{
[self _updateScrollerStyle];
return self;
[self _updateCornerAndHeaderView];
}

- (void)encodeWithCoder:(CPCoder)aCoder
Expand Down
9 changes: 7 additions & 2 deletions AppKit/CPScroller.j
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");

if (_timerFadeOut)
[_timerFadeOut invalidate];

_timerFadeOut = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_performFadeOut:) userInfo:nil repeats:NO];
}

Expand All @@ -796,10 +797,12 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",
if (self = [super initWithCoder:aCoder])
{
_controlSize = CPRegularControlSize;

if ([aCoder containsValueForKey:CPScrollerControlSizeKey])
_controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey];

_knobProportion = 1.0;

if ([aCoder containsValueForKey:CPScrollerKnobProportionKey])
_knobProportion = [aCoder decodeFloatForKey:CPScrollerKnobProportionKey];

Expand All @@ -809,8 +812,10 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",

_allowFadingOut = YES;
_isMouseOver = NO;
var paramAnimFadeOut = [CPDictionary dictionaryWithObjects:[self, CPViewAnimationFadeOutEffect]
forKeys:[CPViewAnimationTargetKey, CPViewAnimationEffectKey]];

var paramAnimFadeOut = [CPDictionary dictionaryWithObjects:[self, CPViewAnimationFadeOutEffect]
forKeys:[CPViewAnimationTargetKey, CPViewAnimationEffectKey]];

_animationScroller = [[CPViewAnimation alloc] initWithDuration:0.2 animationCurve:CPAnimationEaseInOut];
[_animationScroller setViewAnimations:[paramAnimFadeOut]];
[_animationScroller setDelegate:self];
Expand Down
3 changes: 3 additions & 0 deletions Tests/Manual/CPScrollView2/AppController.j
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@
case "Default":
[scrollView setScrollerKnobStyle:CPScrollerKnobStyleDefault];
break;

case "Dark":
[scrollView setScrollerKnobStyle:CPScrollerKnobStyleDark];
break;

case "Light":
[scrollView setScrollerKnobStyle:CPScrollerKnobStyleLight];
break;
Expand All @@ -69,6 +71,7 @@
case "Light":
[[scrollView documentView] setBackgroundColor:lightBackground];
break;

case "Dark":
[[scrollView documentView] setBackgroundColor:[CPColor colorWithHexString:@"333"]];
break;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/CPScrollView2/Resources/MainMenu.cib

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions Tests/Manual/CPScrollView2/Resources/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,6 @@
<string key="NSAction">_doScroller:</string>
<double key="NSCurValue">1</double>
<double key="NSPercent">0.96363627910614014</double>
<int key="NSKnobStyle">2</int>
</object>
<object class="NSScroller" id="196713696">
<reference key="NSNextResponder" ref="364286201"/>
Expand All @@ -1198,7 +1197,6 @@
<reference key="NSTarget" ref="364286201"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.50602412223815918</double>
<int key="NSKnobStyle">2</int>
</object>
</object>
<string key="NSFrame">{{20, 300}, {575, 261}}</string>
Expand All @@ -1210,7 +1208,6 @@
<reference key="NSVScroller" ref="961292000"/>
<reference key="NSHScroller" ref="196713696"/>
<reference key="NSContentView" ref="175384428"/>
<int key="NSScrollerKnobStyle">2</int>
</object>
<object class="NSScrollView" id="17976132">
<reference key="NSNextResponder" ref="439893737"/>
Expand Down

Large diffs are not rendered by default.

0 comments on commit bd691d5

Please sign in to comment.