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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 usingRect:(NSRect)defaultSheetRect; | 89 usingRect:(NSRect)defaultSheetRect; |
90 | 90 |
91 // Assign a theme to the window. | 91 // Assign a theme to the window. |
92 - (void)setTheme; | 92 - (void)setTheme; |
93 | 93 |
94 // Theme up the window. | 94 // Theme up the window. |
95 - (void)applyTheme; | 95 - (void)applyTheme; |
96 | 96 |
97 // Repositions the windows subviews. | 97 // Repositions the windows subviews. |
98 - (void)layoutSubviews; | 98 - (void)layoutSubviews; |
99 | |
100 @end | 99 @end |
101 | 100 |
102 | 101 |
103 @implementation BrowserWindowController | 102 @implementation BrowserWindowController |
104 | 103 |
105 // Load the browser window nib and do any Cocoa-specific initialization. | 104 // Load the browser window nib and do any Cocoa-specific initialization. |
106 // Takes ownership of |browser|. Note that the nib also sets this controller | 105 // Takes ownership of |browser|. Note that the nib also sets this controller |
107 // up as the window's delegate. | 106 // up as the window's delegate. |
108 - (id)initWithBrowser:(Browser*)browser { | 107 - (id)initWithBrowser:(Browser*)browser { |
109 return [self initWithBrowser:browser takeOwnership:YES]; | 108 return [self initWithBrowser:browser takeOwnership:YES]; |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 loadingOnly:(BOOL)loading { | 920 loadingOnly:(BOOL)loading { |
922 if (index == browser_->tabstrip_model()->selected_index()) { | 921 if (index == browser_->tabstrip_model()->selected_index()) { |
923 // Update titles if this is the currently selected tab. | 922 // Update titles if this is the currently selected tab. |
924 windowShim_->UpdateTitleBar(); | 923 windowShim_->UpdateTitleBar(); |
925 } | 924 } |
926 } | 925 } |
927 | 926 |
928 - (void)userChangedTheme { | 927 - (void)userChangedTheme { |
929 [self setTheme]; | 928 [self setTheme]; |
930 [self applyTheme]; | 929 [self applyTheme]; |
| 930 |
| 931 [tabStripController_ userChangedTheme]; |
931 } | 932 } |
932 | 933 |
933 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { | 934 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { |
934 return theme_ ? theme_ : [GTMTheme defaultTheme]; | 935 return theme_ ? theme_ : [GTMTheme defaultTheme]; |
935 } | 936 } |
936 | 937 |
937 - (NSPoint)topLeftForBubble { | 938 - (NSPoint)topLeftForBubble { |
938 NSRect rect = [toolbarController_ starButtonInWindowCoordinates]; | 939 NSRect rect = [toolbarController_ starButtonInWindowCoordinates]; |
939 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left | 940 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left |
940 | 941 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 isOffTheRecord:browser_->profile()->IsOffTheRecord()]; | 1126 isOffTheRecord:browser_->profile()->IsOffTheRecord()]; |
1126 theme_.reset([theme retain]); | 1127 theme_.reset([theme retain]); |
1127 } | 1128 } |
1128 } | 1129 } |
1129 | 1130 |
1130 - (void)applyTheme { | 1131 - (void)applyTheme { |
1131 NSColor* color = | 1132 NSColor* color = |
1132 [theme_ backgroundPatternColorForStyle:GTMThemeStyleWindow | 1133 [theme_ backgroundPatternColorForStyle:GTMThemeStyleWindow |
1133 state:[[self window] isMainWindow]]; | 1134 state:[[self window] isMainWindow]]; |
1134 [[self window] setBackgroundColor:color]; | 1135 [[self window] setBackgroundColor:color]; |
1135 [tabStripController_ applyTheme]; | |
1136 } | 1136 } |
1137 | 1137 |
1138 // Private method to layout browser window subviews. Positions the toolbar and | 1138 // Private method to layout browser window subviews. Positions the toolbar and |
1139 // the infobar above the tab content area. Positions the download shelf below | 1139 // the infobar above the tab content area. Positions the download shelf below |
1140 // the tab content area. If the toolbar is not a child of the contentview, this | 1140 // the tab content area. If the toolbar is not a child of the contentview, this |
1141 // method will not leave room for it. If we are currently running in fullscreen | 1141 // method will not leave room for it. If we are currently running in fullscreen |
1142 // mode, or if the tabstrip is not a descendant of the window, this method fills | 1142 // mode, or if the tabstrip is not a descendant of the window, this method fills |
1143 // the entire content area. Otherwise, this method places the topmost view | 1143 // the entire content area. Otherwise, this method places the topmost view |
1144 // directly beneath the tabstrip. | 1144 // directly beneath the tabstrip. |
1145 - (void)layoutSubviews { | 1145 - (void)layoutSubviews { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 return theme; | 1222 return theme; |
1223 } | 1223 } |
1224 | 1224 |
1225 NSImage* frameImage = provider->GetNSImageNamed(IDR_THEME_FRAME); | 1225 NSImage* frameImage = provider->GetNSImageNamed(IDR_THEME_FRAME); |
1226 NSImage* frameInactiveImage = | 1226 NSImage* frameInactiveImage = |
1227 provider->GetNSImageNamed(IDR_THEME_FRAME_INACTIVE); | 1227 provider->GetNSImageNamed(IDR_THEME_FRAME_INACTIVE); |
1228 | 1228 |
1229 [theme setValue:frameImage | 1229 [theme setValue:frameImage |
1230 forAttribute:@"backgroundImage" | 1230 forAttribute:@"backgroundImage" |
1231 style:GTMThemeStyleWindow | 1231 style:GTMThemeStyleWindow |
1232 state:GTMThemeStateActiveWindow]; | 1232 state:YES]; |
1233 | 1233 |
1234 NSColor* tabTextColor = | 1234 NSColor* tabTextColor = [NSColor blackColor]; |
1235 provider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT); | |
1236 [theme setValue:tabTextColor | 1235 [theme setValue:tabTextColor |
1237 forAttribute:@"textColor" | 1236 forAttribute:@"textColor" |
1238 style:GTMThemeStyleToolBar | 1237 style:GTMThemeStyleToolBar |
1239 state:GTMThemeStateActiveWindow]; | 1238 state:YES]; |
1240 | 1239 |
1241 NSColor* tabInactiveTextColor = | 1240 NSColor* tabInactiveTextColor = [NSColor grayColor]; |
1242 provider->GetNSColor(BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT); | |
1243 [theme setValue:tabInactiveTextColor | 1241 [theme setValue:tabInactiveTextColor |
1244 forAttribute:@"textColor" | 1242 forAttribute:@"textColor" |
1245 style:GTMThemeStyleTabBarDeselected | 1243 style:GTMThemeStyleToolBar |
1246 state:GTMThemeStateActiveWindow]; | 1244 state:NO]; |
1247 | 1245 |
1248 NSColor* bookmarkBarTextColor = | 1246 NSColor* bookmarkBarTextColor = [NSColor blackColor]; |
1249 provider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); | |
1250 [theme setValue:bookmarkBarTextColor | 1247 [theme setValue:bookmarkBarTextColor |
1251 forAttribute:@"textColor" | 1248 forAttribute:@"textColor" |
1252 style:GTMThemeStyleBookmarksBarButton | 1249 style:GTMThemeStyleBookmarksBarButton |
1253 state:GTMThemeStateActiveWindow]; | 1250 state:YES]; |
1254 | 1251 |
1255 [theme setValue:frameInactiveImage | 1252 [theme setValue:frameInactiveImage |
1256 forAttribute:@"backgroundImage" | 1253 forAttribute:@"backgroundImage" |
1257 style:GTMThemeStyleWindow | 1254 style:GTMThemeStyleWindow |
1258 state:0]; | 1255 state:NO]; |
1259 | 1256 |
1260 NSImage* toolbarImage = provider->GetNSImageNamed(IDR_THEME_TOOLBAR); | 1257 NSImage* toolbarImage = provider->GetNSImageNamed(IDR_THEME_TOOLBAR); |
1261 [theme setValue:toolbarImage | 1258 [theme setValue:toolbarImage |
1262 forAttribute:@"backgroundImage" | 1259 forAttribute:@"backgroundImage" |
1263 style:GTMThemeStyleToolBar | 1260 style:GTMThemeStyleToolBar |
1264 state:GTMThemeStateActiveWindow]; | 1261 state:YES]; |
1265 NSImage* toolbarBackgroundImage = | |
1266 provider->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND); | |
1267 [theme setValue:toolbarBackgroundImage | |
1268 forAttribute:@"backgroundImage" | |
1269 style:GTMThemeStyleTabBarDeselected | |
1270 state:GTMThemeStateActiveWindow]; | |
1271 | 1262 |
1272 NSImage* toolbarButtonImage = | 1263 NSImage* toolbarButtonImage = |
1273 provider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND); | 1264 provider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND); |
1274 if (toolbarButtonImage) { | 1265 if (toolbarButtonImage) { |
1275 [theme setValue:toolbarButtonImage | 1266 [theme setValue:toolbarButtonImage |
1276 forAttribute:@"backgroundImage" | 1267 forAttribute:@"backgroundImage" |
1277 style:GTMThemeStyleToolBarButton | 1268 style:GTMThemeStyleToolBarButton |
1278 state:GTMThemeStateActiveWindow]; | 1269 state:YES]; |
1279 } else { | 1270 } else { |
1280 NSColor* startColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.0]; | 1271 NSColor* startColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.0]; |
1281 NSColor* endColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.3]; | 1272 NSColor* endColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.3]; |
1282 scoped_nsobject<NSGradient> gradient([[NSGradient alloc] | 1273 scoped_nsobject<NSGradient> gradient([[NSGradient alloc] |
1283 initWithStartingColor:startColor | 1274 initWithStartingColor:startColor |
1284 endingColor:endColor]); | 1275 endingColor:endColor]); |
1285 | 1276 |
1286 [theme setValue:gradient | 1277 [theme setValue:gradient |
1287 forAttribute:@"gradient" | 1278 forAttribute:@"gradient" |
1288 style:GTMThemeStyleToolBarButton | 1279 style:GTMThemeStyleToolBarButton |
1289 state:GTMThemeStateActiveWindow]; | 1280 state:YES]; |
1290 | 1281 |
1291 [theme setValue:gradient | 1282 [theme setValue:gradient |
1292 forAttribute:@"gradient" | 1283 forAttribute:@"gradient" |
1293 style:GTMThemeStyleToolBarButton | 1284 style:GTMThemeStyleToolBarButton |
1294 state:GTMThemeStateActiveWindow]; | 1285 state:NO]; |
1295 } | 1286 } |
1296 | 1287 |
1297 NSColor* toolbarButtonIconColor = | 1288 NSColor* toolbarButtonIconColor = |
1298 provider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS); | 1289 provider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS); |
1299 [theme setValue:toolbarButtonIconColor | 1290 [theme setValue:toolbarButtonIconColor |
1300 forAttribute:@"iconColor" | 1291 forAttribute:@"iconColor" |
1301 style:GTMThemeStyleToolBarButton | 1292 style:GTMThemeStyleToolBarButton |
1302 state:GTMThemeStateActiveWindow]; | 1293 state:YES]; |
1303 | 1294 |
1304 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; | 1295 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; |
1305 [theme setValue:toolbarButtonBorderColor | 1296 [theme setValue:toolbarButtonBorderColor |
1306 forAttribute:@"borderColor" | 1297 forAttribute:@"borderColor" |
1307 style:GTMThemeStyleToolBar | 1298 style:GTMThemeStyleToolBar |
1308 state:GTMThemeStateActiveWindow]; | 1299 state:YES]; |
1309 | |
1310 NSColor* toolbarBackgroundColor = | |
1311 provider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR); | |
1312 [theme setValue:toolbarBackgroundColor | |
1313 forAttribute:@"backgroundColor" | |
1314 style:GTMThemeStyleToolBar | |
1315 state:GTMThemeStateActiveWindow]; | |
1316 | 1300 |
1317 return theme; | 1301 return theme; |
1318 } | 1302 } |
1319 @end | 1303 @end |
1320 | 1304 |
OLD | NEW |