diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 06d45eca3..57fb8a23b 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -605,7 +605,7 @@ var TIMER_INTERVAL = 0.2, #pragma mark - -#pragma mark Utilities +#pragma mark Privates /* @ignore */ - (void)_updateScrollerStyle @@ -621,6 +621,13 @@ var TIMER_INTERVAL = 0.2, [_verticalScroller unsetThemeState:CPThemeStateSelected]; } + if (_scrollerStyle == CPScrollerStyleOverlay) + { + if (_timerScrollersHide) + [_timerScrollersHide invalidate]; + _timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO]; + } + [self reflectScrolledClipView:_contentView]; } @@ -719,24 +726,30 @@ var TIMER_INTERVAL = 0.2, documentFrame = [[_contentView documentView] frame], contentBounds = [_contentView bounds]; + switch ([_verticalScroller hitPart]) { - case CPScrollerDecrementLine: contentBounds.origin.y -= _verticalLineScroll; - break; + case CPScrollerDecrementLine: + contentBounds.origin.y -= _verticalLineScroll; + break; - case CPScrollerIncrementLine: contentBounds.origin.y += _verticalLineScroll; - break; + case CPScrollerIncrementLine: + contentBounds.origin.y += _verticalLineScroll; + break; - case CPScrollerDecrementPage: contentBounds.origin.y -= _CGRectGetHeight(contentBounds) - _verticalPageScroll; - break; + case CPScrollerDecrementPage: + contentBounds.origin.y -= _CGRectGetHeight(contentBounds) - _verticalPageScroll; + break; - case CPScrollerIncrementPage: contentBounds.origin.y += _CGRectGetHeight(contentBounds) - _verticalPageScroll; - break; + case CPScrollerIncrementPage: + contentBounds.origin.y += _CGRectGetHeight(contentBounds) - _verticalPageScroll; + break; + // We want integral bounds! case CPScrollerKnobSlot: case CPScrollerKnob: - // We want integral bounds! - default: contentBounds.origin.y = ROUND(value * (_CGRectGetHeight(documentFrame) - _CGRectGetHeight(contentBounds))); + default: + contentBounds.origin.y = ROUND(value * (_CGRectGetHeight(documentFrame) - _CGRectGetHeight(contentBounds))); } [self _sendDelegateMessages]; @@ -753,22 +766,27 @@ var TIMER_INTERVAL = 0.2, switch ([_horizontalScroller hitPart]) { - case CPScrollerDecrementLine: contentBounds.origin.x -= _horizontalLineScroll; - break; + case CPScrollerDecrementLine: + contentBounds.origin.x -= _horizontalLineScroll; + break; - case CPScrollerIncrementLine: contentBounds.origin.x += _horizontalLineScroll; - break; + case CPScrollerIncrementLine: + contentBounds.origin.x += _horizontalLineScroll; + break; - case CPScrollerDecrementPage: contentBounds.origin.x -= _CGRectGetWidth(contentBounds) - _horizontalPageScroll; - break; + case CPScrollerDecrementPage: + contentBounds.origin.x -= _CGRectGetWidth(contentBounds) - _horizontalPageScroll; + break; - case CPScrollerIncrementPage: contentBounds.origin.x += _CGRectGetWidth(contentBounds) - _horizontalPageScroll; - break; + case CPScrollerIncrementPage: + contentBounds.origin.x += _CGRectGetWidth(contentBounds) - _horizontalPageScroll; + break; + // We want integral bounds! case CPScrollerKnobSlot: case CPScrollerKnob: - // We want integral bounds! - default: contentBounds.origin.x = ROUND(value * (_CGRectGetWidth(documentFrame) - _CGRectGetWidth(contentBounds))); + default: + contentBounds.origin.x = ROUND(value * (_CGRectGetWidth(documentFrame) - _CGRectGetWidth(contentBounds))); } [self _sendDelegateMessages]; @@ -844,6 +862,10 @@ var TIMER_INTERVAL = 0.2, [_delegate scrollViewDidScroll:self]; } + +#pragma mark - +#pragma mark Utilities + /*! Lays out the scroll view's components. */ @@ -925,7 +947,7 @@ var TIMER_INTERVAL = 0.2, [_horizontalScroller setHidden:!shouldShowHorizontalScroller]; [_horizontalScroller setEnabled:hasHorizontalScroll]; - var overlay = 0; + var overlay = [CPScroller scrollerOverlay]; if (_scrollerStyle === CPScrollerStyleLegacy) { // We can thus appropriately account for them changing the content size. @@ -934,10 +956,7 @@ var TIMER_INTERVAL = 0.2, if (shouldShowHorizontalScroller) contentFrame.size.height -= horizontalScrollerHeight; - } - else - { - overlay = [CPScroller scrollerOffset]; + overlay = 0; } var scrollPoint = [_contentView bounds].origin, @@ -1002,9 +1021,7 @@ var TIMER_INTERVAL = 0.2, _timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO]; } -/* - @ignore -*/ +/* @ignore */ - (void)resizeSubviewsWithOldSize:(CGSize)aSize { [self reflectScrolledClipView:_contentView]; diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index eb114121b..797883c56 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -83,6 +83,10 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); int _style; } + +#pragma mark - +#pragma mark Class methods + + (CPString)defaultThemeClass { return "scroller"; @@ -105,8 +109,44 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); }] } ++ (float)scrollerWidth +{ + return [CPScroller scrollerWidthInStyle:CPScrollerStyleLegacy]; +} -// Calculating Layout +/*! + Returns the CPScroller's width for a CPRegularControlSize. +*/ ++ (float)scrollerWidthInStyle:(int)aStyle +{ + var scroller = [[CPScroller alloc] init]; + + if (aStyle == CPScrollerStyleLegacy) + return [scroller valueForThemeAttribute:@"scroller-width" inState:CPThemeStateScrollViewLegacy]; + return [scroller currentValueForThemeAttribute:@"scroller-width"]; +} + +/*! + Returns the CPScroller's overlay value. +*/ ++ (float)scrollerOverlay +{ + return [[[CPScroller alloc] init] currentValueForThemeAttribute:@"track-border-overlay"]; +} + +/*! + Returns the width of a CPScroller for the specified CPControlSize. + @param aControlSize the size of a controller to return the width for +*/ ++ (float)scrollerWidthForControlSize:(CPControlSize)aControlSize +{ + // ?? a class method using self? + return nil//[self scrollerWidth]; +} + + +#pragma mark - +#pragma mark Initialization - (id)initWithFrame:(CGRect)aFrame { @@ -136,20 +176,22 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); return self; } -- (void)_adjustScrollerSize + +#pragma mark - +#pragma mark Getters / Setters + +/*! + Returns the scroller's style +*/ +- (void)style { - var frame = [self frame], - scrollerWidth = [self currentValueForThemeAttribute:@"scroller-width"]; - - if ([self isVertical] && CGRectGetWidth(frame) !== scrollerWidth) - frame.size.width = scrollerWidth; - - if (![self isVertical] && CGRectGetHeight(frame) !== scrollerWidth) - frame.size.height = scrollerWidth; - - [self setFrame:frame]; + return _style } +/*! + Set the scroller's control size + @param aStyle the scroller style: CPScrollerStyleLegacy or CPScrollerStyleOverlay +*/ - (void)setStyle:(id)aStyle { if (_style != nil && _style === aStyle) @@ -171,41 +213,17 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); [self _adjustScrollerSize]; } -// Determining CPScroller Size - -+ (float)scrollerWidth +- (void)setObjectValue:(id)aValue { - return [CPScroller scrollerWidthInStyle:CPScrollerStyleLegacy]; + [super setObjectValue:MIN(1.0, MAX(0.0, +aValue))]; } /*! - Returns the CPScroller's width for a CPRegularControlSize. + Returns the scroller's control size */ -+ (float)scrollerWidthInStyle:(int)aStyle +- (CPControlSize)controlSize { - var scroller = [[CPScroller alloc] init]; - - if (aStyle == CPScrollerStyleLegacy) - return [scroller valueForThemeAttribute:@"scroller-width" inState:CPThemeStateScrollViewLegacy]; - return [scroller currentValueForThemeAttribute:@"scroller-width"]; -} - -/*! - Returns the CPScroller's offset. -*/ -+ (float)scrollerOffset -{ - return [[[CPScroller alloc] init] currentValueForThemeAttribute:@"track-border-overlay"]; -} - -/*! - Returns the width of a CPScroller for the specified CPControlSize. - @param aControlSize the size of a controller to return the width for -*/ -+ (float)scrollerWidthForControlSize:(CPControlSize)aControlSize -{ - // ?? a class method using self? - return nil//[self scrollerWidth]; + return _controlSize; } /*! @@ -224,18 +242,17 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); } /*! - Returns the scroller's control size + Return's the knob's proportion */ -- (CPControlSize)controlSize +- (float)knobProportion { - return _controlSize; -} - -- (void)setObjectValue:(id)aValue -{ - [super setObjectValue:MIN(1.0, MAX(0.0, +aValue))]; + return _knobProportion; } +/*! + Set the knob's proportion + @param aProportion the desired proportion +*/ - (void)setKnobProportion:(float)aProportion { _knobProportion = MIN(1.0, MAX(0.0001, aProportion)); @@ -244,25 +261,28 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); [self setNeedsLayout]; } -/*! - Return's the knob's proportion -*/ -- (float)knobProportion + +#pragma mark - +#pragma mark Privates + +/*! @ignore */ +- (void)_adjustScrollerSize { - return _knobProportion; + var frame = [self frame], + scrollerWidth = [self currentValueForThemeAttribute:@"scroller-width"]; + + if ([self isVertical] && CGRectGetWidth(frame) !== scrollerWidth) + frame.size.width = scrollerWidth; + + if (![self isVertical] && CGRectGetHeight(frame) !== scrollerWidth) + frame.size.height = scrollerWidth; + + [self setFrame:frame]; } -- (id)currentValueForThemeAttribute:(CPString)anAttributeName -{ - var themeState = _themeState; - if (NAMES_FOR_PARTS[_hitPart] + "-color" !== anAttributeName) - themeState &= ~CPThemeStateHighlighted; - - return [self valueForThemeAttribute:anAttributeName inState:themeState]; -} - -// Calculating Layout +#pragma mark - +#pragma mark Utilities - (CGRect)rectForPart:(CPScrollerPart)aPart { @@ -406,7 +426,29 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); return _usableParts; } -// Drawing the Parts +/*! + Display the scroller +*/ +- (void)fadeIn +{ + [self setAlphaValue:1.0]; +} + +/*! + Start the fade out anination +*/ +- (void)fadeOut +{ + if ([self hasThemeState:CPThemeStateScrollViewLegacy]) + return; + + [_animationScroller startAnimation]; +} + + +#pragma mark - +#pragma mark Drawing + /*! Draws the specified arrow and sets the highlight. @param anArrow the arrow to draw @@ -641,6 +683,20 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); [self setNeedsLayout]; } + +#pragma mark - +#pragma mark Overrides + +- (id)currentValueForThemeAttribute:(CPString)anAttributeName +{ + var themeState = _themeState; + + if (NAMES_FOR_PARTS[_hitPart] + "-color" !== anAttributeName) + themeState &= ~CPThemeStateHighlighted; + + return [self valueForThemeAttribute:anAttributeName inState:themeState]; +} + - (void)mouseDown:(CPEvent)anEvent { if (![self isEnabled]) @@ -672,18 +728,9 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy"); [self fadeOut]; } -- (void)fadeIn -{ - [self setAlphaValue:1.0]; -} -- (void)fadeOut -{ - if ([self hasThemeState:CPThemeStateScrollViewLegacy]) - return; - - [_animationScroller startAnimation]; -} +#pragma mark - +#pragma mark Delegates - (void)animationDidEnd:(CPAnimation)animation { diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png index 025c57615..de67709ae 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png index 858ac4d42..2cd8ec9a5 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png index 6c5361615..d1ad107dc 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-knob-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-center.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-center.png index 3c645b28e..7b9720ec8 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-center.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-left.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-left.png index c8b6c441e..c659f3e55 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-left.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-right.png b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-right.png index 1a2fce89b..18849cea2 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-right.png and b/AppKit/Themes/Aristo/Resources/scroller-horizontal-track-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-center.png index 1dc443e42..b2112661b 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-center.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-left.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-left.png index 047e47c96..7c3245347 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-left.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-right.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-right.png index 3e5c377b9..750fa003f 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-right.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-knob-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-center.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-center.png index b83295f89..cd48f0513 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-center.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-left.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-left.png index 050e7206b..b2f76be02 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-left.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-left.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-right.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-right.png index bb3667ac4..7c338ed9e 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-right.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-horizontal-track-right.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-bottom.png index 1715d2dcf..0d925df81 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-bottom.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-center.png index 5bf039569..8e9272da9 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-center.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-top.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-top.png index f7947c66e..d34e638b8 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-top.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-knob-top.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-bottom.png index 61d1eb3e4..7f53deda9 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-bottom.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-center.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-center.png index 6ca2c3230..0f708cd9b 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-center.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-top.png b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-top.png index 0159341c3..af2421264 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-top.png and b/AppKit/Themes/Aristo/Resources/scroller-legacy-vertical-track-top.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png index c2b5d135e..6bb0e9a69 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png index 6a0ad4ffe..2a876c1b7 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-bottom.png deleted file mode 100644 index 1cb147b84..000000000 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-bottom.png and /dev/null differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-center.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-center.png deleted file mode 100644 index 2756a41ca..000000000 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-center.png and /dev/null differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-top.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-top.png deleted file mode 100644 index 6ca32cb88..000000000 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-disabled-top.png and /dev/null differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png index 557f4dc4c..63fd8b210 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-knob-top.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-bottom.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-bottom.png index 811b31415..0fb67ce54 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-bottom.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-bottom.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-center.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-center.png index dd5bf39c4..b5de80412 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-center.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-center.png differ diff --git a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-top.png b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-top.png index f0534175f..7ffd824d2 100644 Binary files a/AppKit/Themes/Aristo/Resources/scroller-vertical-track-top.png and b/AppKit/Themes/Aristo/Resources/scroller-vertical-track-top.png differ