diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index 805b8a95e..2f0cd73c0 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -307,7 +307,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0, _retargedChildIndex = nil; _shouldRetargetChildIndex = NO; - [self setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleRegular]; [self setIndentationPerLevel:16.0]; [self setIndentationMarkerFollowsDataView:YES]; @@ -2216,63 +2215,20 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0, self = [super initWithFrame:aFrame]; if (self) - { [self setBordered:NO]; - [self setBezelStyle:CPDisclosureBezelStyle]; - _angle = 0.0; - } return self; } -// 1. Tell the animation system that 'angle' must be animated via a Timer loop -// (Software animation) because it affects drawRect, not CSS. -+ (BOOL)needsPeriodicFrameUpdatesForKey:(CPString)aKey -{ - if (aKey === @"angle") - return YES; - return [super needsPeriodicFrameUpdatesForKey:aKey]; -} - -// 2. Accessor for the animator to set the value -- (void)setAngle:(float)anAngle -{ - _angle = anAngle; - [self setNeedsDisplay:YES]; -} - -- (float)angle -{ - return _angle; -} - - (void)setState:(CPInteger)aState { - // If the state isn't changing, do nothing - if ([self state] === aState) - return; - [super setState:aState]; - // Calculate target angle: 0.0 for Expanded (Down), -PI_2 for Collapsed (Right) - var targetAngle = ([self state] === CPOnState) ? 0.0 : -PI_2; + if ([self state] === CPOnState) + _angle = 0.0; - // Only animate if the view is visible in a window - if ([self window]) - { - [CPAnimationContext beginGrouping]; - [[CPAnimationContext currentContext] setDuration:0.2]; - - // Because we implemented +needsPeriodicFrameUpdatesForKey:, - // calling this on the animator automatically starts the timer loop. - [[self animator] setAngle:targetAngle]; - - [CPAnimationContext endGrouping]; - } else - { - [self setAngle:targetAngle]; - } + _angle = -PI_2; } - (void)drawRect:(CGRect)aRect @@ -2283,95 +2239,37 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0, height = CGRectGetHeight(bounds); CGContextBeginPath(context); - CGContextSaveGState(context); - // 3. Apply rotation centered on the view - if (_angle !== 0.0) + if (_angle) { - var centreX = FLOOR(width / 2.0), - centreY = FLOOR(height / 2.0); - - CGContextTranslateCTM(context, centreX, centreY); + var centre = CGPointMake(FLOOR(width / 2.0), FLOOR(height / 2.0)); + CGContextTranslateCTM(context, centre.x, centre.y); CGContextRotateCTM(context, _angle); - CGContextTranslateCTM(context, -centreX, -centreY); + CGContextTranslateCTM(context, -centre.x, -centre.y); } - // Center the triangle visually + // Center, but crisp. CGContextTranslateCTM(context, FLOOR((width - 9.0) / 2.0), FLOOR((height - 8.0) / 2.0)); - // Draw the triangle CGContextMoveToPoint(context, 0.0, 0.0); CGContextAddLineToPoint(context, 9.0, 0.0); CGContextAddLineToPoint(context, 4.5, 8.0); CGContextClosePath(context); - // Calculate Color based on HUD and KeyWindow states --- - var isSelected = [self hasThemeState:CPThemeStateSelected], - isHighlighted = [self hasThemeState:CPThemeStateHighlighted], - isKeyWindow = [self hasThemeState:CPThemeStateKeyWindow], - // Detect HUD style mask on the window - isHUD = [self window] && ([[self window] styleMask] & CPHUDBackgroundWindowMask), - triangleColor = nil; - - if (isHUD) - { - // 2. HUD Logic - if (isSelected) - triangleColor = [CPColor blackColor]; // Selected HUD row = White BG -> Black Triangle - else - triangleColor = [CPColor whiteColor]; // Normal HUD row = Dark BG -> White Triangle - - // Handle click highlight in HUD (dim it) - if (isHighlighted) - triangleColor = [triangleColor colorWithAlphaComponent:0.5]; - } - else - { - // Standard Logic - if (isSelected) - { - if (isKeyWindow) - triangleColor = [CPColor whiteColor]; // Key Window + Selected = Blue BG -> White Triangle - else - triangleColor = [CPColor blackColor]; // 1. Non-Key Window + Selected = Gray BG -> Black Triangle - } - else - { - // Standard Unselected - triangleColor = [CPColor colorWithCalibratedWhite:0.45 alpha: 1.0]; - } - - // Handle click highlight in Standard - if (isHighlighted) - { - if (isSelected && isKeyWindow) - triangleColor = [CPColor colorWithCalibratedWhite:0.9 alpha: 1.0]; - else if (isSelected && !isKeyWindow) - triangleColor = [CPColor colorWithCalibratedWhite:0.2 alpha: 1.0]; - else - triangleColor = [CPColor colorWithCalibratedWhite:0.25 alpha: 1.0]; - } - } - - CGContextSetFillColor(context, triangleColor); - + CGContextSetFillColor(context, + colorForDisclosureTriangle([self hasThemeState:CPThemeStateSelected], + [self hasThemeState:CPThemeStateHighlighted])); CGContextFillPath(context); - // Draw the outline CGContextBeginPath(context); CGContextMoveToPoint(context, 0.0, 0.0); CGContextAddLineToPoint(context, 4.5, 8.0); - // Only draw the top line (completing the triangle) if not rotated (standard Cocoa look) if (_angle === 0.0) CGContextAddLineToPoint(context, 9.0, 0.0); - // Adjust stroke opacity for HUD/Non-Key to avoid "ghostly" white borders on light backgrounds - var strokeAlpha = (isHUD || (isSelected && !isKeyWindow)) ? 0.3 : 0.7; - CGContextSetStrokeColor(context, [CPColor colorWithCalibratedWhite:1.0 alpha:strokeAlpha]); + CGContextSetStrokeColor(context, [CPColor colorWithCalibratedWhite:1.0 alpha: 0.7]); CGContextStrokePath(context); - - CGContextRestoreGState(context); } @end diff --git a/Tests/Manual/ThemeKitchenSinkA3/AppController.j b/Tests/Manual/ThemeKitchenSinkA3/AppController.j index fcb24d93b..6a172bb72 100644 --- a/Tests/Manual/ThemeKitchenSinkA3/AppController.j +++ b/Tests/Manual/ThemeKitchenSinkA3/AppController.j @@ -730,6 +730,8 @@ [scrollView setAutohidesScrollers:YES]; var outlineView = [[CPOutlineView alloc] initWithFrame:[scrollView bounds]]; + [outlineView setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleRegular]; + [outlineView setUsesAlternatingRowBackgroundColors:YES]; [outlineView setCornerView:nil];