diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 22:37:55 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 22:37:55 +0000 |
commit | d546029a268e19c244bcbfba57e4bd2d39d44a83 (patch) | |
tree | 82090113ed3095ac5db6fe5610a908846b7cf0ec /chrome/browser/cocoa/tab_view.mm | |
parent | 8717745b839efbe446902f3449a3a348f687a42f (diff) | |
download | chromium_src-d546029a268e19c244bcbfba57e4bd2d39d44a83.zip chromium_src-d546029a268e19c244bcbfba57e4bd2d39d44a83.tar.gz chromium_src-d546029a268e19c244bcbfba57e4bd2d39d44a83.tar.bz2 |
Several theming fixes for the Mac. Sorry for the extensive change, but they
were all sort of intertwined.
Fixes up patterns in general so that they are all in phase.
Moves the window widget buttons down by two pixels.
Draws overlays correctly.
Fixes up some accessibility issues with the default window widgets.
Gets rid of some out of date files (tab_cell).
BUG=18438, 18547, 19851, 20295, 22213, 23651, 24338
TEST=Launch Chrome. Switch to "dots" theme from the Google themes. Create a couple of tabs. Check to make sure that the background pattern line up with the tabs. Move the tabs around. Check that the hightlight colors and text colors look correct for all of the tabs. Make sure the patterns stay lined up. Resize the window, make sure none of the patterns move around. Create new windows by dragging the tabs out of the windows and make sure a new window is created with the correct pattern. Show the "find" bar. Make sure its pattern lines up correctly with the tabbar. Switch to default theme. Make sure it looks correct and draws properly. Switch to Zen theme and make sure that the overlay at the top draws correctly. Create a new window. make sure that the rollovers in the window widgets work correctly in both the active and inactive window. Mouse down on the zoom button in the inactive window and notice that the window context changes. Move off of the zoom button and mouse up. Mouse down on the miniaturize button on the inactive window and notice that the window context does not change. Move off of the miniaturize button and mouse up. Do the same thing you did for the miniaturize button for the close button. Start up Accessibility Inspector from the developer tools. Make sure that the window widgets report their accessibility information correctly.
Review URL: http://codereview.chromium.org/260009
Patch from dmaclach@chromium.org.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_view.mm')
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index fd6a2a4..fd1be74 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -59,7 +59,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; // Overridden so that mouse clicks come to this view (the parent of the // hierarchy) first. We want to handle clicks and drags in this class and // leave the background button for display purposes only. -- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { +- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent { return YES; } @@ -88,7 +88,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; [self setNeedsDisplay:YES]; } -- (void)mouseEntered:(NSEvent *)theEvent { +- (void)mouseEntered:(NSEvent*)theEvent { if ([theEvent trackingArea] == closeTrackingArea_) { [closeButton_ setImage:nsimage_cache::ImageNamed(@"close_bar_h.pdf")]; } else { @@ -99,13 +99,13 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; } } -- (void)mouseMoved:(NSEvent *)theEvent { +- (void)mouseMoved:(NSEvent*)theEvent { hoverPoint_ = [self convertPoint:[theEvent locationInWindow] fromView:nil]; [self setNeedsDisplay:YES]; } -- (void)mouseExited:(NSEvent *)theEvent { +- (void)mouseExited:(NSEvent*)theEvent { if ([theEvent trackingArea] == closeTrackingArea_) { [closeButton_ setImage:nsimage_cache::ImageNamed(@"close_bar.pdf")]; } else { @@ -118,7 +118,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; // Determines which view a click in our frame actually hit. It's either this // view or our child close button. -- (NSView *)hitTest:(NSPoint)aPoint { +- (NSView*)hitTest:(NSPoint)aPoint { NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; NSRect frame = [self frame]; @@ -136,7 +136,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; // Returns |YES| if this tab can be torn away into a new window. - (BOOL)canBeDragged { - NSWindowController *controller = [sourceWindow_ windowController]; + NSWindowController* controller = [sourceWindow_ windowController]; if ([controller isKindOfClass:[TabWindowController class]]) { TabWindowController* realController = static_cast<TabWindowController*>(controller); @@ -154,7 +154,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; for (NSWindow* window in [NSApp windows]) { if (window == dragWindow) continue; if (![window isVisible]) continue; - NSWindowController *controller = [window windowController]; + NSWindowController* controller = [window windowController]; if ([controller isKindOfClass:[TabWindowController class]]) { TabWindowController* realController = static_cast<TabWindowController*>(controller); @@ -189,7 +189,7 @@ static const NSTimeInterval kTearDuration = 0.333; // has moved less than the threshold, we want to close the tab. static const CGFloat kRapidCloseDist = 2.5; -- (void)mouseDown:(NSEvent *)theEvent { +- (void)mouseDown:(NSEvent*)theEvent { NSPoint downLocation = [theEvent locationInWindow]; // During the tab closure animation (in particular, during rapid tab closure), @@ -284,7 +284,7 @@ static const CGFloat kRapidCloseDist = 2.5; } } -- (void)mouseDragged:(NSEvent *)theEvent { +- (void)mouseDragged:(NSEvent*)theEvent { // Special-case this to keep the logic below simpler. if (moveWindowOnDrag_) { NSPoint thisPoint = [NSEvent mouseLocation]; @@ -452,7 +452,7 @@ static const CGFloat kRapidCloseDist = 2.5; // Compute where placeholder should go and insert it into the // destination tab strip. NSRect dropTabFrame = [[targetController_ tabStripView] frame]; - TabView *draggedTabView = (TabView *)[draggedController_ selectedTabView]; + TabView* draggedTabView = (TabView*)[draggedController_ selectedTabView]; NSRect tabFrame = [draggedTabView frame]; tabFrame.origin = [dragWindow_ convertBaseToScreen:tabFrame.origin]; tabFrame.origin = [[targetController_ window] @@ -490,7 +490,7 @@ static const CGFloat kRapidCloseDist = 2.5; } } -- (void)mouseUp:(NSEvent *)theEvent { +- (void)mouseUp:(NSEvent*)theEvent { // The drag/click is done. If the user dragged the mouse, finalize the drag // and clean up. @@ -549,19 +549,12 @@ static const CGFloat kRapidCloseDist = 2.5; } } -- (NSPoint)patternPhase { - NSPoint phase = NSZeroPoint; - phase.x -= [self convertRect:[self bounds] toView:nil].origin.x; - // offset to start pattern in upper left corner - phase.y += NSHeight([self bounds]) - 1; - return phase; -} - - (void)drawRect:(NSRect)rect { - [[NSGraphicsContext currentContext] saveGraphicsState]; + NSGraphicsContext* context = [NSGraphicsContext currentContext]; + [context saveGraphicsState]; rect = [self bounds]; BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; - BOOL selected = [(NSButton *)self state]; + BOOL selected = [(NSButton*)self state]; // Inset by 0.5 in order to draw on pixels rather than on borders (which would // cause blurry pixels). Decrease height by 1 in order to move away from the @@ -583,7 +576,7 @@ static const CGFloat kRapidCloseDist = 2.5; // Outset many of these values by 1 to cause the fill to bleed outside the // clip area. - NSBezierPath *path = [NSBezierPath bezierPath]; + NSBezierPath* path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(bottomLeft.x - 1, bottomLeft.y - 2)]; [path lineToPoint:NSMakePoint(bottomLeft.x - 1, bottomLeft.y)]; [path lineToPoint:bottomLeft]; @@ -601,52 +594,51 @@ static const CGFloat kRapidCloseDist = 2.5; [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y)]; [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y - 2)]; - GTMTheme *theme = [self gtm_theme]; + GTMTheme* theme = [self gtm_theme]; + + // Setting the pattern phase + NSPoint phase = [self gtm_themePatternPhase]; + [context setPatternPhase:phase]; if (!selected) { - NSColor *windowColor = + NSColor* windowColor = [theme backgroundPatternColorForStyle:GTMThemeStyleWindow state:GTMThemeStateActiveWindow]; if (windowColor) { [windowColor set]; - - [[NSGraphicsContext currentContext] setPatternPhase:[self patternPhase]]; } else { - NSPoint phase = [self patternPhase]; - phase.y += 1; - [[NSGraphicsContext currentContext] setPatternPhase:phase]; [[NSColor windowBackgroundColor] set]; } [path fill]; - NSColor *tabColor = + NSColor* tabColor = [theme backgroundPatternColorForStyle:GTMThemeStyleTabBarDeselected state:GTMThemeStateActiveWindow]; if (tabColor) { [tabColor set]; - [[NSGraphicsContext currentContext] setPatternPhase:[self patternPhase]]; } else { [[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] set]; } [path fill]; - } - [[NSGraphicsContext currentContext] saveGraphicsState]; + [context saveGraphicsState]; [path addClip]; if (selected || hoverAlpha_ > 0) { // Draw the background. CGFloat backgroundAlpha = hoverAlpha_ * 0.5; - [[NSGraphicsContext currentContext] saveGraphicsState]; - CGContextRef context = - (CGContextRef)([[NSGraphicsContext currentContext] graphicsPort]); - CGContextBeginTransparencyLayer(context, 0); + [context saveGraphicsState]; + CGContextRef cgContext = + (CGContextRef)([context graphicsPort]); + CGContextBeginTransparencyLayer(cgContext, 0); if (!selected) - CGContextSetAlpha(context, backgroundAlpha); + CGContextSetAlpha(cgContext, backgroundAlpha); [path addClip]; - [super drawRect:rect]; + [context saveGraphicsState]; + [super drawBackground]; + [context restoreGraphicsState]; // Draw a mouse hover gradient for the default themes if (!selected) { @@ -671,8 +663,8 @@ static const CGFloat kRapidCloseDist = 2.5; } } - CGContextEndTransparencyLayer(context); - [[NSGraphicsContext currentContext] restoreGraphicsState]; + CGContextEndTransparencyLayer(cgContext); + [context restoreGraphicsState]; } // Draw the top inner highlight. @@ -684,10 +676,10 @@ static const CGFloat kRapidCloseDist = 2.5; setStroke]; [highlightPath stroke]; - [[NSGraphicsContext currentContext] restoreGraphicsState]; + [context restoreGraphicsState]; // Draw the top stroke. - [[NSGraphicsContext currentContext] saveGraphicsState]; + [context saveGraphicsState]; if (selected) { [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.3 : 0.15] set]; } else { @@ -696,7 +688,7 @@ static const CGFloat kRapidCloseDist = 2.5; } [path setLineWidth:1.0]; [path stroke]; - [[NSGraphicsContext currentContext] restoreGraphicsState]; + [context restoreGraphicsState]; // Draw the bottom border. if (!selected) { @@ -706,7 +698,7 @@ static const CGFloat kRapidCloseDist = 2.5; [[NSColor colorWithDeviceWhite:0.0 alpha:active ? 0.3 : 0.15] set]; NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); } - [[NSGraphicsContext currentContext] restoreGraphicsState]; + [context restoreGraphicsState]; } // Called when the user hits the right mouse button (or control-clicks) to @@ -715,4 +707,11 @@ static const CGFloat kRapidCloseDist = 2.5; [NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self]; } +- (void)viewDidMoveToWindow { + [super viewDidMoveToWindow]; + if ([self window]) { + [controller_ updateTitleColor]; + } +} + @end |