| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted.h" | 11 #include "base/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 #if defined(OS_LINUX) | 16 #if defined(OS_LINUX) |
| 17 typedef struct _GdkEventExpose GdkEventExpose; | 17 typedef struct _GdkEventExpose GdkEventExpose; |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 class PaintTask; | 22 class PaintTask; |
| 23 class Widget; | 23 class Widget; |
| 24 | 24 |
| 25 #if defined(TOUCH_UI) |
| 26 class GestureManager; |
| 27 #endif |
| 28 |
| 25 ///////////////////////////////////////////////////////////////////////////// | 29 ///////////////////////////////////////////////////////////////////////////// |
| 26 // | 30 // |
| 27 // RootView class | 31 // RootView class |
| 28 // | 32 // |
| 29 // The RootView is the root of a View hierarchy. A RootView is always the | 33 // The RootView is the root of a View hierarchy. A RootView is always the |
| 30 // first and only child of a Widget. | 34 // first and only child of a Widget. |
| 31 // | 35 // |
| 32 // The RootView manages the View hierarchy's interface with the Widget | 36 // The RootView manages the View hierarchy's interface with the Widget |
| 33 // and also maintains the current invalid rect - the region that needs | 37 // and also maintains the current invalid rect - the region that needs |
| 34 // repainting. | 38 // repainting. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // hierarchy. | 90 // hierarchy. |
| 87 void NotifyLocaleChanged(); | 91 void NotifyLocaleChanged(); |
| 88 | 92 |
| 89 // The following event methods are overridden to propagate event to the | 93 // The following event methods are overridden to propagate event to the |
| 90 // control tree | 94 // control tree |
| 91 virtual bool OnMousePressed(const MouseEvent& e); | 95 virtual bool OnMousePressed(const MouseEvent& e); |
| 92 virtual bool OnMouseDragged(const MouseEvent& e); | 96 virtual bool OnMouseDragged(const MouseEvent& e); |
| 93 virtual void OnMouseReleased(const MouseEvent& e, bool canceled); | 97 virtual void OnMouseReleased(const MouseEvent& e, bool canceled); |
| 94 virtual void OnMouseMoved(const MouseEvent& e); | 98 virtual void OnMouseMoved(const MouseEvent& e); |
| 95 virtual void SetMouseHandler(View* new_mouse_handler); | 99 virtual void SetMouseHandler(View* new_mouse_handler); |
| 100 #if defined(TOUCH_UI) |
| 101 virtual bool OnTouchEvent(const TouchEvent& e); |
| 102 #endif |
| 96 | 103 |
| 97 // Invoked By the Widget if the mouse drag is interrupted by | 104 // Invoked By the Widget if the mouse drag is interrupted by |
| 98 // the system. Invokes OnMouseReleased with a value of true for canceled. | 105 // the system. Invokes OnMouseReleased with a value of true for canceled. |
| 99 void ProcessMouseDragCanceled(); | 106 void ProcessMouseDragCanceled(); |
| 100 | 107 |
| 101 // Invoked by the Widget instance when the mouse moves outside of the Widget | 108 // Invoked by the Widget instance when the mouse moves outside of the Widget |
| 102 // bounds. | 109 // bounds. |
| 103 virtual void ProcessOnMouseExited(); | 110 virtual void ProcessOnMouseExited(); |
| 104 | 111 |
| 105 // Make the provided view focused. Also make sure that our Widget is focused. | 112 // Make the provided view focused. Also make sure that our Widget is focused. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // If the view has not been deleted during the drag, OnDragDone is invoked | 175 // If the view has not been deleted during the drag, OnDragDone is invoked |
| 169 // on the view. | 176 // on the view. |
| 170 // NOTE: |view| may be null. | 177 // NOTE: |view| may be null. |
| 171 void StartDragForViewFromMouseEvent(View* view, | 178 void StartDragForViewFromMouseEvent(View* view, |
| 172 const OSExchangeData& data, | 179 const OSExchangeData& data, |
| 173 int operation); | 180 int operation); |
| 174 | 181 |
| 175 // Accessibility accessors/mutators, overridden from View. | 182 // Accessibility accessors/mutators, overridden from View. |
| 176 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 183 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
| 177 | 184 |
| 185 #if defined(TOUCH_UI) && defined(UNIT_TEST) |
| 186 // For unit testing purposes, we use this method to set a mock |
| 187 // GestureManager |
| 188 void SetGestureManager(GestureManager* g) { gesture_manager_ = g; } |
| 189 #endif |
| 190 |
| 178 protected: | 191 protected: |
| 179 | 192 |
| 180 // Overridden to properly reset our event propagation member | 193 // Overridden to properly reset our event propagation member |
| 181 // variables when a child is removed | 194 // variables when a child is removed |
| 182 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 195 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
| 183 | 196 |
| 184 #ifndef NDEBUG | 197 #ifndef NDEBUG |
| 185 virtual bool IsProcessingPaint() const { return is_processing_paint_; } | 198 virtual bool IsProcessingPaint() const { return is_processing_paint_; } |
| 186 #endif | 199 #endif |
| 187 | 200 |
| 188 private: | 201 private: |
| 189 friend class View; | 202 friend class View; |
| 190 friend class PaintTask; | 203 friend class PaintTask; |
| 191 | 204 |
| 205 #if defined(TOUCH_UI) |
| 206 // Required so the GestureManager can call the Process* entry points |
| 207 // with synthetic events as necessary. |
| 208 friend class GestureManager; |
| 209 #endif |
| 210 |
| 192 RootView(); | 211 RootView(); |
| 193 | 212 |
| 194 // Convert a point to our current mouse handler. Returns false if the | 213 // Convert a point to our current mouse handler. Returns false if the |
| 195 // mouse handler is not connected to a Widget. In that case, the | 214 // mouse handler is not connected to a Widget. In that case, the |
| 196 // conversion cannot take place and *p is unchanged | 215 // conversion cannot take place and *p is unchanged |
| 197 bool ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point *p); | 216 bool ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point *p); |
| 198 | 217 |
| 199 // Update the cursor given a mouse event. This is called by non mouse_move | 218 // Update the cursor given a mouse event. This is called by non mouse_move |
| 200 // event handlers to honor the cursor desired by views located under the | 219 // event handlers to honor the cursor desired by views located under the |
| 201 // cursor during drag operations. | 220 // cursor during drag operations. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // wrapped inside native components, and is used for the focus traversal. | 333 // wrapped inside native components, and is used for the focus traversal. |
| 315 View* focus_traversable_parent_view_; | 334 View* focus_traversable_parent_view_; |
| 316 | 335 |
| 317 // Tracks drag state for a view. | 336 // Tracks drag state for a view. |
| 318 View::DragInfo drag_info; | 337 View::DragInfo drag_info; |
| 319 | 338 |
| 320 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the | 339 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the |
| 321 // view the drag started from. | 340 // view the drag started from. |
| 322 View* drag_view_; | 341 View* drag_view_; |
| 323 | 342 |
| 343 #if defined(TOUCH_UI) |
| 344 // The gesture_manager_ for this. |
| 345 GestureManager* gesture_manager_; |
| 346 |
| 347 // The view currently handling touch events. |
| 348 View *touch_pressed_handler_; |
| 349 #endif |
| 350 |
| 324 #ifndef NDEBUG | 351 #ifndef NDEBUG |
| 325 // True if we're currently processing paint. | 352 // True if we're currently processing paint. |
| 326 bool is_processing_paint_; | 353 bool is_processing_paint_; |
| 327 #endif | 354 #endif |
| 328 | |
| 329 DISALLOW_COPY_AND_ASSIGN(RootView); | 355 DISALLOW_COPY_AND_ASSIGN(RootView); |
| 330 }; | 356 }; |
| 331 | |
| 332 } // namespace views | 357 } // namespace views |
| 333 | 358 |
| 334 #endif // VIEWS_WIDGET_ROOT_VIEW_H_ | 359 #endif // VIEWS_WIDGET_ROOT_VIEW_H_ |
| OLD | NEW |