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

Side by Side Diff: views/mouse_watcher.h

Issue 8735009: views: Move some random files from views/ to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « views/metrics_win.cc ('k') | views/mouse_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef VIEWS_MOUSE_WATCHER_H_
6 #define VIEWS_MOUSE_WATCHER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/insets.h"
12 #include "views/views_export.h"
13
14 namespace views {
15
16 class View;
17
18 // MouseWatcherListener is notified when the mouse moves outside the view.
19 class VIEWS_EXPORT MouseWatcherListener {
20 public:
21 virtual void MouseMovedOutOfView() = 0;
22
23 protected:
24 virtual ~MouseWatcherListener();
25 };
26
27 // MouseWatcher is used to watch mouse movement and notify its listener when the
28 // mouse moves outside the bounds of a view.
29 class VIEWS_EXPORT MouseWatcher {
30 public:
31 // Creates a new MouseWatcher. |hot_zone_insets| is added to the bounds of
32 // the view to determine the active zone. For example, if
33 // |hot_zone_insets.bottom()| is 10, then the listener is not notified if
34 // the y coordinate is between the origin of the view and height of the view
35 // plus 10.
36 MouseWatcher(views::View* host,
37 MouseWatcherListener* listener,
38 const gfx::Insets& hot_zone_insets);
39 ~MouseWatcher();
40
41 // Sets the amount to delay before notifying the listener when the mouse exits
42 // the view by way of going to another window.
43 void set_notify_on_exit_time_ms(int time) { notify_on_exit_time_ms_ = time; }
44
45 // Starts watching mouse movements. When the mouse moves outside the bounds of
46 // the view the listener is notified. |Start| may be invoked any number of
47 // times. If the mouse moves outside the bounds of the view the listener is
48 // notified and watcher stops watching events.
49 void Start();
50
51 // Stops watching mouse events.
52 void Stop();
53
54 private:
55 class Observer;
56
57 // Are we currently observing events?
58 bool is_observing() const { return observer_.get() != NULL; }
59
60 // Notifies the listener and stops watching events.
61 void NotifyListener();
62
63 // View we're listening for events over.
64 View* host_;
65
66 // Our listener.
67 MouseWatcherListener* listener_;
68
69 // Insets added to the bounds of the view.
70 const gfx::Insets hot_zone_insets_;
71
72 // Does the actual work of listening for mouse events.
73 scoped_ptr<Observer> observer_;
74
75 // See description above setter.
76 int notify_on_exit_time_ms_;
77
78 DISALLOW_COPY_AND_ASSIGN(MouseWatcher);
79 };
80
81 } // namespace views
82
83 #endif // VIEWS_MOUSE_WATCHER_H_
OLDNEW
« no previous file with comments | « views/metrics_win.cc ('k') | views/mouse_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698