mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-13 14:11:27 +00:00
Major CPScroller nib2cib fixes.
Reviewed by me.
This commit is contained in:
@@ -65,9 +65,6 @@
|
||||
|
||||
if (_documentView)
|
||||
{
|
||||
// FIXME: remove when bounds.
|
||||
[_documentView setFrameOrigin:CGPointMake(0.0, 0.0)];
|
||||
|
||||
[self addSubview:_documentView];
|
||||
|
||||
[_documentView setPostsFrameChangedNotifications:YES];
|
||||
@@ -187,9 +184,7 @@ var CPClipViewDocumentViewKey = @"CPScrollViewDocumentView";
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
[self setDocumentView:[aCoder decodeObjectForKey:CPClipViewDocumentViewKey]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
*/
|
||||
- (void)reflectScrolledClipView:(CPClipView)aClipView
|
||||
{
|
||||
if(_contentView != aClipView)
|
||||
if(_contentView !== aClipView)
|
||||
return;
|
||||
|
||||
if (_recursionCount > 5)
|
||||
@@ -240,7 +240,7 @@
|
||||
*/
|
||||
- (void)setHorizontalScroller:(CPScroller)aScroller
|
||||
{
|
||||
if (_horizontalScroller == aScroller)
|
||||
if (_horizontalScroller === aScroller)
|
||||
return;
|
||||
|
||||
[_horizontalScroller removeFromSuperview];
|
||||
@@ -272,7 +272,7 @@
|
||||
*/
|
||||
- (void)setHasHorizontalScroller:(BOOL)shouldHaveHorizontalScroller
|
||||
{
|
||||
if (_hasHorizontalScroller == shouldHaveHorizontalScroller)
|
||||
if (_hasHorizontalScroller === shouldHaveHorizontalScroller)
|
||||
return;
|
||||
|
||||
_hasHorizontalScroller = shouldHaveHorizontalScroller;
|
||||
@@ -302,7 +302,7 @@
|
||||
*/
|
||||
- (void)setVerticalScroller:(CPScroller)aScroller
|
||||
{
|
||||
if (_verticalScroller == aScroller)
|
||||
if (_verticalScroller === aScroller)
|
||||
return;
|
||||
|
||||
[_verticalScroller removeFromSuperview];
|
||||
@@ -335,7 +335,7 @@
|
||||
*/
|
||||
- (void)setHasVerticalScroller:(BOOL)shouldHaveVerticalScroller
|
||||
{
|
||||
if (_hasVerticalScroller == shouldHaveVerticalScroller)
|
||||
if (_hasVerticalScroller === shouldHaveVerticalScroller)
|
||||
return;
|
||||
|
||||
_hasVerticalScroller = shouldHaveVerticalScroller;
|
||||
|
||||
+13
-100
@@ -67,10 +67,6 @@ var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScroller
|
||||
|
||||
CPView _decrementArrowView;
|
||||
CPView _incrementArrowView;
|
||||
|
||||
JSObject _layoutViews;
|
||||
|
||||
CPThemedValue _scrollerWidth;
|
||||
}
|
||||
|
||||
+ (id)themedAttributes
|
||||
@@ -101,7 +97,7 @@ var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScroller
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{_layoutViews = {}
|
||||
{
|
||||
_controlSize = CPRegularControlSize;
|
||||
_partRects = [];
|
||||
|
||||
@@ -414,31 +410,18 @@ var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScroller
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CPView)layoutSubviewNamed:(CPString)aViewName positioned:(CPWindowOrderingMode)anOrderingMode relativeToSubviewNamed:(CPString)relativeToViewName
|
||||
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
|
||||
{
|
||||
var frame = [self rectForPart:aViewName];
|
||||
return _partRects[aName];
|
||||
}
|
||||
|
||||
if (frame && !_CGRectIsEmpty(frame))
|
||||
{
|
||||
if (!_layoutViews[aViewName])
|
||||
{
|
||||
_layoutViews[aViewName] = [self createViewForPart:aViewName];
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aName
|
||||
{
|
||||
var view = [[CPView alloc] initWithFrame:_CGRectMakeZero()];
|
||||
|
||||
[view setHitTests:NO];
|
||||
|
||||
if (_layoutViews[aViewName])
|
||||
[self addSubview:_layoutViews[aViewName] positioned:anOrderingMode relativeTo:_layoutViews[relativeToViewName]];
|
||||
}
|
||||
|
||||
if (_layoutViews[aViewName])
|
||||
[_layoutViews[aViewName] setFrame:frame];
|
||||
}
|
||||
else if (_layoutViews[aViewName])
|
||||
{
|
||||
[_layoutViews[aViewName] removeFromSuperview];
|
||||
|
||||
delete _layoutViews[aViewName];
|
||||
}
|
||||
|
||||
return _layoutViews[aViewName];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
@@ -454,9 +437,9 @@ var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScroller
|
||||
var part = PARTS_ARRANGEMENT[index];
|
||||
|
||||
if (index === 0)
|
||||
view = [self layoutSubviewNamed:part positioned:CPWindowBelow relativeToSubviewNamed:PARTS_ARRANGEMENT[index + 1]];
|
||||
view = [self layoutEphemeralSubviewNamed:part positioned:CPWindowBelow relativeToEphemeralSubviewNamed:PARTS_ARRANGEMENT[index + 1]];
|
||||
else
|
||||
view = [self layoutSubviewNamed:part positioned:CPWindowAbove relativeToSubviewNamed:PARTS_ARRANGEMENT[index - 1]];
|
||||
view = [self layoutEphemeralSubviewNamed:part positioned:CPWindowAbove relativeToEphemeralSubviewNamed:PARTS_ARRANGEMENT[index - 1]];
|
||||
|
||||
if (view)
|
||||
[view setBackgroundColor:objj_msgSend(self, selector, part)];
|
||||
@@ -635,75 +618,7 @@ var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScroller
|
||||
}
|
||||
|
||||
@end
|
||||
/*
|
||||
@implementation CPScroller (Theming)
|
||||
|
||||
- (void)viewDidChangeTheme
|
||||
{
|
||||
[super viewDidChangeTheme];
|
||||
|
||||
var theme = [self theme];
|
||||
|
||||
[_trackOverlapInset setTheme:theme];
|
||||
|
||||
[_verticalMinimumKnobSize setTheme:theme];
|
||||
[_verticalDecrementLineSize setTheme:theme];
|
||||
[_verticalIncrementLineSize setTheme:theme];
|
||||
|
||||
[_horizontalMinimumKnobSize setTheme:theme];
|
||||
[_horizontalDecrementLineSize setTheme:theme];
|
||||
[_horizontalIncrementLineSize setTheme:theme];
|
||||
|
||||
var index = 0,
|
||||
count = PARTS_ARRANGEMENT.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var part = PARTS_ARRANGEMENT[index];
|
||||
|
||||
[_horizontalPartColors[part] setTheme:theme];
|
||||
[_verticalPartColors[part] setTheme:theme];
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (CPDictionary)themedValues
|
||||
{
|
||||
var values = [super themedValues],
|
||||
isVertical = [self isVertical];
|
||||
|
||||
[values setObject:_trackOverlapInset forKey:"track-overlap-inset"];
|
||||
|
||||
if (isVertical)
|
||||
{
|
||||
[values setObject:_verticalMinimumKnobSize forKey:"vertical-minimum-knob-size"];
|
||||
[values setObject:_verticalDecrementLineSize forKey:"vertical-decrement-line-size"];
|
||||
[values setObject:_verticalIncrementLineSize forKey:"vertical-increment-line-size"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[values setObject:_horizontalMinimumKnobSize forKey:"horizontal-minimum-knob-size"];
|
||||
[values setObject:_horizontalDecrementLineSize forKey:"horizontal-decrement-line-size"];
|
||||
[values setObject:_horizontalIncrementLineSize forKey:"horizontal-increment-line-size"];
|
||||
}
|
||||
|
||||
var index = 0,
|
||||
count = PARTS_ARRANGEMENT.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var part = PARTS_ARRANGEMENT[index];
|
||||
|
||||
[values setObject:(isVertical ? _verticalPartColors : _horizontalPartColors)[part] forKey:(isVertical ? "vertical-" : "horizontal-") + part + "-color"];
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
@end
|
||||
*/
|
||||
var CPScrollerControlSizeKey = "CPScrollerControlSize",
|
||||
CPScrollerKnobProportionKey = "CPScrollerKnobProportion";
|
||||
|
||||
@@ -712,7 +627,7 @@ var CPScrollerControlSizeKey = "CPScrollerControlSize",
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{_layoutViews = {};
|
||||
{
|
||||
_controlSize = CPRegularControlSize;
|
||||
if ([aCoder containsValueForKey:CPScrollerControlSizeKey])
|
||||
_controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey];
|
||||
@@ -722,8 +637,6 @@ var CPScrollerControlSizeKey = "CPScrollerControlSize",
|
||||
_knobProportion = [aCoder decodeFloatForKey:CPScrollerKnobProportionKey];
|
||||
|
||||
_partRects = [];
|
||||
_verticalPartColors = [];
|
||||
_horizontalPartColors = [];
|
||||
|
||||
_hitPart = CPScrollerNoPart;
|
||||
|
||||
|
||||
@@ -45,11 +45,21 @@
|
||||
if ([aCoder containsValueForKey:"NSCurValue"])
|
||||
_value = [aCoder decodeFloatForKey:"NSCurValue"];
|
||||
|
||||
var isVertical = [self isVertical];
|
||||
|
||||
if (CPStringFromSelector([self action]) === @"_doScroller:")
|
||||
if ([self isVertical])
|
||||
[self setAction:@selector(_verticalScrollerDidScroll)];
|
||||
if (isVertical)
|
||||
[self setAction:@selector(_verticalScrollerDidScroll:)];
|
||||
else
|
||||
[self setAction:@selector(_horizontalScrollerDidScroll)];
|
||||
[self setAction:@selector(_horizontalScrollerDidScroll:)];
|
||||
|
||||
_partRects = [];
|
||||
|
||||
// FIXME:SIZE
|
||||
if (isVertical)
|
||||
[self setFrameSize:CGSizeMake(17.0, CGRectGetHeight([self frame]))];
|
||||
else
|
||||
[self setFrameSize:CGSizeMake(CGRectGetWidth([self frame]), 17.0)];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user