OLD | NEW |
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 VIEWS_MOUSE_WATCHER_H_ | 5 #ifndef VIEWS_MOUSE_WATCHER_H_ |
6 #define VIEWS_MOUSE_WATCHER_H_ | 6 #define VIEWS_MOUSE_WATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Creates a new MouseWatcher. |hot_zone_insets| is added to the bounds of | 30 // Creates a new MouseWatcher. |hot_zone_insets| is added to the bounds of |
31 // the view to determine the active zone. For example, if | 31 // the view to determine the active zone. For example, if |
32 // |hot_zone_insets.bottom()| is 10, then the listener is not notified if | 32 // |hot_zone_insets.bottom()| is 10, then the listener is not notified if |
33 // the y coordinate is between the origin of the view and height of the view | 33 // the y coordinate is between the origin of the view and height of the view |
34 // plus 10. | 34 // plus 10. |
35 MouseWatcher(views::View* host, | 35 MouseWatcher(views::View* host, |
36 MouseWatcherListener* listener, | 36 MouseWatcherListener* listener, |
37 const gfx::Insets& hot_zone_insets); | 37 const gfx::Insets& hot_zone_insets); |
38 ~MouseWatcher(); | 38 ~MouseWatcher(); |
39 | 39 |
| 40 // Sets the amount to delay before notifying the listener when the mouse exits |
| 41 // the view by way of going to another window. |
| 42 void set_notify_on_exit_time_ms(int time) { notify_on_exit_time_ms_ = time; } |
| 43 |
40 // Starts watching mouse movements. When the mouse moves outside the bounds of | 44 // Starts watching mouse movements. When the mouse moves outside the bounds of |
41 // the view the listener is notified. |Start| may be invoked any number of | 45 // the view the listener is notified. |Start| may be invoked any number of |
42 // times. If the mouse moves outside the bounds of the view the listener is | 46 // times. If the mouse moves outside the bounds of the view the listener is |
43 // notified and watcher stops watching events. | 47 // notified and watcher stops watching events. |
44 void Start(); | 48 void Start(); |
45 | 49 |
46 // Stops watching mouse events. | 50 // Stops watching mouse events. |
47 void Stop(); | 51 void Stop(); |
48 | 52 |
49 private: | 53 private: |
50 class Observer; | 54 class Observer; |
51 | 55 |
52 // Are we currently observing events? | 56 // Are we currently observing events? |
53 bool is_observing() const { return observer_.get() != NULL; } | 57 bool is_observing() const { return observer_.get() != NULL; } |
54 | 58 |
55 // Notifies the listener and stops watching events. | 59 // Notifies the listener and stops watching events. |
56 void NotifyListener(); | 60 void NotifyListener(); |
57 | 61 |
58 // View we're listening for events over. | 62 // View we're listening for events over. |
59 views::View* host_; | 63 View* host_; |
60 | 64 |
61 // Our listener. | 65 // Our listener. |
62 MouseWatcherListener* listener_; | 66 MouseWatcherListener* listener_; |
63 | 67 |
64 // Insets added to the bounds of the view. | 68 // Insets added to the bounds of the view. |
65 const gfx::Insets hot_zone_insets_; | 69 const gfx::Insets hot_zone_insets_; |
66 | 70 |
67 // Does the actual work of listening for mouse events. | 71 // Does the actual work of listening for mouse events. |
68 scoped_ptr<Observer> observer_; | 72 scoped_ptr<Observer> observer_; |
69 | 73 |
| 74 // See description above setter. |
| 75 int notify_on_exit_time_ms_; |
| 76 |
70 DISALLOW_COPY_AND_ASSIGN(MouseWatcher); | 77 DISALLOW_COPY_AND_ASSIGN(MouseWatcher); |
71 }; | 78 }; |
72 | 79 |
73 } // namespace views | 80 } // namespace views |
74 | 81 |
75 #endif // VIEWS_MOUSE_WATCHER_H_ | 82 #endif // VIEWS_MOUSE_WATCHER_H_ |
OLD | NEW |