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

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

Issue 2313723004: cocoa: flip window controls and profile switcher for RTL (Closed)
Patch Set: add ExperimentalMacRTL feature Created 4 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
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/new_tab_button.h" 5 #import "chrome/browser/ui/cocoa/new_tab_button.h"
6 6
7 #include "base/i18n/rtl.h"
7 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 9 #include "base/mac/sdk_forward_declarations.h"
9 #import "chrome/browser/ui/cocoa/image_button_cell.h" 10 #import "chrome/browser/ui/cocoa/image_button_cell.h"
11 #include "chrome/browser/ui/cocoa/l10n_util.h"
10 #include "chrome/browser/ui/cocoa/tabs/tab_view.h" 12 #include "chrome/browser/ui/cocoa/tabs/tab_view.h"
11 #include "chrome/grit/theme_resources.h" 13 #include "chrome/grit/theme_resources.h"
12 #include "ui/base/cocoa/nsgraphics_context_additions.h" 14 #include "ui/base/cocoa/nsgraphics_context_additions.h"
13 #include "ui/base/material_design/material_design_controller.h" 15 #include "ui/base/material_design/material_design_controller.h"
14 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/theme_provider.h" 17 #include "ui/base/theme_provider.h"
16 18
17 @class NewTabButtonCell; 19 @class NewTabButtonCell;
18 20
19 namespace { 21 namespace {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 [bezierPath curveToPoint:NSMakePoint(64.0268555,27.5961914) 407 [bezierPath curveToPoint:NSMakePoint(64.0268555,27.5961914)
406 controlPoint1:NSMakePoint(52.9464653,2.82643678) 408 controlPoint1:NSMakePoint(52.9464653,2.82643678)
407 controlPoint2:NSMakePoint(64.0268555,27.4111339)]; 409 controlPoint2:NSMakePoint(64.0268555,27.4111339)];
408 410
409 [bezierPath curveToPoint:NSMakePoint(62.2756294,30) 411 [bezierPath curveToPoint:NSMakePoint(62.2756294,30)
410 controlPoint1:NSMakePoint(64.0268555,28.5502144) 412 controlPoint1:NSMakePoint(64.0268555,28.5502144)
411 controlPoint2:NSMakePoint(63.227482,29.9977011)]; 413 controlPoint2:NSMakePoint(63.227482,29.9977011)];
412 414
413 [bezierPath closePath]; 415 [bezierPath closePath];
414 416
415 // The SVG path is flipped for some reason, so flip it back. 417 // The SVG path is flipped for some reason, so flip it back. However, in RTL,
416 const CGFloat kSVGHeight = 32; 418 // we'd need to flip it again below, so when in RTL mode just leave the flip
417 NSAffineTransformStruct flipStruct = { 1, 0, 0, -1, 0, kSVGHeight }; 419 // out altogether.
418 NSAffineTransform* flipTransform = [NSAffineTransform transform]; 420 if (!cocoa_l10n_util::ExperimentalMacRTLIsEnabled() || !base::i18n::IsRTL()) {
419 [flipTransform setTransformStruct:flipStruct]; 421 const CGFloat kSVGHeight = 32;
420 [bezierPath transformUsingAffineTransform:flipTransform]; 422 NSAffineTransformStruct flipStruct = {1, 0, 0, -1, 0, kSVGHeight};
423 NSAffineTransform* flipTransform = [NSAffineTransform transform];
424 [flipTransform setTransformStruct:flipStruct];
425 [bezierPath transformUsingAffineTransform:flipTransform];
426 }
421 427
422 // The SVG data is for the 2x version so scale it down. 428 // The SVG data is for the 2x version so scale it down.
423 NSAffineTransform* scaleTransform = [NSAffineTransform transform]; 429 NSAffineTransform* scaleTransform = [NSAffineTransform transform];
424 const CGFloat k50PercentScale = 0.5; 430 const CGFloat k50PercentScale = 0.5;
425 [scaleTransform scaleBy:k50PercentScale]; 431 [scaleTransform scaleBy:k50PercentScale];
426 [bezierPath transformUsingAffineTransform:scaleTransform]; 432 [bezierPath transformUsingAffineTransform:scaleTransform];
427 433
428 // Adjust by half the line width to get crisp lines. 434 // Adjust by half the line width to get crisp lines.
429 NSAffineTransform* transform = [NSAffineTransform transform]; 435 NSAffineTransform* transform = [NSAffineTransform transform];
430 [transform translateXBy:lineWidth / 2 yBy:lineWidth / 2]; 436 [transform translateXBy:lineWidth / 2 yBy:lineWidth / 2];
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 [fillColor set]; 536 [fillColor set];
531 CGContextRef context = static_cast<CGContextRef>( 537 CGContextRef context = static_cast<CGContextRef>(
532 [[NSGraphicsContext currentContext] graphicsPort]); 538 [[NSGraphicsContext currentContext] graphicsPort]);
533 CGFloat lineWidth = LineWidthFromContext(context); 539 CGFloat lineWidth = LineWidthFromContext(context);
534 [[NewTabButton newTabButtonBezierPathWithLineWidth:lineWidth] fill]; 540 [[NewTabButton newTabButtonBezierPathWithLineWidth:lineWidth] fill];
535 [image unlockFocus]; 541 [image unlockFocus];
536 return image; 542 return image;
537 } 543 }
538 544
539 @end 545 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/l10n_util.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698