| 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 UI_VIEWS_WIDGET_ROOT_VIEW_H_ | 5 #ifndef UI_VIEWS_WIDGET_ROOT_VIEW_H_ |
| 6 #define UI_VIEWS_WIDGET_ROOT_VIEW_H_ | 6 #define UI_VIEWS_WIDGET_ROOT_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "ui/views/focus/focus_manager.h" | 12 #include "ui/views/focus/focus_manager.h" |
| 13 #include "ui/views/focus/focus_search.h" | 13 #include "ui/views/focus/focus_search.h" |
| 14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 enum TouchStatus; | 17 enum TouchStatus; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 class Widget; | 22 class Widget; |
| 23 class GestureManager; | 23 class GestureManager; |
| 24 class GestureRecognizer; |
| 24 | 25 |
| 25 // This is a views-internal API and should not be used externally. | 26 // This is a views-internal API and should not be used externally. |
| 26 // Widget exposes this object as a View*. | 27 // Widget exposes this object as a View*. |
| 27 namespace internal { | 28 namespace internal { |
| 28 | 29 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 30 // RootView class | 31 // RootView class |
| 31 // | 32 // |
| 32 // The RootView is the root of a View hierarchy. A RootView is attached to a | 33 // The RootView is the root of a View hierarchy. A RootView is attached to a |
| 33 // Widget. The Widget is responsible for receiving events from the host | 34 // Widget. The Widget is responsible for receiving events from the host |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 | 65 |
| 65 // Input --------------------------------------------------------------------- | 66 // Input --------------------------------------------------------------------- |
| 66 | 67 |
| 67 // Process a key event. Send the event to the focused view and up the focus | 68 // Process a key event. Send the event to the focused view and up the focus |
| 68 // path, and finally to the default keyboard handler, until someone consumes | 69 // path, and finally to the default keyboard handler, until someone consumes |
| 69 // it. Returns whether anyone consumed the event. | 70 // it. Returns whether anyone consumed the event. |
| 70 bool OnKeyEvent(const KeyEvent& event); | 71 bool OnKeyEvent(const KeyEvent& event); |
| 71 | 72 |
| 72 // Provided only for testing: | 73 // Provided only for testing: |
| 73 void SetGestureManagerForTesting(GestureManager* g) { gesture_manager_ = g; } | 74 void SetGestureManagerForTesting(GestureManager* g) { gesture_manager_ = g; } |
| 75 void SetGestureRecognizerForTesting(GestureRecognizer* gr) { |
| 76 gesture_recognizer_ = gr; |
| 77 } |
| 74 | 78 |
| 75 // Focus --------------------------------------------------------------------- | 79 // Focus --------------------------------------------------------------------- |
| 76 | 80 |
| 77 // Used to set the FocusTraversable parent after the view has been created | 81 // Used to set the FocusTraversable parent after the view has been created |
| 78 // (typically when the hierarchy changes and this RootView is added/removed). | 82 // (typically when the hierarchy changes and this RootView is added/removed). |
| 79 virtual void SetFocusTraversableParent(FocusTraversable* focus_traversable); | 83 virtual void SetFocusTraversableParent(FocusTraversable* focus_traversable); |
| 80 | 84 |
| 81 // Used to set the View parent after the view has been created. | 85 // Used to set the View parent after the view has been created. |
| 82 virtual void SetFocusTraversableParentView(View* view); | 86 virtual void SetFocusTraversableParentView(View* view); |
| 83 | 87 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 virtual std::string GetClassName() const OVERRIDE; | 107 virtual std::string GetClassName() const OVERRIDE; |
| 104 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | 108 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; |
| 105 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 109 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
| 106 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 110 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
| 107 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 111 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
| 108 virtual void OnMouseCaptureLost() OVERRIDE; | 112 virtual void OnMouseCaptureLost() OVERRIDE; |
| 109 virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; | 113 virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; |
| 110 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; | 114 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; |
| 111 virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; | 115 virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; |
| 112 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 116 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 117 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
| 113 virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE; | 118 virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE; |
| 114 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 119 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 115 virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; | 120 virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; |
| 116 | 121 |
| 117 protected: | 122 protected: |
| 118 // Overridden from View: | 123 // Overridden from View: |
| 119 virtual void ViewHierarchyChanged(bool is_add, View* parent, | 124 virtual void ViewHierarchyChanged(bool is_add, View* parent, |
| 120 View* child) OVERRIDE; | 125 View* child) OVERRIDE; |
| 121 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 126 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 122 virtual void CalculateOffsetToAncestorWithLayer( | 127 virtual void CalculateOffsetToAncestorWithLayer( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 138 // cursor during drag operations. The location of the mouse should be in the | 143 // cursor during drag operations. The location of the mouse should be in the |
| 139 // current coordinate system (i.e. any necessary transformation should be | 144 // current coordinate system (i.e. any necessary transformation should be |
| 140 // applied to the point prior to calling this). | 145 // applied to the point prior to calling this). |
| 141 void UpdateCursor(const MouseEvent& event); | 146 void UpdateCursor(const MouseEvent& event); |
| 142 | 147 |
| 143 // Updates the last_mouse_* fields from e. The location of the mouse should be | 148 // Updates the last_mouse_* fields from e. The location of the mouse should be |
| 144 // in the current coordinate system (i.e. any necessary transformation should | 149 // in the current coordinate system (i.e. any necessary transformation should |
| 145 // be applied to the point prior to calling this). | 150 // be applied to the point prior to calling this). |
| 146 void SetMouseLocationAndFlags(const MouseEvent& event); | 151 void SetMouseLocationAndFlags(const MouseEvent& event); |
| 147 | 152 |
| 153 // Feeds touch event to GestureRecognizer. |
| 154 // Returns true if the event resulted in firing a synthetic event. |
| 155 bool DoGestureProcessing(const TouchEvent& event, ui::TouchStatus status); |
| 156 |
| 148 ////////////////////////////////////////////////////////////////////////////// | 157 ////////////////////////////////////////////////////////////////////////////// |
| 149 | 158 |
| 150 // Tree operations ----------------------------------------------------------- | 159 // Tree operations ----------------------------------------------------------- |
| 151 | 160 |
| 152 // The host Widget | 161 // The host Widget |
| 153 Widget* widget_; | 162 Widget* widget_; |
| 154 | 163 |
| 155 // Input --------------------------------------------------------------------- | 164 // Input --------------------------------------------------------------------- |
| 156 | 165 |
| 157 // The view currently handing down - drag - up | 166 // The view currently handing down - drag - up |
| (...skipping 14 matching lines...) Expand all Loading... |
| 172 int last_mouse_event_flags_; | 181 int last_mouse_event_flags_; |
| 173 int last_mouse_event_x_; | 182 int last_mouse_event_x_; |
| 174 int last_mouse_event_y_; | 183 int last_mouse_event_y_; |
| 175 | 184 |
| 176 // The gesture_manager_ for this. | 185 // The gesture_manager_ for this. |
| 177 GestureManager* gesture_manager_; | 186 GestureManager* gesture_manager_; |
| 178 | 187 |
| 179 // The view currently handling touch events. | 188 // The view currently handling touch events. |
| 180 View* touch_pressed_handler_; | 189 View* touch_pressed_handler_; |
| 181 | 190 |
| 191 // The gesture_recognizer_ for this. |
| 192 GestureRecognizer* gesture_recognizer_; |
| 193 |
| 194 // The view currently handling gesture events. |
| 195 View* gesture_handling_view_; |
| 196 |
| 182 // Focus --------------------------------------------------------------------- | 197 // Focus --------------------------------------------------------------------- |
| 183 | 198 |
| 184 // The focus search algorithm. | 199 // The focus search algorithm. |
| 185 FocusSearch focus_search_; | 200 FocusSearch focus_search_; |
| 186 | 201 |
| 187 // Whether this root view belongs to the current active window. | 202 // Whether this root view belongs to the current active window. |
| 188 // bool activated_; | 203 // bool activated_; |
| 189 | 204 |
| 190 // The parent FocusTraversable, used for focus traversal. | 205 // The parent FocusTraversable, used for focus traversal. |
| 191 FocusTraversable* focus_traversable_parent_; | 206 FocusTraversable* focus_traversable_parent_; |
| 192 | 207 |
| 193 // The View that contains this RootView. This is used when we have RootView | 208 // The View that contains this RootView. This is used when we have RootView |
| 194 // wrapped inside native components, and is used for the focus traversal. | 209 // wrapped inside native components, and is used for the focus traversal. |
| 195 View* focus_traversable_parent_view_; | 210 View* focus_traversable_parent_view_; |
| 196 | 211 |
| 197 // Drag and drop ------------------------------------------------------------- | 212 // Drag and drop ------------------------------------------------------------- |
| 198 | 213 |
| 199 // Tracks drag state for a view. | 214 // Tracks drag state for a view. |
| 200 View::DragInfo drag_info_; | 215 View::DragInfo drag_info_; |
| 201 | 216 |
| 202 DISALLOW_IMPLICIT_CONSTRUCTORS(RootView); | 217 DISALLOW_IMPLICIT_CONSTRUCTORS(RootView); |
| 203 }; | 218 }; |
| 204 | 219 |
| 205 } // namespace internal | 220 } // namespace internal |
| 206 } // namespace views | 221 } // namespace views |
| 207 | 222 |
| 208 #endif // UI_VIEWS_WIDGET_ROOT_VIEW_H_ | 223 #endif // UI_VIEWS_WIDGET_ROOT_VIEW_H_ |
| OLD | NEW |