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