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