OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_TOUCH_TOUCH_HUD_DEBUG_H_ | 5 #ifndef ASH_TOUCH_TOUCH_HUD_DEBUG_H_ |
6 #define ASH_TOUCH_TOUCH_HUD_DEBUG_H_ | 6 #define ASH_TOUCH_TOUCH_HUD_DEBUG_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 | 12 |
12 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
13 #include "ash/touch/touch_observer_hud.h" | 14 #include "ash/touch/touch_observer_hud.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 class Label; | 19 class Label; |
20 class View; | 20 class View; |
21 } | 21 } |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 class TouchHudCanvas; | 24 class TouchHudCanvas; |
25 class TouchLog; | 25 class TouchLog; |
26 | 26 |
27 // A heads-up display to show touch traces on the screen and log touch events. | 27 // A heads-up display to show touch traces on the screen and log touch events. |
28 // As a derivative of TouchObserverHUD, objects of this class manage their own | 28 // As a derivative of TouchObserverHUD, objects of this class manage their own |
29 // lifetime. | 29 // lifetime. |
30 class ASH_EXPORT TouchHudDebug : public TouchObserverHUD { | 30 class ASH_EXPORT TouchHudDebug : public TouchObserverHUD { |
31 public: | 31 public: |
32 enum Mode { | 32 enum Mode { |
33 FULLSCREEN, | 33 FULLSCREEN, |
34 REDUCED_SCALE, | 34 REDUCED_SCALE, |
35 INVISIBLE, | 35 INVISIBLE, |
36 }; | 36 }; |
37 | 37 |
38 explicit TouchHudDebug(aura::Window* initial_root); | 38 explicit TouchHudDebug(aura::Window* initial_root); |
39 | 39 |
40 // Returns the log of touch events for all displays as a dictionary mapping id | 40 // Returns the log of touch events for all displays as a dictionary mapping id |
41 // of each display to its touch log. | 41 // of each display to its touch log. |
42 static scoped_ptr<base::DictionaryValue> GetAllAsDictionary(); | 42 static std::unique_ptr<base::DictionaryValue> GetAllAsDictionary(); |
43 | 43 |
44 // Changes the display mode (e.g. scale, visibility). Calling this repeatedly | 44 // Changes the display mode (e.g. scale, visibility). Calling this repeatedly |
45 // cycles between a fixed number of display modes. | 45 // cycles between a fixed number of display modes. |
46 void ChangeToNextMode(); | 46 void ChangeToNextMode(); |
47 | 47 |
48 // Returns log of touch events as a list value. Each item in the list is a | 48 // Returns log of touch events as a list value. Each item in the list is a |
49 // trace of one touch point. | 49 // trace of one touch point. |
50 scoped_ptr<base::ListValue> GetLogAsList() const; | 50 std::unique_ptr<base::ListValue> GetLogAsList() const; |
51 | 51 |
52 Mode mode() const { return mode_; } | 52 Mode mode() const { return mode_; } |
53 | 53 |
54 // Overriden from TouchObserverHUD. | 54 // Overriden from TouchObserverHUD. |
55 void Clear() override; | 55 void Clear() override; |
56 | 56 |
57 private: | 57 private: |
58 ~TouchHudDebug() override; | 58 ~TouchHudDebug() override; |
59 | 59 |
60 void SetMode(Mode mode); | 60 void SetMode(Mode mode); |
61 | 61 |
62 void UpdateTouchPointLabel(int index); | 62 void UpdateTouchPointLabel(int index); |
63 | 63 |
64 // Overriden from TouchObserverHUD. | 64 // Overriden from TouchObserverHUD. |
65 void OnTouchEvent(ui::TouchEvent* event) override; | 65 void OnTouchEvent(ui::TouchEvent* event) override; |
66 void OnDisplayMetricsChanged(const gfx::Display& display, | 66 void OnDisplayMetricsChanged(const gfx::Display& display, |
67 uint32_t metrics) override; | 67 uint32_t metrics) override; |
68 void SetHudForRootWindowController(RootWindowController* controller) override; | 68 void SetHudForRootWindowController(RootWindowController* controller) override; |
69 void UnsetHudForRootWindowController( | 69 void UnsetHudForRootWindowController( |
70 RootWindowController* controller) override; | 70 RootWindowController* controller) override; |
71 | 71 |
72 static const int kMaxTouchPoints = 32; | 72 static const int kMaxTouchPoints = 32; |
73 | 73 |
74 Mode mode_; | 74 Mode mode_; |
75 | 75 |
76 scoped_ptr<TouchLog> touch_log_; | 76 std::unique_ptr<TouchLog> touch_log_; |
77 | 77 |
78 TouchHudCanvas* canvas_; | 78 TouchHudCanvas* canvas_; |
79 views::View* label_container_; | 79 views::View* label_container_; |
80 views::Label* touch_labels_[kMaxTouchPoints]; | 80 views::Label* touch_labels_[kMaxTouchPoints]; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(TouchHudDebug); | 82 DISALLOW_COPY_AND_ASSIGN(TouchHudDebug); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace ash | 85 } // namespace ash |
86 | 86 |
87 #endif // ASH_TOUCH_TOUCH_HUD_DEBUG_H_ | 87 #endif // ASH_TOUCH_TOUCH_HUD_DEBUG_H_ |
OLD | NEW |