OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <Carbon/Carbon.h> | 5 #include <Carbon/Carbon.h> |
6 | 6 |
7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/scoped_nsdisable_screen_updates.h" | 8 #include "base/scoped_nsdisable_screen_updates.h" |
9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 [[self window] setViewsNeedDisplay:YES]; | 1031 [[self window] setViewsNeedDisplay:YES]; |
1032 } | 1032 } |
1033 | 1033 |
1034 - (GTMTheme*)gtm_themeForWindow:(NSWindow*)window { | 1034 - (GTMTheme*)gtm_themeForWindow:(NSWindow*)window { |
1035 return theme_ ? theme_ : [GTMTheme defaultTheme]; | 1035 return theme_ ? theme_ : [GTMTheme defaultTheme]; |
1036 } | 1036 } |
1037 | 1037 |
1038 - (NSPoint)gtm_themePatternPhaseForWindow:(NSWindow*)window { | 1038 - (NSPoint)gtm_themePatternPhaseForWindow:(NSWindow*)window { |
1039 // Our patterns want to be drawn from the upper left hand corner of the view. | 1039 // Our patterns want to be drawn from the upper left hand corner of the view. |
1040 // Cocoa wants to do it from the lower left of the window. | 1040 // Cocoa wants to do it from the lower left of the window. |
| 1041 // |
1041 // Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.) | 1042 // Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.) |
1042 // will phase their patterns relative to this so all the views look right. | 1043 // will phase their patterns relative to this so all the views look right. |
| 1044 // |
| 1045 // To line up the background pattern with the pattern in the browser window |
| 1046 // the background pattern for the tabs needs to be moved left by 5 pixels. |
| 1047 const CGFloat kPatternHorizontalOffset = -5; |
1043 NSView* tabStripView = [self tabStripView]; | 1048 NSView* tabStripView = [self tabStripView]; |
1044 NSRect tabStripViewWindowBounds = [tabStripView bounds]; | 1049 NSRect tabStripViewWindowBounds = [tabStripView bounds]; |
1045 NSView* windowChromeView = [[window contentView] superview]; | 1050 NSView* windowChromeView = [[window contentView] superview]; |
1046 tabStripViewWindowBounds = | 1051 tabStripViewWindowBounds = |
1047 [tabStripView convertRect:tabStripViewWindowBounds | 1052 [tabStripView convertRect:tabStripViewWindowBounds |
1048 toView:windowChromeView]; | 1053 toView:windowChromeView]; |
1049 NSPoint phase = NSMakePoint(NSMinX(tabStripViewWindowBounds), | 1054 NSPoint phase = NSMakePoint(NSMinX(tabStripViewWindowBounds) |
| 1055 + kPatternHorizontalOffset, |
1050 NSMinY(tabStripViewWindowBounds) | 1056 NSMinY(tabStripViewWindowBounds) |
1051 + [TabStripController defaultTabHeight]); | 1057 + [TabStripController defaultTabHeight]); |
1052 return phase; | 1058 return phase; |
1053 } | 1059 } |
1054 | 1060 |
1055 - (NSPoint)topLeftForBubble { | 1061 - (NSPoint)topLeftForBubble { |
1056 NSRect rect = [toolbarController_ starButtonInWindowCoordinates]; | 1062 NSRect rect = [toolbarController_ starButtonInWindowCoordinates]; |
1057 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left | 1063 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left |
1058 | 1064 |
1059 // Adjust top-left based on our knowledge of how the view looks. | 1065 // Adjust top-left based on our knowledge of how the view looks. |
1060 p.x -= 2; | 1066 p.x -= 2; |
1061 p.y += 7; | 1067 p.y += 7; |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 if (frameOverlayInactiveImage) { | 1540 if (frameOverlayInactiveImage) { |
1535 [theme setValue:frameOverlayInactiveImage | 1541 [theme setValue:frameOverlayInactiveImage |
1536 forAttribute:@"overlay" | 1542 forAttribute:@"overlay" |
1537 style:GTMThemeStyleWindow | 1543 style:GTMThemeStyleWindow |
1538 state:GTMThemeStateInactiveWindow]; | 1544 state:GTMThemeStateInactiveWindow]; |
1539 } | 1545 } |
1540 | 1546 |
1541 return theme; | 1547 return theme; |
1542 } | 1548 } |
1543 @end | 1549 @end |
OLD | NEW |