mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-22 14:35:52 +00:00
Cleaned up CPControl ephemeral views code and got rid of some dead code in cib logic.
Reviewed by me.
This commit is contained in:
1 parent
7e88b1abfd
commit
8b25240d04
3 files changed
+71
-86
No files matched your search
@@ -100,9 +100,6 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
BOOL _trackingWasWithinFrame;
|
||||
unsigned _trackingMouseDownFlags;
|
||||
CGPoint _previousTrackingLocation;
|
||||
|
||||
JSObject _ephemeralSubviewsForNames;
|
||||
CPSet _ephereralSubviews;
|
||||
|
||||
CPString _toolTip;
|
||||
}
|
||||
@@ -557,54 +554,6 @@ BRIDGE(ImageScaling, imageScaling, "image-scaling")
|
||||
return [self hasThemeState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aViewName
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aViewName
|
||||
{
|
||||
return _CGRectMakeZero();
|
||||
}
|
||||
|
||||
- (CPView)layoutEphemeralSubviewNamed:(CPString)aViewName
|
||||
positioned:(CPWindowOrderingMode)anOrderingMode
|
||||
relativeToEphemeralSubviewNamed:(CPString)relativeToViewName
|
||||
{
|
||||
if (!_ephemeralSubviewsForNames)
|
||||
{
|
||||
_ephemeralSubviewsForNames = {};
|
||||
_ephemeralSubviews = [CPSet set];
|
||||
}
|
||||
|
||||
var frame = [self rectForEphemeralSubviewNamed:aViewName];
|
||||
|
||||
if (frame && !_CGRectIsEmpty(frame))
|
||||
{
|
||||
if (!_ephemeralSubviewsForNames[aViewName])
|
||||
{
|
||||
_ephemeralSubviewsForNames[aViewName] = [self createEphemeralSubviewNamed:aViewName];
|
||||
|
||||
[_ephemeralSubviews addObject:_ephemeralSubviewsForNames[aViewName]];
|
||||
|
||||
if (_ephemeralSubviewsForNames[aViewName])
|
||||
[self addSubview:_ephemeralSubviewsForNames[aViewName] positioned:anOrderingMode relativeTo:_ephemeralSubviewsForNames[relativeToViewName]];
|
||||
}
|
||||
|
||||
if (_ephemeralSubviewsForNames[aViewName])
|
||||
[_ephemeralSubviewsForNames[aViewName] setFrame:frame];
|
||||
}
|
||||
else if (_ephemeralSubviewsForNames[aViewName])
|
||||
{
|
||||
[_ephemeralSubviewsForNames[aViewName] removeFromSuperview];
|
||||
|
||||
[_ephemeralSubviews removeObject:_ephemeralSubviewsForNames[aViewName]];
|
||||
delete _ephemeralSubviewsForNames[aViewName];
|
||||
}
|
||||
|
||||
return _ephemeralSubviewsForNames[aViewName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPControlValueKey = "CPControlValueKey",
|
||||
@@ -647,24 +596,8 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
|
||||
*/
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
var count = [_subviews count],
|
||||
ephemeral
|
||||
subviews = nil;
|
||||
|
||||
if (count > 0 && [_ephemeralSubviews count] > 0)
|
||||
{
|
||||
subviews = [_subviews.slice(0) copy];
|
||||
|
||||
while (count--)
|
||||
if ([_ephemeralSubviews containsObject:_subviews[count]])
|
||||
_subviews.splice(count, 1);
|
||||
}
|
||||
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
if (subviews)
|
||||
_subviews = subviews;
|
||||
|
||||
if (_value !== nil)
|
||||
[aCoder encodeObject:_value forKey:CPControlValueKey];
|
||||
|
||||
|
||||
+66
-2
@@ -178,6 +178,9 @@ var DOMElementPrototype = nil,
|
||||
JSObject _themeAttributes;
|
||||
unsigned _themeState;
|
||||
|
||||
JSObject _ephemeralSubviewsForNames;
|
||||
CPSet _ephereralSubviews;
|
||||
|
||||
// Key View Support
|
||||
CPView _nextKeyView;
|
||||
CPView _previousKeyView;
|
||||
@@ -2180,6 +2183,54 @@ setBoundsOrigin:
|
||||
return [_themeAttributes[aName] valueForState:_themeState];
|
||||
}
|
||||
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aViewName
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aViewName
|
||||
{
|
||||
return _CGRectMakeZero();
|
||||
}
|
||||
|
||||
- (CPView)layoutEphemeralSubviewNamed:(CPString)aViewName
|
||||
positioned:(CPWindowOrderingMode)anOrderingMode
|
||||
relativeToEphemeralSubviewNamed:(CPString)relativeToViewName
|
||||
{
|
||||
if (!_ephemeralSubviewsForNames)
|
||||
{
|
||||
_ephemeralSubviewsForNames = {};
|
||||
_ephemeralSubviews = [CPSet set];
|
||||
}
|
||||
|
||||
var frame = [self rectForEphemeralSubviewNamed:aViewName];
|
||||
|
||||
if (frame && !_CGRectIsEmpty(frame))
|
||||
{
|
||||
if (!_ephemeralSubviewsForNames[aViewName])
|
||||
{
|
||||
_ephemeralSubviewsForNames[aViewName] = [self createEphemeralSubviewNamed:aViewName];
|
||||
|
||||
[_ephemeralSubviews addObject:_ephemeralSubviewsForNames[aViewName]];
|
||||
|
||||
if (_ephemeralSubviewsForNames[aViewName])
|
||||
[self addSubview:_ephemeralSubviewsForNames[aViewName] positioned:anOrderingMode relativeTo:_ephemeralSubviewsForNames[relativeToViewName]];
|
||||
}
|
||||
|
||||
if (_ephemeralSubviewsForNames[aViewName])
|
||||
[_ephemeralSubviewsForNames[aViewName] setFrame:frame];
|
||||
}
|
||||
else if (_ephemeralSubviewsForNames[aViewName])
|
||||
{
|
||||
[_ephemeralSubviewsForNames[aViewName] removeFromSuperview];
|
||||
|
||||
[_ephemeralSubviews removeObject:_ephemeralSubviewsForNames[aViewName]];
|
||||
delete _ephemeralSubviewsForNames[aViewName];
|
||||
}
|
||||
|
||||
return _ephemeralSubviewsForNames[aViewName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
@@ -2286,6 +2337,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
}
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -2309,8 +2361,20 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
if (_window !== nil)
|
||||
[aCoder encodeConditionalObject:_window forKey:CPViewWindowKey];
|
||||
|
||||
if (_subviews.length > 0)
|
||||
[aCoder encodeObject:_subviews forKey:CPViewSubviewsKey];
|
||||
var count = [_subviews count],
|
||||
encodedSubviews = _subviews;
|
||||
|
||||
if (count > 0 && [_ephemeralSubviews count] > 0)
|
||||
{
|
||||
encodedSubviews = [encodedSubviews copy];
|
||||
|
||||
while (count--)
|
||||
if ([_ephemeralSubviews containsObject:encodedSubviews[count]])
|
||||
encodedSubviews.splice(count, 1);
|
||||
}
|
||||
|
||||
if (encodedSubviews.length > 0)
|
||||
[aCoder encodeObject:encodedSubviews forKey:CPViewSubviewsKey];
|
||||
|
||||
// This will come out nil on the other side with decodeObjectForKey:
|
||||
if (_superview !== nil)
|
||||
|
||||
@@ -47,29 +47,17 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
|
||||
if (self)
|
||||
_className = [aCoder decodeObjectForKey:_CPCibCustomViewClassNameKey];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
|
||||
[aCoder encodeObject:_className forKey:_CPCibCustomViewClassNameKey];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var bounds = [self bounds],
|
||||
context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextSetLineWidth(context, 1.0);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithCalibratedRed:169.0 / 255.0 green:173.0 / 255.0 blue:178.0 / 255.0 alpha:1.0]);
|
||||
CGContextStrokeRect(context, CGRectInset(CGRectIntegral(bounds), 0.5, 0.5));
|
||||
CGContextSetFillColor(context, [CPColor colorWithCalibratedRed:224.0 / 255.0 green:236.0 / 255.0 blue:250.0 / 255.0 alpha:1.0]);
|
||||
CGContextFillRect(context, CGRectInset(bounds, 2.0, 2.0));
|
||||
}
|
||||
|
||||
- (id)_cibInstantiate
|
||||
{
|
||||
var theClass = CPClassFromString(_className);
|
||||
@@ -83,7 +71,7 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
#endif
|
||||
theClass = [CPView class];
|
||||
}
|
||||
|
||||
|
||||
// Hey this is us!
|
||||
if (theClass === [self class])
|
||||
{
|
||||
@@ -110,7 +98,7 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
|
||||
[view setAutoresizingMask:[self autoresizingMask]];
|
||||
[view setAutoresizesSubviews:[self autoresizesSubviews]];
|
||||
|
||||
|
||||
[view setHitTests:[self hitTests]];
|
||||
[view setHidden:[self isHidden]];
|
||||
[view setAlphaValue:[self alphaValue]];
|
||||
@@ -119,7 +107,7 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
|
||||
[view setBackgroundColor:[self backgroundColor]];
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user