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

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

Issue 1987203003: [Mac][Material Design] Add MD hover to bookmark items in menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uploaded__bookmark_title_baseline_fix
Patch Set: Created 4 years, 7 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/gradient_button_cell.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) 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 break; 539 break;
540 } 540 }
541 if (type == kLeftButtonWithShadowType) 541 if (type == kLeftButtonWithShadowType)
542 innerFrame.size.width -= 1.0; 542 innerFrame.size.width -= 1.0;
543 543
544 // Return results if |return...| not null. 544 // Return results if |return...| not null.
545 if (returnInnerFrame) 545 if (returnInnerFrame)
546 *returnInnerFrame = innerFrame; 546 *returnInnerFrame = innerFrame;
547 if (returnInnerPath) { 547 if (returnInnerPath) {
548 DCHECK(*returnInnerPath == nil); 548 DCHECK(*returnInnerPath == nil);
549 // In Material Design on Retina, nudge the hover background by 1px. 549 drawFrame.origin.y +=
550 if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback && 550 [self hoverBackgroundVerticalOffsetInControlView:controlView];
551 kLineWidth < 1) {
552 drawFrame.origin.y -= kLineWidth;
553 }
554 551
555 *returnInnerPath = [NSBezierPath bezierPathWithRoundedRect:drawFrame 552 *returnInnerPath = [NSBezierPath bezierPathWithRoundedRect:drawFrame
556 xRadius:cornerRadius 553 xRadius:cornerRadius
557 yRadius:cornerRadius]; 554 yRadius:cornerRadius];
558 [*returnInnerPath setLineWidth:kLineWidth]; 555 [*returnInnerPath setLineWidth:kLineWidth];
559 } 556 }
560 if (returnClipPath) { 557 if (returnClipPath) {
561 DCHECK(*returnClipPath == nil); 558 DCHECK(*returnClipPath == nil);
562 NSRect clipPathRect = 559 NSRect clipPathRect =
563 NSInsetRect(drawFrame, -kHalfLineWidth, -kHalfLineWidth); 560 NSInsetRect(drawFrame, -kHalfLineWidth, -kHalfLineWidth);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 fraction:[self isEnabled] ? 1.0 : 0.5 682 fraction:[self isEnabled] ? 1.0 : 0.5
686 respectFlipped:YES 683 respectFlipped:YES
687 hints:nil]; 684 hints:nil];
688 } 685 }
689 } 686 }
690 687
691 - (int)verticalTextOffset { 688 - (int)verticalTextOffset {
692 return 1; 689 return 1;
693 } 690 }
694 691
692 - (CGFloat)hoverBackgroundVerticalOffsetInControlView:(NSView*)controlView {
693 return 0.0;
694 }
695
695 // Overriden from NSButtonCell so we can display a nice fadeout effect for 696 // Overriden from NSButtonCell so we can display a nice fadeout effect for
696 // button titles that overflow. 697 // button titles that overflow.
697 // This method is copied in the most part from GTMFadeTruncatingTextFieldCell, 698 // This method is copied in the most part from GTMFadeTruncatingTextFieldCell,
698 // the only difference is that here we draw the text ourselves rather than 699 // the only difference is that here we draw the text ourselves rather than
699 // calling the super to do the work. 700 // calling the super to do the work.
700 // We can't use GTMFadeTruncatingTextFieldCell because there's no easy way to 701 // We can't use GTMFadeTruncatingTextFieldCell because there's no easy way to
701 // get it to work with NSButtonCell. 702 // get it to work with NSButtonCell.
702 // TODO(jeremy): Move this to GTM. 703 // TODO(jeremy): Move this to GTM.
703 - (NSRect)drawTitle:(NSAttributedString*)title 704 - (NSRect)drawTitle:(NSAttributedString*)title
704 withFrame:(NSRect)cellFrame 705 withFrame:(NSRect)cellFrame
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 options:options 835 options:options
835 owner:self 836 owner:self
836 userInfo:nil]); 837 userInfo:nil]);
837 if (isMouseInside_ != mouseInView) { 838 if (isMouseInside_ != mouseInView) {
838 [self setMouseInside:mouseInView animate:NO]; 839 [self setMouseInside:mouseInView animate:NO];
839 [controlView setNeedsDisplay:YES]; 840 [controlView setNeedsDisplay:YES];
840 } 841 }
841 } 842 }
842 843
843 @end 844 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/gradient_button_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698