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

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

Issue 2013523005: [Mac][Material Design] Bring bookmark hover state, etc. up to spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo, fix chevron button highlight state. Created 4 years, 6 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/bookmarks/bookmark_button_cell.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) 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 defaultGradient:(NSGradient*)defaultGradient { 370 defaultGradient:(NSGradient*)defaultGradient {
371 // For Material Design, draw a solid rounded rect behind the button, based on 371 // For Material Design, draw a solid rounded rect behind the button, based on
372 // the hover and pressed states. 372 // the hover and pressed states.
373 if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback) { 373 if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback) {
374 const CGFloat kEightPercentAlpha = 0.08; 374 const CGFloat kEightPercentAlpha = 0.08;
375 const CGFloat kFourPercentAlpha = 0.04; 375 const CGFloat kFourPercentAlpha = 0.04;
376 376
377 // The alpha is always at least 8%. Default the color to black. 377 // The alpha is always at least 8%. Default the color to black.
378 CGFloat alpha = kEightPercentAlpha; 378 CGFloat alpha = kEightPercentAlpha;
379 CGFloat color = 0.0; 379 CGFloat color = 0.0;
380 // If a dark theme, incrase the opacity slightly and use white. 380
381 // If a dark theme, increase the opacity slightly and use white.
381 if ([[controlView window] hasDarkTheme]) { 382 if ([[controlView window] hasDarkTheme]) {
382 alpha += kFourPercentAlpha; 383 alpha += kFourPercentAlpha;
383 color = 1.0; 384 color = 1.0;
384 } 385 }
385 // If clicked or highlighted, the background is slightly more opaque. If not 386 // If clicked or highlighted, the background is slightly more opaque. If not
386 // clicked or highlighted, adjust the alpha by the animation fade in 387 // clicked or highlighted, adjust the alpha by the animation fade in
387 // percentage. 388 // percentage.
388 if (showClickedGradient || showHighlightGradient) { 389 if (showClickedGradient || showHighlightGradient) {
389 alpha += kFourPercentAlpha; 390 alpha += kFourPercentAlpha;
390 } else { 391 } else {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // TODO(viettrungluu): clean this up. 507 // TODO(viettrungluu): clean this up.
507 // (Private) 508 // (Private)
508 - (void)getDrawParamsForFrame:(NSRect)cellFrame 509 - (void)getDrawParamsForFrame:(NSRect)cellFrame
509 inView:(NSView*)controlView 510 inView:(NSView*)controlView
510 innerFrame:(NSRect*)returnInnerFrame 511 innerFrame:(NSRect*)returnInnerFrame
511 innerPath:(NSBezierPath**)returnInnerPath 512 innerPath:(NSBezierPath**)returnInnerPath
512 clipPath:(NSBezierPath**)returnClipPath { 513 clipPath:(NSBezierPath**)returnClipPath {
513 const CGFloat kLineWidth = [controlView cr_lineWidth]; 514 const CGFloat kLineWidth = [controlView cr_lineWidth];
514 const CGFloat kHalfLineWidth = kLineWidth / 2.0; 515 const CGFloat kHalfLineWidth = kLineWidth / 2.0;
515 516
516 NSRect drawFrame = cellFrame; 517 NSRect drawFrame = NSZeroRect;
517 NSRect innerFrame = NSInsetRect(cellFrame, kLineWidth, kLineWidth); 518 NSRect innerFrame = NSZeroRect;
518 CGFloat cornerRadius = 2; 519 CGFloat cornerRadius = 2;
519 if ([self tag] != kMaterialStandardButtonTypeWithLimitedClickFeedback) { 520 if ([self tag] != kMaterialStandardButtonTypeWithLimitedClickFeedback) {
520 drawFrame = NSInsetRect(cellFrame, 1.5 * kLineWidth, 1.5 * kLineWidth); 521 drawFrame = NSInsetRect(cellFrame, 1.5 * kLineWidth, 1.5 * kLineWidth);
522 innerFrame = NSInsetRect(cellFrame, kLineWidth, kLineWidth);
521 cornerRadius = 3; 523 cornerRadius = 3;
524 } else {
525 drawFrame = cellFrame;
526 // Hover and click paths are always 20pt tall, regardless of the button's
527 // height.
528 drawFrame.size.height = 20;
529 innerFrame = NSInsetRect(drawFrame, kLineWidth, kLineWidth);
522 } 530 }
523 531
524 ButtonType type = [[(NSControl*)controlView cell] tag]; 532 ButtonType type = [[(NSControl*)controlView cell] tag];
525 switch (type) { 533 switch (type) {
526 case kMiddleButtonType: 534 case kMiddleButtonType:
527 drawFrame.size.width += 20; 535 drawFrame.size.width += 20;
528 innerFrame.size.width += 2; 536 innerFrame.size.width += 2;
529 // Fallthrough 537 // Fallthrough
530 case kRightButtonType: 538 case kRightButtonType:
531 drawFrame.origin.x -= 20; 539 drawFrame.origin.x -= 20;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 options:options 843 options:options
836 owner:self 844 owner:self
837 userInfo:nil]); 845 userInfo:nil]);
838 if (isMouseInside_ != mouseInView) { 846 if (isMouseInside_ != mouseInView) {
839 [self setMouseInside:mouseInView animate:NO]; 847 [self setMouseInside:mouseInView animate:NO];
840 [controlView setNeedsDisplay:YES]; 848 [controlView setNeedsDisplay:YES];
841 } 849 }
842 } 850 }
843 851
844 @end 852 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698