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

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

Issue 2511973002: Reverse bookmark buttons and menus in RTL (Closed)
Patch Set: Increase cell size to account for gradient button's 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/gradient_button_cell.h" 5 #include "chrome/browser/ui/cocoa/gradient_button_cell.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 NSDivideRect(cellFrame, &gradientPart, &solidPart, gradientWidth, NSMaxXEdge); 736 NSDivideRect(cellFrame, &gradientPart, &solidPart, gradientWidth, NSMaxXEdge);
737 737
738 // Draw non-gradient part without transparency layer, as light text on a dark 738 // Draw non-gradient part without transparency layer, as light text on a dark
739 // background looks bad with a gradient layer. 739 // background looks bad with a gradient layer.
740 NSPoint textOffset = NSZeroPoint; 740 NSPoint textOffset = NSZeroPoint;
741 { 741 {
742 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 742 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
743 if (shouldClipTheTitle) 743 if (shouldClipTheTitle)
744 [NSBezierPath clipRect:solidPart]; 744 [NSBezierPath clipRect:solidPart];
745 745
746 CGFloat textLeft = [self textStartXOffset];
747 746
748 // For some reason, the height of cellFrame as passed in is totally bogus. 747 // For some reason, the height of cellFrame as passed in is totally bogus.
749 // For vertical centering purposes, we need the bounds of the containing 748 // For vertical centering purposes, we need the bounds of the containing
750 // view. 749 // view.
751 NSRect buttonFrame = [[self controlView] frame]; 750 NSRect buttonFrame = [[self controlView] frame];
752 751
753 // Call the vertical offset to match native NSButtonCell's version. 752 // Call the vertical offset to match native NSButtonCell's version.
754 textOffset = NSMakePoint(textLeft, 753 textOffset = NSMakePoint(
755 (NSHeight(buttonFrame) - size.height) / 2 + 754 NSMinX(cellFrame),
756 [self verticalTextOffset]); 755 (NSHeight(buttonFrame) - size.height) / 2 + [self verticalTextOffset]);
757 // WIth Material Design we want an ellipsis if the title is too long to fit, 756 // WIth Material Design we want an ellipsis if the title is too long to fit,
758 // so have to use drawInRect: instead of drawAtPoint:. 757 // so have to use drawInRect: instead of drawAtPoint:.
759 if (isModeMaterial) { 758 if (isModeMaterial) {
760 NSRect textBounds = NSMakeRect(textOffset.x, 759 NSRect textFrame = NSMakeRect(textOffset.x, textOffset.y,
761 textOffset.y, 760 NSWidth(cellFrame), NSHeight(buttonFrame));
762 NSWidth(buttonFrame) - textOffset.x, 761 [title drawInRect:textFrame];
763 NSHeight(buttonFrame));
764 [title drawInRect:textBounds];
765 } else { 762 } else {
766 [title drawAtPoint:textOffset]; 763 [title drawAtPoint:textOffset];
767 } 764 }
768 } 765 }
769 766
770 if (!shouldClipTheTitle) 767 if (!shouldClipTheTitle)
771 return cellFrame; 768 return cellFrame;
772 769
773 // Draw the gradient part with a transparency layer. This makes the text look 770 // Draw the gradient part with a transparency layer. This makes the text look
774 // suboptimal, but since it fades out, that's ok. 771 // suboptimal, but since it fades out, that's ok.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 options:options 842 options:options
846 owner:self 843 owner:self
847 userInfo:nil]); 844 userInfo:nil]);
848 if (isMouseInside_ != mouseInView) { 845 if (isMouseInside_ != mouseInView) {
849 [self setMouseInside:mouseInView animate:NO]; 846 [self setMouseInside:mouseInView animate:NO];
850 [controlView setNeedsDisplay:YES]; 847 [controlView setNeedsDisplay:YES];
851 } 848 }
852 } 849 }
853 850
854 @end 851 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698