Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1009)

Side by Side Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 165499: Updates to clean up default theme and add hover states (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
99 @end 100 @end
100 101
101 102
102 @implementation BrowserWindowController 103 @implementation BrowserWindowController
103 104
104 // Load the browser window nib and do any Cocoa-specific initialization. 105 // Load the browser window nib and do any Cocoa-specific initialization.
105 // Takes ownership of |browser|. Note that the nib also sets this controller 106 // Takes ownership of |browser|. Note that the nib also sets this controller
106 // up as the window's delegate. 107 // up as the window's delegate.
107 - (id)initWithBrowser:(Browser*)browser { 108 - (id)initWithBrowser:(Browser*)browser {
108 return [self initWithBrowser:browser takeOwnership:YES]; 109 return [self initWithBrowser:browser takeOwnership:YES];
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 loadingOnly:(BOOL)loading { 921 loadingOnly:(BOOL)loading {
921 if (index == browser_->tabstrip_model()->selected_index()) { 922 if (index == browser_->tabstrip_model()->selected_index()) {
922 // Update titles if this is the currently selected tab. 923 // Update titles if this is the currently selected tab.
923 windowShim_->UpdateTitleBar(); 924 windowShim_->UpdateTitleBar();
924 } 925 }
925 } 926 }
926 927
927 - (void)userChangedTheme { 928 - (void)userChangedTheme {
928 [self setTheme]; 929 [self setTheme];
929 [self applyTheme]; 930 [self applyTheme];
930
931 [tabStripController_ userChangedTheme];
932 } 931 }
933 932
934 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { 933 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window {
935 return theme_ ? theme_ : [GTMTheme defaultTheme]; 934 return theme_ ? theme_ : [GTMTheme defaultTheme];
936 } 935 }
937 936
938 - (NSPoint)topLeftForBubble { 937 - (NSPoint)topLeftForBubble {
939 NSRect rect = [toolbarController_ starButtonInWindowCoordinates]; 938 NSRect rect = [toolbarController_ starButtonInWindowCoordinates];
940 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left 939 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left
941 940
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 isOffTheRecord:browser_->profile()->IsOffTheRecord()]; 1125 isOffTheRecord:browser_->profile()->IsOffTheRecord()];
1127 theme_.reset([theme retain]); 1126 theme_.reset([theme retain]);
1128 } 1127 }
1129 } 1128 }
1130 1129
1131 - (void)applyTheme { 1130 - (void)applyTheme {
1132 NSColor* color = 1131 NSColor* color =
1133 [theme_ backgroundPatternColorForStyle:GTMThemeStyleWindow 1132 [theme_ backgroundPatternColorForStyle:GTMThemeStyleWindow
1134 state:[[self window] isMainWindow]]; 1133 state:[[self window] isMainWindow]];
1135 [[self window] setBackgroundColor:color]; 1134 [[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
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:YES]; 1232 state:GTMThemeStateActiveWindow];
1233 1233
1234 NSColor* tabTextColor = [NSColor blackColor]; 1234 NSColor* tabTextColor =
1235 provider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT);
1235 [theme setValue:tabTextColor 1236 [theme setValue:tabTextColor
1236 forAttribute:@"textColor" 1237 forAttribute:@"textColor"
1237 style:GTMThemeStyleToolBar 1238 style:GTMThemeStyleToolBar
1238 state:YES]; 1239 state:GTMThemeStateActiveWindow];
1239 1240
1240 NSColor* tabInactiveTextColor = [NSColor grayColor]; 1241 NSColor* tabInactiveTextColor =
1242 provider->GetNSColor(BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT);
1241 [theme setValue:tabInactiveTextColor 1243 [theme setValue:tabInactiveTextColor
1242 forAttribute:@"textColor" 1244 forAttribute:@"textColor"
1243 style:GTMThemeStyleToolBar 1245 style:GTMThemeStyleTabBarDeselected
1244 state:NO]; 1246 state:GTMThemeStateActiveWindow];
1245 1247
1246 NSColor* bookmarkBarTextColor = [NSColor blackColor]; 1248 NSColor* bookmarkBarTextColor =
1249 provider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
1247 [theme setValue:bookmarkBarTextColor 1250 [theme setValue:bookmarkBarTextColor
1248 forAttribute:@"textColor" 1251 forAttribute:@"textColor"
1249 style:GTMThemeStyleBookmarksBarButton 1252 style:GTMThemeStyleBookmarksBarButton
1250 state:YES]; 1253 state:GTMThemeStateActiveWindow];
1251 1254
1252 [theme setValue:frameInactiveImage 1255 [theme setValue:frameInactiveImage
1253 forAttribute:@"backgroundImage" 1256 forAttribute:@"backgroundImage"
1254 style:GTMThemeStyleWindow 1257 style:GTMThemeStyleWindow
1255 state:NO]; 1258 state:0];
1256 1259
1257 NSImage* toolbarImage = provider->GetNSImageNamed(IDR_THEME_TOOLBAR); 1260 NSImage* toolbarImage = provider->GetNSImageNamed(IDR_THEME_TOOLBAR);
1258 [theme setValue:toolbarImage 1261 [theme setValue:toolbarImage
1259 forAttribute:@"backgroundImage" 1262 forAttribute:@"backgroundImage"
1260 style:GTMThemeStyleToolBar 1263 style:GTMThemeStyleToolBar
1261 state:YES]; 1264 state:GTMThemeStateActiveWindow];
1265 NSImage* toolbarBackgroundImage =
1266 provider->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND);
1267 [theme setValue:toolbarBackgroundImage
1268 forAttribute:@"backgroundImage"
1269 style:GTMThemeStyleTabBarDeselected
1270 state:GTMThemeStateActiveWindow];
1262 1271
1263 NSImage* toolbarButtonImage = 1272 NSImage* toolbarButtonImage =
1264 provider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND); 1273 provider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND);
1265 if (toolbarButtonImage) { 1274 if (toolbarButtonImage) {
1266 [theme setValue:toolbarButtonImage 1275 [theme setValue:toolbarButtonImage
1267 forAttribute:@"backgroundImage" 1276 forAttribute:@"backgroundImage"
1268 style:GTMThemeStyleToolBarButton 1277 style:GTMThemeStyleToolBarButton
1269 state:YES]; 1278 state:GTMThemeStateActiveWindow];
1270 } else { 1279 } else {
1271 NSColor* startColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.0]; 1280 NSColor* startColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.0];
1272 NSColor* endColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.3]; 1281 NSColor* endColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.3];
1273 scoped_nsobject<NSGradient> gradient([[NSGradient alloc] 1282 scoped_nsobject<NSGradient> gradient([[NSGradient alloc]
1274 initWithStartingColor:startColor 1283 initWithStartingColor:startColor
1275 endingColor:endColor]); 1284 endingColor:endColor]);
1276 1285
1277 [theme setValue:gradient 1286 [theme setValue:gradient
1278 forAttribute:@"gradient" 1287 forAttribute:@"gradient"
1279 style:GTMThemeStyleToolBarButton 1288 style:GTMThemeStyleToolBarButton
1280 state:YES]; 1289 state:GTMThemeStateActiveWindow];
1281 1290
1282 [theme setValue:gradient 1291 [theme setValue:gradient
1283 forAttribute:@"gradient" 1292 forAttribute:@"gradient"
1284 style:GTMThemeStyleToolBarButton 1293 style:GTMThemeStyleToolBarButton
1285 state:NO]; 1294 state:GTMThemeStateActiveWindow];
1286 } 1295 }
1287 1296
1288 NSColor* toolbarButtonIconColor = 1297 NSColor* toolbarButtonIconColor =
1289 provider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS); 1298 provider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS);
1290 [theme setValue:toolbarButtonIconColor 1299 [theme setValue:toolbarButtonIconColor
1291 forAttribute:@"iconColor" 1300 forAttribute:@"iconColor"
1292 style:GTMThemeStyleToolBarButton 1301 style:GTMThemeStyleToolBarButton
1293 state:YES]; 1302 state:GTMThemeStateActiveWindow];
1294 1303
1295 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; 1304 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor;
1296 [theme setValue:toolbarButtonBorderColor 1305 [theme setValue:toolbarButtonBorderColor
1297 forAttribute:@"borderColor" 1306 forAttribute:@"borderColor"
1298 style:GTMThemeStyleToolBar 1307 style:GTMThemeStyleToolBar
1299 state:YES]; 1308 state:GTMThemeStateActiveWindow];
1309
1310 NSColor* toolbarBackgroundColor =
1311 provider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR);
1312 [theme setValue:toolbarBackgroundColor
1313 forAttribute:@"backgroundColor"
1314 style:GTMThemeStyleToolBar
1315 state:GTMThemeStateActiveWindow];
1300 1316
1301 return theme; 1317 return theme;
1302 } 1318 }
1303 @end 1319 @end
1304 1320
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698