Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/cocoa/new_tab_button.h"

@implementation NewTabButton

// Approximate the shape. It doesn't need to be perfect. This will need to be
// updated if the size or shape of the icon ever changes.
// TODO(pinkerton): use a click mask image instead of hard-coding points.
- (NSBezierPath*)pathForButton {
  if (imagePath_.get())
    return imagePath_.get();

  // Cache the path as it doesn't change (the coordinates are local to this
  // view). There's not much point making constants for these, as they are
  // custom.
  imagePath_.reset([[NSBezierPath bezierPath] retain]);
  [imagePath_ moveToPoint:NSMakePoint(9, 7)];
  [imagePath_ lineToPoint:NSMakePoint(26, 7)];
  [imagePath_ lineToPoint:NSMakePoint(33, 23)];
  [imagePath_ lineToPoint:NSMakePoint(14, 23)];
  [imagePath_ lineToPoint:NSMakePoint(9, 7)];
  return imagePath_;

// Override to only accept clicks within the bounds of the defined path, not
// the entire bounding box. |aPoint| is in the superview's coordinate system.
- (NSView*)hitTest:(NSPoint)aPoint {
  NSBezierPath* buttonPath = [self pathForButton];
  NSPoint localPoint = [self convertPoint:aPoint fromView:[self superview]];
  if ([buttonPath containsPoint:localPoint])
    return [super hitTest:aPoint];
  return nil;


Generated by  Doxygen 1.6.0   Back to index