| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_OBSERVER_HUD_H_ | 5 #ifndef ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ |
| 6 #define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ | 6 #define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "ui/base/events/event_handler.h" | 13 #include "ui/base/events/event_handler.h" |
| 13 #include "ui/gfx/display_observer.h" | 14 #include "ui/gfx/display_observer.h" |
| 14 #include "ui/gfx/point.h" | 15 #include "ui/gfx/point.h" |
| 15 #include "ui/views/widget/widget_observer.h" | 16 #include "ui/views/widget/widget_observer.h" |
| 16 | 17 |
| 17 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 18 #include "chromeos/display/output_configurator.h" | 19 #include "chromeos/display/output_configurator.h" |
| 19 #endif // defined(OS_CHROMEOS) | 20 #endif // defined(OS_CHROMEOS) |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 class Window; | 23 class Window; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace gfx { | 26 namespace gfx { |
| 26 class Display; | 27 class Display; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace views { | 30 namespace views { |
| 30 class Label; | 31 class Label; |
| 31 class View; | 32 class View; |
| 32 class Widget; | 33 class Widget; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace ash { | 36 namespace ash { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 class TouchHudCanvas; | 39 class TouchHudCanvas; |
| 40 class TouchLog; |
| 39 | 41 |
| 40 // An event filter which handles system level gesture events. Objects of this | 42 // An event filter which handles system level gesture events. Objects of this |
| 41 // class manage their own lifetime. | 43 // class manage their own lifetime. |
| 42 class ASH_EXPORT TouchObserverHUD | 44 class ASH_EXPORT TouchObserverHUD |
| 43 : public ui::EventHandler, | 45 : public ui::EventHandler, |
| 44 public views::WidgetObserver, | 46 public views::WidgetObserver, |
| 45 public gfx::DisplayObserver, | 47 public gfx::DisplayObserver, |
| 46 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 47 public chromeos::OutputConfigurator::Observer, | 49 public chromeos::OutputConfigurator::Observer, |
| 48 #endif // defined(OS_CHROMEOS) | 50 #endif // defined(OS_CHROMEOS) |
| 49 public DisplayController::Observer { | 51 public DisplayController::Observer { |
| 50 public: | 52 public: |
| 53 enum Mode { |
| 54 FULLSCREEN, |
| 55 REDUCED_SCALE, |
| 56 PROJECTION, |
| 57 INVISIBLE, |
| 58 }; |
| 59 |
| 51 explicit TouchObserverHUD(aura::RootWindow* initial_root); | 60 explicit TouchObserverHUD(aura::RootWindow* initial_root); |
| 52 | 61 |
| 53 // Returns the log of touch events as a dictionary mapping id of each display | 62 // Returns the log of touch events as a dictionary mapping id of each display |
| 54 // to its touch log. | 63 // to its touch log. |
| 55 static scoped_ptr<DictionaryValue> GetAllAsDictionary(); | 64 static scoped_ptr<DictionaryValue> GetAllAsDictionary(); |
| 56 | 65 |
| 57 // Changes the display mode (e.g. scale, visibility). Calling this repeatedly | 66 // Changes the display mode (e.g. scale, visibility). Calling this repeatedly |
| 58 // cycles between a fixed number of display modes. | 67 // cycles between a fixed number of display modes. |
| 59 void ChangeToNextMode(); | 68 void ChangeToNextMode(); |
| 60 | 69 |
| 61 // Removes all existing touch points from the screen (only if the HUD is | 70 // Removes all existing touch points from the screen (only if the HUD is |
| 62 // visible). | 71 // visible). |
| 63 void Clear(); | 72 void Clear(); |
| 64 | 73 |
| 65 // Returns log of touch events as a list value. Each item in the list is a | 74 // Returns log of touch events as a list value. Each item in the list is a |
| 66 // trace of one touch point. | 75 // trace of one touch point. |
| 67 scoped_ptr<ListValue> GetLogAsList() const; | 76 scoped_ptr<ListValue> GetLogAsList() const; |
| 68 | 77 |
| 78 Mode mode() const { return mode_; } |
| 79 |
| 69 private: | 80 private: |
| 70 friend class TouchHudTest; | 81 friend class TouchHudTest; |
| 71 | 82 |
| 72 virtual ~TouchObserverHUD(); | 83 virtual ~TouchObserverHUD(); |
| 73 | 84 |
| 85 void SetMode(Mode mode); |
| 86 |
| 74 void UpdateTouchPointLabel(int index); | 87 void UpdateTouchPointLabel(int index); |
| 75 | 88 |
| 76 // Overriden from ui::EventHandler: | 89 // Overriden from ui::EventHandler: |
| 77 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 90 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
| 78 | 91 |
| 79 // Overridden from views::WidgetObserver: | 92 // Overridden from views::WidgetObserver: |
| 80 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 93 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
| 81 | 94 |
| 82 // Overridden from gfx::DisplayObserver: | 95 // Overridden from gfx::DisplayObserver: |
| 83 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | 96 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; |
| 84 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; | 97 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; |
| 85 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; | 98 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; |
| 86 | 99 |
| 87 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
| 88 // Overriden from chromeos::OutputConfigurator::Observer: | 101 // Overriden from chromeos::OutputConfigurator::Observer: |
| 89 virtual void OnDisplayModeChanged() OVERRIDE; | 102 virtual void OnDisplayModeChanged() OVERRIDE; |
| 90 #endif // defined(OS_CHROMEOS) | 103 #endif // defined(OS_CHROMEOS) |
| 91 | 104 |
| 92 // Overriden form DisplayController::Observer: | 105 // Overriden form DisplayController::Observer: |
| 93 virtual void OnDisplayConfigurationChanging() OVERRIDE; | 106 virtual void OnDisplayConfigurationChanging() OVERRIDE; |
| 94 virtual void OnDisplayConfigurationChanged() OVERRIDE; | 107 virtual void OnDisplayConfigurationChanged() OVERRIDE; |
| 95 | 108 |
| 96 static const int kMaxTouchPoints = 32; | 109 static const int kMaxTouchPoints = 32; |
| 97 | 110 |
| 98 const int64 display_id_; | 111 const int64 display_id_; |
| 99 aura::RootWindow* root_window_; | 112 aura::RootWindow* root_window_; |
| 100 | 113 |
| 114 Mode mode_; |
| 115 |
| 116 scoped_ptr<TouchLog> touch_log_; |
| 117 |
| 101 views::Widget* widget_; | 118 views::Widget* widget_; |
| 102 TouchHudCanvas* canvas_; | 119 TouchHudCanvas* canvas_; |
| 103 views::View* label_container_; | 120 views::View* label_container_; |
| 104 views::Label* touch_labels_[kMaxTouchPoints]; | 121 views::Label* touch_labels_[kMaxTouchPoints]; |
| 105 gfx::Point touch_positions_[kMaxTouchPoints]; | |
| 106 float touch_radius_[kMaxTouchPoints]; | |
| 107 ui::EventType touch_status_[kMaxTouchPoints]; | |
| 108 | 122 |
| 109 DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD); | 123 DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD); |
| 110 }; | 124 }; |
| 111 | 125 |
| 112 } // namespace internal | 126 } // namespace internal |
| 113 } // namespace ash | 127 } // namespace ash |
| 114 | 128 |
| 115 #endif // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ | 129 #endif // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ |
| OLD | NEW |