OLD | NEW |
| (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_REPEAT_CONTROLLER_H_ | |
6 #define VIEWS_REPEAT_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/callback.h" | |
10 #include "base/timer.h" | |
11 | |
12 namespace views { | |
13 | |
14 /////////////////////////////////////////////////////////////////////////////// | |
15 // | |
16 // RepeatController | |
17 // | |
18 // An object that handles auto-repeating UI actions. There is a longer initial | |
19 // delay after which point repeats become constant. Users provide a callback | |
20 // that is notified when each repeat occurs so that they can perform the | |
21 // associated action. | |
22 // | |
23 /////////////////////////////////////////////////////////////////////////////// | |
24 class RepeatController { | |
25 public: | |
26 // The RepeatController takes ownership of this callback object. | |
27 explicit RepeatController(const base::Closure& callback); | |
28 virtual ~RepeatController(); | |
29 | |
30 // Start repeating. | |
31 void Start(); | |
32 | |
33 // Stop repeating. | |
34 void Stop(); | |
35 | |
36 private: | |
37 // Called when the timer expires. | |
38 void Run(); | |
39 | |
40 // The current timer. | |
41 base::OneShotTimer<RepeatController> timer_; | |
42 | |
43 base::Closure callback_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(RepeatController); | |
46 }; | |
47 | |
48 } // namespace views | |
49 | |
50 #endif // #ifndef VIEWS_REPEAT_CONTROLLER_H_ | |
OLD | NEW |