| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_WIDGET_ROOT_VIEW_H_ | 5 #ifndef VIEWS_WIDGET_ROOT_VIEW_H_ |
| 6 #define VIEWS_WIDGET_ROOT_VIEW_H_ | 6 #define 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 "views/focus/focus_manager.h" | 12 #include "views/focus/focus_manager.h" |
| 13 #include "views/focus/focus_search.h" | 13 #include "views/focus/focus_search.h" |
| 14 #include "views/view.h" | 14 #include "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 | 120 |
| 116 protected: | 121 protected: |
| 117 // Overridden from View: | 122 // Overridden from View: |
| 118 virtual void ViewHierarchyChanged(bool is_add, View* parent, | 123 virtual void ViewHierarchyChanged(bool is_add, View* parent, |
| 119 View* child) OVERRIDE; | 124 View* child) OVERRIDE; |
| 120 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 125 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 121 virtual void CalculateOffsetToAncestorWithLayer( | 126 virtual void CalculateOffsetToAncestorWithLayer( |
| 122 gfx::Point* offset, | 127 gfx::Point* offset, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 137 // cursor during drag operations. The location of the mouse should be in the | 142 // cursor during drag operations. The location of the mouse should be in the |
| 138 // current coordinate system (i.e. any necessary transformation should be | 143 // current coordinate system (i.e. any necessary transformation should be |
| 139 // applied to the point prior to calling this). | 144 // applied to the point prior to calling this). |
| 140 void UpdateCursor(const MouseEvent& event); | 145 void UpdateCursor(const MouseEvent& event); |
| 141 | 146 |
| 142 // Updates the last_mouse_* fields from e. The location of the mouse should be | 147 // Updates the last_mouse_* fields from e. The location of the mouse should be |
| 143 // in the current coordinate system (i.e. any necessary transformation should | 148 // in the current coordinate system (i.e. any necessary transformation should |
| 144 // be applied to the point prior to calling this). | 149 // be applied to the point prior to calling this). |
| 145 void SetMouseLocationAndFlags(const MouseEvent& event); | 150 void SetMouseLocationAndFlags(const MouseEvent& event); |
| 146 | 151 |
| 152 // Feeds touch event to GestureRecognizer. |
| 153 // Returns true if the event resulted in firing a synthetic event. |
| 154 bool DoGestureProcessing(const TouchEvent& event, ui::TouchStatus status); |
| 155 |
| 147 ////////////////////////////////////////////////////////////////////////////// | 156 ////////////////////////////////////////////////////////////////////////////// |
| 148 | 157 |
| 149 // Tree operations ----------------------------------------------------------- | 158 // Tree operations ----------------------------------------------------------- |
| 150 | 159 |
| 151 // The host Widget | 160 // The host Widget |
| 152 Widget* widget_; | 161 Widget* widget_; |
| 153 | 162 |
| 154 // Input --------------------------------------------------------------------- | 163 // Input --------------------------------------------------------------------- |
| 155 | 164 |
| 156 // The view currently handing down - drag - up | 165 // The view currently handing down - drag - up |
| (...skipping 14 matching lines...) Expand all Loading... |
| 171 int last_mouse_event_flags_; | 180 int last_mouse_event_flags_; |
| 172 int last_mouse_event_x_; | 181 int last_mouse_event_x_; |
| 173 int last_mouse_event_y_; | 182 int last_mouse_event_y_; |
| 174 | 183 |
| 175 // The gesture_manager_ for this. | 184 // The gesture_manager_ for this. |
| 176 GestureManager* gesture_manager_; | 185 GestureManager* gesture_manager_; |
| 177 | 186 |
| 178 // The view currently handling touch events. | 187 // The view currently handling touch events. |
| 179 View* touch_pressed_handler_; | 188 View* touch_pressed_handler_; |
| 180 | 189 |
| 190 // The gesture_recognizer_ for this. |
| 191 GestureRecognizer* gesture_recognizer_; |
| 192 |
| 193 // The view currently handling gesture events. |
| 194 View* gesture_handling_view_; |
| 195 |
| 181 // Focus --------------------------------------------------------------------- | 196 // Focus --------------------------------------------------------------------- |
| 182 | 197 |
| 183 // The focus search algorithm. | 198 // The focus search algorithm. |
| 184 FocusSearch focus_search_; | 199 FocusSearch focus_search_; |
| 185 | 200 |
| 186 // Whether this root view belongs to the current active window. | 201 // Whether this root view belongs to the current active window. |
| 187 // bool activated_; | 202 // bool activated_; |
| 188 | 203 |
| 189 // The parent FocusTraversable, used for focus traversal. | 204 // The parent FocusTraversable, used for focus traversal. |
| 190 FocusTraversable* focus_traversable_parent_; | 205 FocusTraversable* focus_traversable_parent_; |
| 191 | 206 |
| 192 // The View that contains this RootView. This is used when we have RootView | 207 // The View that contains this RootView. This is used when we have RootView |
| 193 // wrapped inside native components, and is used for the focus traversal. | 208 // wrapped inside native components, and is used for the focus traversal. |
| 194 View* focus_traversable_parent_view_; | 209 View* focus_traversable_parent_view_; |
| 195 | 210 |
| 196 // Drag and drop ------------------------------------------------------------- | 211 // Drag and drop ------------------------------------------------------------- |
| 197 | 212 |
| 198 // Tracks drag state for a view. | 213 // Tracks drag state for a view. |
| 199 View::DragInfo drag_info; | 214 View::DragInfo drag_info; |
| 200 | 215 |
| 201 DISALLOW_IMPLICIT_CONSTRUCTORS(RootView); | 216 DISALLOW_IMPLICIT_CONSTRUCTORS(RootView); |
| 202 }; | 217 }; |
| 203 | 218 |
| 204 } // namespace internal | 219 } // namespace internal |
| 205 } // namespace views | 220 } // namespace views |
| 206 | 221 |
| 207 #endif // VIEWS_WIDGET_ROOT_VIEW_H_ | 222 #endif // VIEWS_WIDGET_ROOT_VIEW_H_ |
| OLD | NEW |