| OLD | NEW |
| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // TODO(viettrungluu): clean this up. | 506 // TODO(viettrungluu): clean this up. |
| 507 // (Private) | 507 // (Private) |
| 508 - (void)getDrawParamsForFrame:(NSRect)cellFrame | 508 - (void)getDrawParamsForFrame:(NSRect)cellFrame |
| 509 inView:(NSView*)controlView | 509 inView:(NSView*)controlView |
| 510 innerFrame:(NSRect*)returnInnerFrame | 510 innerFrame:(NSRect*)returnInnerFrame |
| 511 innerPath:(NSBezierPath**)returnInnerPath | 511 innerPath:(NSBezierPath**)returnInnerPath |
| 512 clipPath:(NSBezierPath**)returnClipPath { | 512 clipPath:(NSBezierPath**)returnClipPath { |
| 513 const CGFloat kLineWidth = [controlView cr_lineWidth]; | 513 const CGFloat kLineWidth = [controlView cr_lineWidth]; |
| 514 const CGFloat kHalfLineWidth = kLineWidth / 2.0; | 514 const CGFloat kHalfLineWidth = kLineWidth / 2.0; |
| 515 | 515 |
| 516 NSRect drawFrame = NSZeroRect; | 516 NSRect drawFrame = cellFrame; |
| 517 NSRect innerFrame = NSZeroRect; | 517 NSRect innerFrame = NSInsetRect(cellFrame, kLineWidth, kLineWidth); |
| 518 CGFloat cornerRadius = 2; | 518 CGFloat cornerRadius = 2; |
| 519 if ([self tag] != kMaterialStandardButtonTypeWithLimitedClickFeedback) { | 519 if ([self tag] != kMaterialStandardButtonTypeWithLimitedClickFeedback) { |
| 520 drawFrame = NSInsetRect(cellFrame, 1.5 * kLineWidth, 1.5 * kLineWidth); | 520 drawFrame = NSInsetRect(cellFrame, 1.5 * kLineWidth, 1.5 * kLineWidth); |
| 521 innerFrame = NSInsetRect(cellFrame, kLineWidth, kLineWidth); | |
| 522 cornerRadius = 3; | 521 cornerRadius = 3; |
| 523 } else { | |
| 524 drawFrame = cellFrame; | |
| 525 // Hover and click paths are always 20pt tall, regardless of the button's | |
| 526 // height. | |
| 527 drawFrame.size.height = 20; | |
| 528 innerFrame = NSInsetRect(drawFrame, kLineWidth, kLineWidth); | |
| 529 } | 522 } |
| 530 | 523 |
| 531 ButtonType type = [[(NSControl*)controlView cell] tag]; | 524 ButtonType type = [[(NSControl*)controlView cell] tag]; |
| 532 switch (type) { | 525 switch (type) { |
| 533 case kMiddleButtonType: | 526 case kMiddleButtonType: |
| 534 drawFrame.size.width += 20; | 527 drawFrame.size.width += 20; |
| 535 innerFrame.size.width += 2; | 528 innerFrame.size.width += 2; |
| 536 // Fallthrough | 529 // Fallthrough |
| 537 case kRightButtonType: | 530 case kRightButtonType: |
| 538 drawFrame.origin.x -= 20; | 531 drawFrame.origin.x -= 20; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 options:options | 835 options:options |
| 843 owner:self | 836 owner:self |
| 844 userInfo:nil]); | 837 userInfo:nil]); |
| 845 if (isMouseInside_ != mouseInView) { | 838 if (isMouseInside_ != mouseInView) { |
| 846 [self setMouseInside:mouseInView animate:NO]; | 839 [self setMouseInside:mouseInView animate:NO]; |
| 847 [controlView setNeedsDisplay:YES]; | 840 [controlView setNeedsDisplay:YES]; |
| 848 } | 841 } |
| 849 } | 842 } |
| 850 | 843 |
| 851 @end | 844 @end |
| OLD | NEW |