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

Side by Side Diff: chrome/browser/cocoa/menu_tracked_button.h

Issue 3137013: [Mac] Implement highlight-on-hover for the Wrench menu buttons. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_ 5 #ifndef CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_
6 #define CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_ 6 #define CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 10
11 // A MenuTrackedButton is meant to be used whenever a button is placed inside 11 // A MenuTrackedButton is meant to be used whenever a button is placed inside
12 // the custom view of an NSMenuItem. If the user opens the menu in a non-sticky 12 // the custom view of an NSMenuItem. If the user opens the menu in a non-sticky
13 // fashion (i.e. clicks, holds, and drags) and then releases the mouse over 13 // fashion (i.e. clicks, holds, and drags) and then releases the mouse over
14 // a MenuTrackedButton, it will |-performClick:| itself. 14 // a MenuTrackedButton, it will |-performClick:| itself.
15 //
16 // To create the hover state effects, there are two code paths. When the menu
17 // is opened sticky, a tracking rect produces mouse entered/exit events that
18 // allow for setting the cell's highlight property. When in a drag cycle,
19 // however, the only event received is |-mouseDragged:|. Therefore, a
20 // delayed selector is scheduled to poll the mouse location after each drag
21 // event. This checks if the user is still over the button after the drag
22 // events stop being sent, indicating either the user is hovering without
23 // movement or that the mouse is no longer over the receiver.
15 @interface MenuTrackedButton : NSButton { 24 @interface MenuTrackedButton : NSButton {
16 @private 25 @private
17 // If the button received a |-mouseEntered:| event. This short-circuits the 26 // If the button received a |-mouseEntered:| event. This short-circuits the
18 // custom drag tracking logic. 27 // custom drag tracking logic.
19 BOOL didEnter_; 28 BOOL didEnter_;
20 29
21 // Whether or not the user is in a click-drag-release event sequence. If so 30 // Whether or not the user is in a click-drag-release event sequence. If so
22 // and this receives a |-mouseUp:|, then this will click itself. 31 // and this receives a |-mouseUp:|, then this will click itself.
23 BOOL tracking_; 32 BOOL tracking_;
33
34 // In order to get hover effects when the menu is sticky-opened, a tracking
35 // rect needs to be installed on the button.
36 NSTrackingRectTag trackingTag_;
24 } 37 }
25 38
26 @end 39 @end
27 40
28 #endif // CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_ 41 #endif // CHROME_BROWSER_COCOA_MENU_TRACKED_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/menu_tracked_button.mm » ('j') | chrome/browser/cocoa/menu_tracked_button.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698