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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 318913002: Fix BrowserActionButton displaying pressed state when mouse is out. There are some special case… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | 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 #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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698