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

Side by Side Diff: chrome/browser/ui/cocoa/l10n_util.mm

Issue 2511973002: Reverse bookmark buttons and menus in RTL (Closed)
Patch Set: Use line width instead of hardcoding cell inset Created 4 years 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.h ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/l10n_util.h" 5 #import "chrome/browser/ui/cocoa/l10n_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 bool ShouldDoExperimentalRTLLayout() { 90 bool ShouldDoExperimentalRTLLayout() {
91 return base::i18n::IsRTL() && 91 return base::i18n::IsRTL() &&
92 base::FeatureList::IsEnabled(kExperimentalMacRTL); 92 base::FeatureList::IsEnabled(kExperimentalMacRTL);
93 } 93 }
94 94
95 bool ShouldFlipWindowControlsInRTL() { 95 bool ShouldFlipWindowControlsInRTL() {
96 return ShouldDoExperimentalRTLLayout() && base::mac::IsAtLeastOS10_12(); 96 return ShouldDoExperimentalRTLLayout() && base::mac::IsAtLeastOS10_12();
97 } 97 }
98 98
99 #if !defined(MAC_OS_X_VERSION_10_12) || \
100 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
101 NSCellImagePosition LeadingCellImagePosition() {
102 return ShouldDoExperimentalRTLLayout() ? NSImageRight : NSImageLeft;
103 }
104 NSCellImagePosition TrailingCellImagePosition() {
105 return ShouldDoExperimentalRTLLayout() ? NSImageLeft : NSImageRight;
106 }
107 #else
108 NSCellImagePosition LeadingCellImagePosition() {
109 return NSImageLeading;
110 }
111 NSCellImagePosition TrailingCellImagePosition() {
112 return NSImageTrailing;
113 }
114 #endif // MAC_OS_X_VERSION_10_12
115
116 // Adapted from Apple's RTL docs (goo.gl/cBaFnT)
117 NSImage* FlippedImage(NSImage* image) {
118 NSImage* existingImage = image;
119 NSSize existingSize = [existingImage size];
120 NSSize newSize = NSMakeSize(existingSize.width, existingSize.height);
121 NSImage* flippedImage = [[[NSImage alloc] initWithSize:newSize] autorelease];
122
123 [flippedImage lockFocus];
124 [[NSGraphicsContext currentContext]
125 setImageInterpolation:NSImageInterpolationHigh];
126
127 NSAffineTransform* transform = [NSAffineTransform transform];
128 [transform translateXBy:existingSize.width yBy:0];
129 [transform scaleXBy:-1 yBy:1];
130 [transform concat];
131
132 [existingImage drawAtPoint:NSZeroPoint
133 fromRect:NSMakeRect(0, 0, newSize.width, newSize.height)
134 operation:NSCompositeSourceOver
135 fraction:1.0];
136
137 [flippedImage unlockFocus];
138
139 return flippedImage;
140 }
141
99 } // namespace cocoa_l10n_util 142 } // namespace cocoa_l10n_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698