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 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 return self; | 176 return self; |
177 } | 177 } |
178 | 178 |
179 - (BOOL)acceptsFirstResponder { | 179 - (BOOL)acceptsFirstResponder { |
180 return YES; | 180 return YES; |
181 } | 181 } |
182 | 182 |
183 - (void)mouseDown:(NSEvent*)theEvent { | 183 - (void)mouseDown:(NSEvent*)theEvent { |
184 [[self cell] setHighlighted:YES]; | 184 NSPoint location = [self convertPoint:[theEvent locationInWindow] |
185 dragCouldStart_ = YES; | 185 fromView:nil]; |
186 dragStartPoint_ = [theEvent locationInWindow]; | 186 if (NSPointInRect(location, [self bounds])) { |
| 187 [[self cell] setHighlighted:YES]; |
| 188 dragCouldStart_ = YES; |
| 189 dragStartPoint_ = [theEvent locationInWindow]; |
| 190 } |
187 } | 191 } |
188 | 192 |
189 - (void)mouseDragged:(NSEvent*)theEvent { | 193 - (void)mouseDragged:(NSEvent*)theEvent { |
190 if (!dragCouldStart_) | 194 if (!dragCouldStart_) |
191 return; | 195 return; |
192 | 196 |
193 if (!isBeingDragged_) { | 197 if (!isBeingDragged_) { |
194 // Don't initiate a drag until it moves at least kMinimumDragDistance. | 198 // Don't initiate a drag until it moves at least kMinimumDragDistance. |
195 NSPoint currentPoint = [theEvent locationInWindow]; | 199 NSPoint currentPoint = [theEvent locationInWindow]; |
196 CGFloat dx = currentPoint.x - dragStartPoint_.x; | 200 CGFloat dx = currentPoint.x - dragStartPoint_.x; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 operation:NSCompositeSourceOver | 353 operation:NSCompositeSourceOver |
350 fraction:enabled ? 1.0 : 0.4 | 354 fraction:enabled ? 1.0 : 0.4 |
351 respectFlipped:YES | 355 respectFlipped:YES |
352 hints:nil]; | 356 hints:nil]; |
353 | 357 |
354 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; | 358 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; |
355 [self drawBadgeWithinFrame:cellFrame]; | 359 [self drawBadgeWithinFrame:cellFrame]; |
356 } | 360 } |
357 | 361 |
358 @end | 362 @end |
OLD | NEW |