Swap touch HUD when switching primary display
[chromium-blink-merge.git] / ash / touch / touch_observer_hud.h
blob1a79015b8c911a6c66d95968f413b8d31a7988c4
1 // Copyright (c) 2012 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.
5 #ifndef ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
6 #define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
8 #include "ash/ash_export.h"
9 #include "ash/display/display_controller.h"
10 #include "ash/shell.h"
11 #include "base/values.h"
12 #include "ui/base/events/event_handler.h"
13 #include "ui/gfx/display_observer.h"
14 #include "ui/gfx/point.h"
15 #include "ui/views/widget/widget_observer.h"
17 #if defined(OS_CHROMEOS)
18 #include "chromeos/display/output_configurator.h"
19 #endif // defined(OS_CHROMEOS)
21 namespace aura {
22 class Window;
25 namespace gfx {
26 class Display;
29 namespace views {
30 class Label;
31 class View;
32 class Widget;
35 namespace ash {
36 namespace internal {
38 class TouchHudCanvas;
40 // An event filter which handles system level gesture events. Objects of this
41 // class manage their own lifetime.
42 class ASH_EXPORT TouchObserverHUD
43 : public ui::EventHandler,
44 public views::WidgetObserver,
45 public gfx::DisplayObserver,
46 #if defined(OS_CHROMEOS)
47 public chromeos::OutputConfigurator::Observer,
48 #endif // defined(OS_CHROMEOS)
49 public DisplayController::Observer {
50 public:
51 explicit TouchObserverHUD(aura::RootWindow* initial_root);
53 // Returns the log of touch events as a dictionary mapping id of each display
54 // to its touch log.
55 static scoped_ptr<DictionaryValue> GetAllAsDictionary();
57 // Changes the display mode (e.g. scale, visibility). Calling this repeatedly
58 // cycles between a fixed number of display modes.
59 void ChangeToNextMode();
61 // Removes all existing touch points from the screen (only if the HUD is
62 // visible).
63 void Clear();
65 // Returns log of touch events as a list value. Each item in the list is a
66 // trace of one touch point.
67 scoped_ptr<ListValue> GetLogAsList() const;
69 private:
70 friend class TouchHudTest;
72 virtual ~TouchObserverHUD();
74 void UpdateTouchPointLabel(int index);
76 // Overriden from ui::EventHandler:
77 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
79 // Overridden from views::WidgetObserver:
80 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
82 // Overridden from gfx::DisplayObserver:
83 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
84 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
85 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
87 #if defined(OS_CHROMEOS)
88 // Overriden from chromeos::OutputConfigurator::Observer:
89 virtual void OnDisplayModeChanged() OVERRIDE;
90 #endif // defined(OS_CHROMEOS)
92 // Overriden form DisplayController::Observer:
93 virtual void OnDisplayConfigurationChanging() OVERRIDE;
94 virtual void OnDisplayConfigurationChanged() OVERRIDE;
96 static const int kMaxTouchPoints = 32;
98 const int64 display_id_;
99 aura::RootWindow* root_window_;
101 views::Widget* widget_;
102 TouchHudCanvas* canvas_;
103 views::View* label_container_;
104 views::Label* touch_labels_[kMaxTouchPoints];
105 gfx::Point touch_positions_[kMaxTouchPoints];
106 float touch_radius_[kMaxTouchPoints];
107 ui::EventType touch_status_[kMaxTouchPoints];
109 DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD);
112 } // namespace internal
113 } // namespace ash
115 #endif // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_