OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_COCOA_RELOAD_BUTTON_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_RELOAD_BUTTON_H_ | |
7 #pragma once | |
8 | |
9 #import <Cocoa/Cocoa.h> | |
10 | |
11 #import "base/scoped_nsobject.h" | |
12 | |
13 // NSButton subclass which defers certain state changes when the mouse | |
14 // is hovering over it. | |
15 | |
16 @interface ReloadButton : NSButton { | |
17 @private | |
18 // Tracks whether the mouse is hovering for purposes of not making | |
19 // unexpected state changes. | |
20 BOOL isMouseInside_; | |
21 scoped_nsobject<NSTrackingArea> trackingArea_; | |
22 | |
23 // Timer used when setting reload mode while the mouse is hovered. | |
24 scoped_nsobject<NSTimer> pendingReloadTimer_; | |
25 } | |
26 | |
27 // Returns YES if the mouse is currently inside the bounds. | |
28 - (BOOL)isMouseInside; | |
29 | |
30 // Update the tag, and the image and tooltip to match. If |anInt| | |
31 // matches the current tag, no action is taken. |anInt| must be | |
32 // either |IDC_STOP| or |IDC_RELOAD|. | |
33 - (void)updateTag:(NSInteger)anInt; | |
34 | |
35 // Update the button to be a reload button or stop button depending on | |
36 // |isLoading|. If |force|, always sets the indicated mode. If | |
37 // |!force|, and the mouse is over the button, defer the transition | |
38 // from stop button to reload button until the mouse has left the | |
39 // button, or until |pendingReloadTimer_| fires. This prevents an | |
40 // inadvertent click _just_ as the state changes. | |
41 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force; | |
42 | |
43 @end | |
44 | |
45 @interface ReloadButton (PrivateTestingMethods) | |
46 + (void)setPendingReloadTimeout:(NSTimeInterval)seconds; | |
47 - (NSTrackingArea*)trackingArea; | |
48 @end | |
49 | |
50 #endif // CHROME_BROWSER_UI_COCOA_RELOAD_BUTTON_H_ | |
OLD | NEW |