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

Side by Side Diff: chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm

Issue 2710123002: [Mac] Flip toolbar button images in RTL (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/cocoa/l10n_util.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 8 #include "base/mac/sdk_forward_declarations.h"
9 #include "chrome/app/vector_icons/vector_icons.h" 9 #include "chrome/app/vector_icons/vector_icons.h"
10 #import "chrome/browser/ui/cocoa/image_button_cell.h" 10 #import "chrome/browser/ui/cocoa/image_button_cell.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 - (void)drawFocusRingMask { 202 - (void)drawFocusRingMask {
203 // Match the hover image's bezel. 203 // Match the hover image's bezel.
204 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect([self bounds], 2, 2) 204 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect([self bounds], 2, 2)
205 xRadius:2 205 xRadius:2
206 yRadius:2] fill]; 206 yRadius:2] fill];
207 } 207 }
208 208
209 - (const gfx::VectorIcon*)vectorIcon { 209 - (const gfx::VectorIcon*)vectorIcon {
210 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
211 switch ([self viewID]) { 210 switch ([self viewID]) {
212 case VIEW_ID_BACK_BUTTON: 211 case VIEW_ID_BACK_BUTTON:
213 return isRTL ? &ui::kForwardArrowIcon : &ui::kBackArrowIcon; 212 return &ui::kBackArrowIcon;
214 case VIEW_ID_FORWARD_BUTTON: 213 case VIEW_ID_FORWARD_BUTTON:
215 return isRTL ? &ui::kBackArrowIcon : &ui::kForwardArrowIcon; 214 return &ui::kForwardArrowIcon;
216 case VIEW_ID_HOME_BUTTON: 215 case VIEW_ID_HOME_BUTTON:
217 return &kNavigateHomeIcon; 216 return &kNavigateHomeIcon;
218 case VIEW_ID_APP_MENU: 217 case VIEW_ID_APP_MENU:
219 return &kBrowserToolsIcon; 218 return &kBrowserToolsIcon;
220 default: 219 default:
221 break; 220 break;
222 } 221 }
223 222
224 return nullptr; 223 return nullptr;
225 } 224 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 CGFloat normalAlpha = isDarkTheme ? 0xCC : 0xFF; 304 CGFloat normalAlpha = isDarkTheme ? 0xCC : 0xFF;
306 const SkColor normalColor = SkColorSetA(vectorIconColor, normalAlpha); 305 const SkColor normalColor = SkColorSetA(vectorIconColor, normalAlpha);
307 const SkColor disabledColor = SkColorSetA(vectorIconColor, 0x33); 306 const SkColor disabledColor = SkColorSetA(vectorIconColor, 0x33);
308 307
309 // Create the normal and disabled state icons. These icons are always the 308 // Create the normal and disabled state icons. These icons are always the
310 // same shape but use a different color. 309 // same shape but use a different color.
311 if (icon == &kBrowserToolsIcon) { 310 if (icon == &kBrowserToolsIcon) {
312 normalIcon = [self browserToolsIconForFillColor:normalColor]; 311 normalIcon = [self browserToolsIconForFillColor:normalColor];
313 disabledIcon = [self browserToolsIconForFillColor:disabledColor]; 312 disabledIcon = [self browserToolsIconForFillColor:disabledColor];
314 } else { 313 } else {
314 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
315 normalIcon = NSImageFromImageSkia( 315 normalIcon = NSImageFromImageSkia(
316 gfx::CreateVectorIcon(*icon, 316 gfx::CreateVectorIcon(*icon,
317 kMDButtonIconSize.width, 317 kMDButtonIconSize.width,
318 normalColor)); 318 normalColor));
319 319 if (isRTL)
320 normalIcon = cocoa_l10n_util::FlippedImage(normalIcon);
320 // The home button has no icon for its disabled state. 321 // The home button has no icon for its disabled state.
321 if (icon != &kNavigateReloadIcon) { 322 if (icon != &kNavigateReloadIcon) {
322 disabledIcon = NSImageFromImageSkia( 323 disabledIcon = NSImageFromImageSkia(
323 gfx::CreateVectorIcon(*icon, 324 gfx::CreateVectorIcon(*icon,
324 kMDButtonIconSize.width, 325 kMDButtonIconSize.width,
325 disabledColor)); 326 disabledColor));
327 if (isRTL)
328 disabledIcon = cocoa_l10n_util::FlippedImage(disabledIcon);
326 } 329 }
327 } 330 }
328 } 331 }
329 332
330 ImageButtonCell* theCell = base::mac::ObjCCast<ImageButtonCell>([self cell]); 333 ImageButtonCell* theCell = base::mac::ObjCCast<ImageButtonCell>([self cell]);
331 // Set the image for the default state, which is just the icon. 334 // Set the image for the default state, which is just the icon.
332 [theCell setImage:normalIcon forButtonState:image_button_cell::kDefaultState]; 335 [theCell setImage:normalIcon forButtonState:image_button_cell::kDefaultState];
333 336
334 // Determine the appropriate image background style for the hover and pressed 337 // Determine the appropriate image background style for the hover and pressed
335 // states. 338 // states.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 381
379 - (void)windowDidChangeTheme { 382 - (void)windowDidChangeTheme {
380 // Update the hover and pressed image backgrounds to match the current theme. 383 // Update the hover and pressed image backgrounds to match the current theme.
381 [self resetButtonStateImages]; 384 [self resetButtonStateImages];
382 } 385 }
383 386
384 - (void)windowDidChangeActive { 387 - (void)windowDidChangeActive {
385 } 388 }
386 389
387 @end 390 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/l10n_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698