15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef UI_VIEWS_VIEW_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UI_VIEWS_VIEW_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <algorithm>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <set>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/i18n/rtl.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h"
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/accessibility/ax_enums.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/accelerators/accelerator.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/dragdrop/drag_drop_types.h"
2268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "ui/base/dragdrop/drop_target_event.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/dragdrop/os_exchange_data.h"
247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "ui/base/ui_base_types.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/layer_delegate.h"
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/layer_owner.h"
27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "ui/events/event.h"
28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "ui/events/event_target.h"
29cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ui/gfx/geometry/r_tree.h"
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/gfx/insets.h"
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h"
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/vector2d.h"
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ui/views/cull_set.h"
35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "ui/views/view_targeter.h"
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/views/views_export.h"
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/win/scoped_comptr.h"
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using ui::OSExchangeData;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace gfx {
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Canvas;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Insets;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Path;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Transform;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)struct AXViewState;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Compositor;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Layer;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class NativeTheme;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TextInputClient;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Texture;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ThemeProvider;
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace views {
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Background;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Border;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ContextMenuController;
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DragController;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FocusManager;
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FocusTraversable;
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InputMethod;
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LayoutManager;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class NativeViewAccessibility;
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ScrollView;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Widget;
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace internal {
76e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass PreEventDispatchHandler;
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PostEventDispatchHandler;
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RootView;
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// View class
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   A View is a rectangle within the views View hierarchy. It is the base
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   class for all Views.
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   A View is a container of other Views (there is no such thing as a Leaf
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   View - makes code simpler, reduces type conversion headaches, design
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   mistakes etc)
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   The View contains basic properties for sizing (bounds), layout (flex,
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   orientation, etc), painting of children and event dispatch.
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   The View also uses a simple Box Layout Manager similar to XUL's
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   SprocketLayout system. Alternative Layout Managers implementing the
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   LayoutManager interface can be used to lay out children if required.
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   It is up to the subclass to implement Painting and storage of subclass -
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   specific properties and functionality.
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   Unless otherwise documented, views is not thread safe and should only be
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   accessed from the main thread.
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VIEWS_EXPORT View : public ui::LayerDelegate,
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public ui::LayerOwner,
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public ui::AcceleratorTarget,
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public ui::EventTarget {
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef std::vector<View*> Views;
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
113a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  struct ViewHierarchyChangedDetails {
114a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    ViewHierarchyChangedDetails()
115a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)        : is_add(false),
116a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          parent(NULL),
117a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          child(NULL),
118a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          move_view(NULL) {}
119a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
120a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    ViewHierarchyChangedDetails(bool is_add,
121a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                View* parent,
122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                View* child,
123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                View* move_view)
124a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)        : is_add(is_add),
125a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          parent(parent),
126a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          child(child),
127a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)          move_view(move_view) {}
128a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
129a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    bool is_add;
130a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // New parent if |is_add| is true, old parent if |is_add| is false.
131a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    View* parent;
132a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // The view being added or removed.
133a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    View* child;
134a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // If this is a move (reparent), meaning AddChildViewAt() is invoked with an
135a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // existing parent, then a notification for the remove is sent first,
136a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // followed by one for the add.  This case can be distinguished by a
137a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // non-NULL |move_view|.
138a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // For the remove part of move, |move_view| is the new parent of the View
139a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // being removed.
140a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // For the add part of move, |move_view| is the old parent of the View being
141a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    // added.
142a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    View* move_view;
143a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  };
144a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creation and lifetime -----------------------------------------------------
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View();
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~View();
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // By default a View is owned by its parent unless specified otherwise here.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_owned_by_client() { owned_by_client_ = true; }
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tree operations -----------------------------------------------------------
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get the Widget that hosts this View, if any.
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual const Widget* GetWidget() const;
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual Widget* GetWidget();
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Adds |view| as a child of this view, optionally at |index|.
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddChildView(View* view);
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddChildViewAt(View* view, int index);
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Moves |view| to the specified |index|. A negative value for |index| moves
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the view at the end.
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ReorderChildView(View* view, int index);
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Removes |view| from this view. The view's parent will change to NULL.
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RemoveChildView(View* view);
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Removes all the children from this view. If |delete_children| is true,
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the views are deleted, unless marked as not parent owned.
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RemoveAllChildViews(bool delete_children);
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int child_count() const { return static_cast<int>(children_.size()); }
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_children() const { return !children_.empty(); }
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the child view at |index|.
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const View* child_at(int index) const {
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DCHECK_GE(index, 0);
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DCHECK_LT(index, child_count());
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return children_[index];
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* child_at(int index) {
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return const_cast<View*>(const_cast<const View*>(this)->child_at(index));
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the parent view.
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const View* parent() const { return parent_; }
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* parent() { return parent_; }
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |view| is contained within this View's hierarchy, even as
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // an indirect descendant. Will return true if child is also this view.
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool Contains(const View* view) const;
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the index of |view|, or -1 if |view| is not a child of this view.
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetIndexOf(const View* view) const;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size and disposition ------------------------------------------------------
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Methods for obtaining and modifying the position and size of the view.
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Position is in the coordinate system of the view's parent.
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Position is NOT flipped for RTL. See "RTL positioning" for RTL-sensitive
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // position accessors.
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Transformations are not applied on the size/position. For example, if
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // bounds is (0, 0, 100, 100) and it is scaled by 0.5 along the X axis, the
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // width will still be 100 (although when painted, it will be 50x50, painted
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // at location (0, 0)).
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetBounds(int x, int y, int width, int height);
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetBoundsRect(const gfx::Rect& bounds);
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetSize(const gfx::Size& size);
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetPosition(const gfx::Point& position);
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetX(int x);
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetY(int y);
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // No transformation is applied on the size or the locations.
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const gfx::Rect& bounds() const { return bounds_; }
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int x() const { return bounds_.x(); }
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int y() const { return bounds_.y(); }
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int width() const { return bounds_.width(); }
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int height() const { return bounds_.height(); }
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const gfx::Size& size() const { return bounds_.size(); }
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds of the content area of the view, i.e. the rectangle
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // enclosed by the view's border.
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetContentsBounds() const;
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds of the view in its own coordinates (i.e. position is
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // 0, 0).
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetLocalBounds() const;
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds of the layer in its own pixel coordinates.
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetLayerBoundsInPixel() const;
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the insets of the current border. If there is no border an empty
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // insets is returned.
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Insets GetInsets() const;
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the visible bounds of the receiver in the receivers coordinate
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system.
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When traversing the View hierarchy in order to compute the bounds, the
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // function takes into account the mirroring setting and transformation for
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // each View and therefore it will return the mirrored and transformed version
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the visible bounds if need be.
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetVisibleBounds() const;
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the bounds of the View in screen coordinate system.
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetBoundsInScreen() const;
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the baseline of this view, or -1 if this view has no baseline. The
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // return value is relative to the preferred height.
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetBaseline() const;
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get the size the View would like to be, if enough space were available.
255cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual gfx::Size GetPreferredSize() const;
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience method that sizes this view to its preferred size.
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SizeToPreferredSize();
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets the minimum size of the view. View's implementation invokes
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetPreferredSize.
262cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual gfx::Size GetMinimumSize() const;
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets the maximum size of the view. Currently only used for sizing shell
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // windows.
266cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual gfx::Size GetMaximumSize() const;
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the height necessary to display this view with the provided width.
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // View's implementation returns the value from getPreferredSize.cy.
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override if your View's preferred height depends upon the width (such
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as with Labels).
272cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual int GetHeightForWidth(int w) const;
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Sets whether this view is visible. Painting is scheduled as needed. Also,
2756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // clears focus if the focused view or one of its ancestors is set to be
2766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // hidden.
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetVisible(bool visible);
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return whether a view is visible
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool visible() const { return visible_; }
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if this view is drawn on screen.
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsDrawn() const;
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set whether this view is enabled. A disabled view does not receive keyboard
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // or mouse inputs. If |enabled| differs from the current value, SchedulePaint
2876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // is invoked. Also, clears focus if the focused view is disabled.
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetEnabled(bool enabled);
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether the view is enabled.
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool enabled() const { return enabled_; }
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This indicates that the view completely fills its bounds in an opaque
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // color. This doesn't affect compositing but is a hint to the compositor to
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // optimize painting.
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that this method does not implicitly create a layer if one does not
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // already exist for the View, but is a no-op in that case.
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetFillsBoundsOpaquely(bool fills_bounds_opaquely);
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Transformations -----------------------------------------------------------
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Methods for setting transformations for a view (e.g. rotation, scaling).
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Transform GetTransform() const;
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Clipping parameters. Clipping is done relative to the view bounds.
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_clip_insets(gfx::Insets clip_insets) { clip_insets_ = clip_insets; }
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the transform to the supplied transform.
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetTransform(const gfx::Transform& transform);
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets whether this view paints to a layer. A view paints to a layer if
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // either of the following are true:
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // . the view has a non-identity transform.
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // . SetPaintToLayer(true) has been invoked.
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // View creates the Layer only when it exists in a Widget with a non-NULL
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Compositor.
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetPaintToLayer(bool paint_to_layer);
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RTL positioning -----------------------------------------------------------
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Methods for accessing the bounds and position of the view, relative to its
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // parent. The position returned is mirrored if the parent view is using a RTL
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // layout.
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: in the vast majority of the cases, the mirroring implementation is
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //       transparent to the View subclasses and therefore you should use the
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //       bounds() accessor instead.
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetMirroredBounds() const;
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point GetMirroredPosition() const;
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetMirroredX() const;
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Given a rectangle specified in this View's coordinate system, the function
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // computes the 'left' value for the mirrored rectangle within this View. If
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the View's UI layout is not right-to-left, then bounds.x() is returned.
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // UI mirroring is transparent to most View subclasses and therefore there is
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // no need to call this routine from anywhere within your subclass
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // implementation.
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetMirroredXForRect(const gfx::Rect& rect) const;
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Given the X coordinate of a point inside the View, this function returns
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the mirrored X coordinate of the point if the View's UI layout is
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // right-to-left. If the layout is left-to-right, the same X coordinate is
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // returned.
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Following are a few examples of the values returned by this function for
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a View with the bounds {0, 0, 100, 100} and a right-to-left layout:
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetMirroredXCoordinateInView(0) -> 100
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetMirroredXCoordinateInView(20) -> 80
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetMirroredXCoordinateInView(99) -> 1
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetMirroredXInView(int x) const;
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Given a X coordinate and a width inside the View, this function returns
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the mirrored X coordinate if the View's UI layout is right-to-left. If the
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // layout is left-to-right, the same X coordinate is returned.
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Following are a few examples of the values returned by this function for
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a View with the bounds {0, 0, 100, 100} and a right-to-left layout:
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetMirroredXCoordinateInView(0, 10) -> 90
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetMirroredXCoordinateInView(20, 20) -> 60
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetMirroredXWithWidthInView(int x, int w) const;
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Layout --------------------------------------------------------------------
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Lay out the child Views (set their bounds based on sizing heuristics
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // specific to the current Layout Manager)
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Layout();
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(beng): I think we should remove this.
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Mark this view and all parents to require a relayout. This ensures the
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // next call to Layout() will propagate to this view, even if the bounds of
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // parent views do not change.
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InvalidateLayout();
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets/Sets the Layout Manager used by this view to size and place its
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // children.
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The LayoutManager is owned by the View and is deleted when the view is
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // deleted, or when a new LayoutManager is installed.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  LayoutManager* GetLayoutManager() const;
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetLayoutManager(LayoutManager* layout);
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Adjust the layer's offset so that it snaps to the physical pixel boundary.
386116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // This has no effect if the view does not have an associated layer.
387116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void SnapLayerToPixelBoundary();
388116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Attributes ----------------------------------------------------------------
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The view class name.
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const char kViewClassName[];
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the receiving view's class name. A view class is a string which
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // uniquely identifies the view class. It is intended to be used as a way to
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // find out during run time if a view can be safely casted to a specific view
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // subclass. The default implementation returns kViewClassName.
398b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  virtual const char* GetClassName() const;
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the first ancestor, starting at this, whose class name is |name|.
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns null if no ancestor has the class name |name|.
402effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  const View* GetAncestorWithClassName(const std::string& name) const;
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* GetAncestorWithClassName(const std::string& name);
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Recursively descends the view tree starting at this view, and returns
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the first child that it encounters that has the given ID.
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns NULL if no matching child view is found.
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual const View* GetViewByID(int id) const;
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual View* GetViewByID(int id);
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets and sets the ID for this view. ID should be unique within the subtree
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that you intend to search for it. 0 is the default ID for views.
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int id() const { return id_; }
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_id(int id) { id_ = id; }
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A group id is used to tag views which are part of the same logical group.
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus can be moved between views with the same group using the arrow keys.
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Groups are currently used to implement radio button mutual exclusion.
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The group id is immutable once it's set.
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetGroup(int gid);
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the group id of the view, or -1 if the id is not set yet.
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetGroup() const;
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this returns true, the views from the same group can each be focused
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when moving focus with the Tab/Shift-Tab key.  If this returns false,
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // only the selected view from the group (obtained with
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetSelectedViewForGroup()) is focused.
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsGroupFocusTraversable() const;
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Fills |views| with all the available views which belong to the provided
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |group|.
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetViewsInGroup(int group, Views* views);
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the View that is currently selected in |group|.
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The default implementation simply returns the first View found for that
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // group.
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual View* GetSelectedViewForGroup(int group);
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Coordinate conversion -----------------------------------------------------
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that the utility coordinate conversions functions always operate on
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the mirrored position of the child Views if the parent View uses a
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // right-to-left UI layout.
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point from the coordinate system of one View to another.
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |source| and |target| must be in the same widget, but doesn't need to be in
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the same view hierarchy.
449a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Neither |source| nor |target| can be NULL.
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ConvertPointToTarget(const View* source,
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const View* target,
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   gfx::Point* point);
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Convert |rect| from the coordinate system of |source| to the coordinate
4558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // system of |target|.
4568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  //
4578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // |source| and |target| must be in the same widget, but doesn't need to be in
4588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // the same view hierarchy.
459a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Neither |source| nor |target| can be NULL.
4608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  static void ConvertRectToTarget(const View* source,
4618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                                  const View* target,
4628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                                  gfx::RectF* rect);
4638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point from a View's coordinate system to that of its Widget.
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ConvertPointToWidget(const View* src, gfx::Point* point);
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point from the coordinate system of a View's Widget to that
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // View's coordinate system.
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ConvertPointFromWidget(const View* dest, gfx::Point* p);
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point from a View's coordinate system to that of the screen.
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ConvertPointToScreen(const View* src, gfx::Point* point);
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point from a View's coordinate system to that of the screen.
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ConvertPointFromScreen(const View* dst, gfx::Point* point);
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Applies transformation on the rectangle, which is in the view's coordinate
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system, to convert it into the parent's coordinate system.
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect ConvertRectToParent(const gfx::Rect& rect) const;
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Converts a rectangle from this views coordinate system to its widget
4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinate system.
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect ConvertRectToWidget(const gfx::Rect& rect) const;
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Painting ------------------------------------------------------------------
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Mark all or part of the View's bounds as dirty (needing repaint).
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |r| is in the View's coordinates.
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Rectangle |r| should be in the view's coordinate system. The
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // transformations are applied to it to convert it into the parent coordinate
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system before propagating SchedulePaint up the view hierarchy.
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(beng): Make protected.
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SchedulePaint();
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SchedulePaintInRect(const gfx::Rect& r);
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called by the framework to paint a View. Performs translation and clipping
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for View coordinates and language direction as required, allows the View
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to paint itself via the various OnPaint*() event handlers and then paints
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the hierarchy beneath it.
500cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set);
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The background object is owned by this object and may be NULL.
503a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void set_background(Background* b);
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const Background* background() const { return background_.get(); }
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Background* background() { return background_.get(); }
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The border object is owned by this object and may be NULL.
508010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual void SetBorder(scoped_ptr<Border> b);
5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const Border* border() const { return border_.get(); }
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Border* border() { return border_.get(); }
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get the theme provider from the parent widget.
5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ui::ThemeProvider* GetThemeProvider() const;
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the NativeTheme to use for this View. This calls through to
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetNativeTheme() on the Widget this View is in. If this View is not in a
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Widget this returns ui::NativeTheme::instance().
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ui::NativeTheme* GetNativeTheme() {
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return const_cast<ui::NativeTheme*>(
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        const_cast<const View*>(this)->GetNativeTheme());
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const ui::NativeTheme* GetNativeTheme() const;
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RTL painting --------------------------------------------------------------
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method determines whether the gfx::Canvas object passed to
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // View::Paint() needs to be transformed such that anything drawn on the
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // canvas object during View::Paint() is flipped horizontally.
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // By default, this function returns false (which is the initial value of
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |flip_canvas_on_paint_for_rtl_ui_|). View subclasses that need to paint on
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a flipped gfx::Canvas when the UI layout is right-to-left need to call
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // EnableCanvasFlippingForRTLUI().
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool FlipCanvasOnPaintForRTLUI() const {
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return flip_canvas_on_paint_for_rtl_ui_ ? base::i18n::IsRTL() : false;
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Enables or disables flipping of the gfx::Canvas during View::Paint().
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that if canvas flipping is enabled, the canvas will be flipped only
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if the UI layout is right-to-left; that is, the canvas will be flipped
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // only if base::i18n::IsRTL() returns true.
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Enabling canvas flipping is useful for leaf views that draw an image that
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // needs to be flipped horizontally when the UI layout is right-to-left
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (views::Button, for example). This method is helpful for such classes
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // because their drawing logic stays the same and they can become agnostic to
5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the UI directionality.
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void EnableCanvasFlippingForRTLUI(bool enable) {
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    flip_canvas_on_paint_for_rtl_ui_ = enable;
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Input ---------------------------------------------------------------------
553f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // The points, rects, mouse locations, and touch locations in the following
554f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // functions are in the view's coordinates, except for a RootView.
555f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
5565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // A convenience function which calls into GetEventHandlerForRect() with
5575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // a 1x1 rect centered at |point|. |point| is in the local coordinate
5585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // space of |this|.
559f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  View* GetEventHandlerForPoint(const gfx::Point& point);
560f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
5615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Returns the View that should be the target of an event having |rect| as
5625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // its location, or NULL if no such target exists. |rect| is in the local
5635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // coordinate space of |this|.
5645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  View* GetEventHandlerForRect(const gfx::Rect& rect);
5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
566c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Returns the deepest visible descendant that contains the specified point
567c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // and supports tooltips. If the view does not contain the point, returns
568c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // NULL.
569c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual View* GetTooltipHandlerForPoint(const gfx::Point& point);
570c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the cursor that should be used for this view or the default cursor.
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The event location is in the receiver's coordinate system. The caller is
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // responsible for managing the lifetime of the returned object, though that
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // lifetime may vary from platform to platform. On Windows and Aura,
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the cursor is a shared resource.
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event);
5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A convenience function which calls HitTestRect() with a rect of size
5795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // 1x1 and an origin of |point|. |point| is in the local coordinate space
5805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // of |this|.
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool HitTestPoint(const gfx::Point& point) const;
5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Returns true if |rect| intersects this view's bounds. |rect| is in the
5845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // local coordinate space of |this|.
585116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool HitTestRect(const gfx::Rect& rect) const;
5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
58746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // Returns true if this view or any of its descendants are permitted to
58846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // be the target of an event.
58946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  virtual bool CanProcessEventsWithinSubtree() const;
59046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
5917d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Returns true if the mouse cursor is over |view| and mouse events are
5927d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // enabled.
5937d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool IsMouseHovered();
5947d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the user clicks on this view.
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The provided event is in the receiver's coordinate system.
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return true if you processed the event and want to receive subsequent
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // MouseDraggged and MouseReleased events.  This also stops the event from
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // bubbling.  If you return false, the event will bubble through parent
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views.
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If you remove yourself from the tree while processing this, event bubbling
6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // stops as if you returned true, but you will not receive future events.
6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The return value is ignored in this case.
6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation returns true if a ContextMenuController has been
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // set, false otherwise. Override as needed.
6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMousePressed(const ui::MouseEvent& event);
6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the user clicked on this control.
6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and is still moving the mouse with a button pressed.
6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The provided event is in the receiver's coordinate system.
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return true if you processed the event and want to receive
6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // subsequent MouseDragged and MouseReleased events.
6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation returns true if a ContextMenuController has been
6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // set, false otherwise. Override as needed.
6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMouseDragged(const ui::MouseEvent& event);
6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the user releases the mouse
6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // button. The event is in the receiver's coordinate system.
6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation notifies the ContextMenuController is appropriate.
6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Subclasses that wish to honor the ContextMenuController should invoke
6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // super.
6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnMouseReleased(const ui::MouseEvent& event);
6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the mouse press/drag was canceled by a
6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system/user gesture.
6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnMouseCaptureLost();
6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the mouse is above this control
6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The event is in the receiver's coordinate system.
6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation does nothing. Override as needed.
6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnMouseMoved(const ui::MouseEvent& event);
6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the mouse enters this control.
6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation does nothing. Override as needed.
6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnMouseEntered(const ui::MouseEvent& event);
6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the mouse exits this control
6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The provided event location is always (0, 0)
6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation does nothing. Override as needed.
6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnMouseExited(const ui::MouseEvent& event);
6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set the MouseHandler for a drag session.
6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A drag session is a stream of mouse events starting
6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // with a MousePressed event, followed by several MouseDragged
6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // events and finishing with a MouseReleased event.
6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method should be only invoked while processing a
6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // MouseDragged or MousePressed event.
6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // All further mouse dragged and mouse up events will be sent
6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the MouseHandler, even if it is reparented to another window.
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The MouseHandler is automatically cleared when the control
6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // comes back from processing the MouseReleased event.
6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: if the mouse handler is no longer connected to a
6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view hierarchy, events won't be sent.
6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sky): rename this.
6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetMouseHandler(View* new_mouse_handler);
6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when a key is pressed or released.
6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Subclasser should return true if the event has been processed and false
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // otherwise. If the event has not been processed, the parent will be given a
6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chance.
6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnKeyPressed(const ui::KeyEvent& event);
6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnKeyReleased(const ui::KeyEvent& event);
6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when the user uses the mousewheel. Implementors should return true
6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if the event has been processed and false otherwise. This message is sent
6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if the view is focused. If the event has not been processed, the parent
6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // will be given a chance.
6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMouseWheel(const ui::MouseWheelEvent& event);
6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See field for description.
6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_notify_enter_exit_on_child(bool notify) {
6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    notify_enter_exit_on_child_ = notify;
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool notify_enter_exit_on_child() const {
6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return notify_enter_exit_on_child_;
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the View's TextInputClient instance or NULL if the View doesn't
6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // support text input.
6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ui::TextInputClient* GetTextInputClient();
6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience method to retrieve the InputMethod associated with the
7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Widget that contains this view. Returns NULL if this view is not part of a
7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view hierarchy with a Widget.
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual InputMethod* GetInputMethod();
703ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  virtual const InputMethod* GetInputMethod() const;
7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
705116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Sets a new ViewTargeter for the view, and returns the previous
706116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // ViewTargeter.
707116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter);
708c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
7095f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Returns the ViewTargeter installed on |this| if one exists,
7105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // otherwise returns the ViewTargeter installed on our root view.
7115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // The return value is guaranteed to be non-null.
7125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  ViewTargeter* GetEffectiveViewTargeter() const;
7135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
7145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  ViewTargeter* targeter() const { return targeter_.get(); }
7155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from ui::EventTarget:
7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
7185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ui::EventTarget* GetParentTarget() OVERRIDE;
719a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
720a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
721010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual void ConvertEventToTarget(ui::EventTarget* target,
722010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)                                    ui::LocatedEvent* event) OVERRIDE;
7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from ui::EventHandler:
7252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
7262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
7272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
728e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE FINAL;
7292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerators --------------------------------------------------------------
7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets a keyboard accelerator for that view. When the user presses the
7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // accelerator key combination, the AcceleratorPressed method is invoked.
7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that you can set multiple accelerators for a view by invoking this
7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // method several times. Note also that AcceleratorPressed is invoked only
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when CanHandleAccelerators() is true.
7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AddAccelerator(const ui::Accelerator& accelerator);
7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Removes the specified accelerator for this view.
7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RemoveAccelerator(const ui::Accelerator& accelerator);
7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Removes all the keyboard accelerators for this view.
7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ResetAccelerators();
7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from AcceleratorTarget:
7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether accelerators are enabled for this view. Accelerators are
7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // enabled if the containing widget is visible and the view is enabled() and
7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IsDrawn()
7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool CanHandleAccelerators() const OVERRIDE;
7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus ---------------------------------------------------------------------
7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether this view currently has the focus.
7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HasFocus() const;
7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the view that should be selected next when pressing Tab.
7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* GetNextFocusableView();
7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const View* GetNextFocusableView() const;
7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the view that should be selected next when pressing Shift-Tab.
7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* GetPreviousFocusableView();
7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the component that should be selected next when pressing Tab, and
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // makes the current view the precedent view of the specified one.
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that by default views are linked in the order they have been added to
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // their container. Use this method if you want to modify the order.
7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IMPORTANT NOTE: loops in the focus hierarchy are not supported.
7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetNextFocusableView(View* view);
7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Sets whether this view is capable of taking focus. It will clear focus if
7746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // the focused view is set to be non-focusable.
7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that this is false by default so that a view used as a container does
7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not get the focus.
7775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetFocusable(bool focusable);
7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if this view is |focusable_|, |enabled_| and drawn.
7806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  bool IsFocusable() const;
7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return whether this view is focusable when the user requires full keyboard
7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // access, even though it may not be normally focusable.
7845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool IsAccessibilityFocusable() const;
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set whether this view can be made focusable if the user requires
7876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // full keyboard access, even though it's not normally focusable. It will
7886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // clear focus if the focused view is set to be non-focusable.
7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that this is false by default.
7905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetAccessibilityFocusable(bool accessibility_focusable);
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience method to retrieve the FocusManager associated with the
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Widget that contains this view.  This can return NULL if this view is not
7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // part of a view hierarchy with a Widget.
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual FocusManager* GetFocusManager();
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual const FocusManager* GetFocusManager() const;
7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
798c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Request keyboard focus. The receiving view will become the focused view.
7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestFocus();
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when a view is about to be requested for focus due to the focus
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // traversal. Reverse is this request was generated going backward
8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (Shift-Tab).
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AboutToRequestFocusFromTabTraversal(bool reverse) {}
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when a key is pressed before the key event is processed (and
8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // potentially eaten) by the focus manager for tab traversal, accelerators and
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // other focus related actions.
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The default implementation returns false, ensuring that tab traversal and
8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // accelerators processing is performed.
8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Subclasses should return true if they want to process the key event and not
8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // have it processed as an accelerator (if any) or as a tab traversal (if the
8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // key event is for the TAB key).  In that case, OnKeyPressed will
8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // subsequently be invoked for that event.
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event);
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Subclasses that contain traversable children that are not directly
8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // accessible through the children hierarchy should return the associated
8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // FocusTraversable for the focus traversal to work properly.
8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual FocusTraversable* GetFocusTraversable();
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Subclasses that can act as a "pane" must implement their own
8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // FocusTraversable to keep the focus trapped within the pane.
8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this method returns an object, any view that's a direct or
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // indirect child of this view will always use this FocusTraversable
8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // rather than the one from the widget.
8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual FocusTraversable* GetPaneFocusTraversable();
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tooltips ------------------------------------------------------------------
8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets the tooltip for this View. If the View does not have a tooltip,
8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // return false. If the View does have a tooltip, copy the tooltip into
8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the supplied string and return true.
8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Any time the tooltip text that a View is displaying changes, it must
8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoke TooltipTextChanged.
8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |p| provides the coordinates of the mouse (relative to this view).
8375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool GetTooltipText(const gfx::Point& p,
8385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                              base::string16* tooltip) const;
8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the location (relative to this View) for the text on the tooltip
8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to display. If false is returned (the default), the tooltip is placed at
8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a default position.
8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) const;
8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Context menus -------------------------------------------------------------
8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the ContextMenuController. Setting this to non-null makes the View
8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process mouse events.
8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ContextMenuController* context_menu_controller() {
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return context_menu_controller_;
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_context_menu_controller(ContextMenuController* menu_controller) {
8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    context_menu_controller_ = menu_controller;
8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Provides default implementation for context menu handling. The default
8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // implementation calls the ShowContextMenu of the current
8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ContextMenuController (if it is not NULL). Overridden in subclassed views
8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to provide right-click menu display triggerd by the keyboard (i.e. for the
8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Chrome toolbar Back and Forward buttons). No source needs to be specified,
8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as it is always equal to the current View.
8627d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  virtual void ShowContextMenu(const gfx::Point& p,
8637d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                               ui::MenuSourceType source_type);
8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // On some platforms, we show context menu on mouse press instead of release.
866c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // This method returns true for those platforms.
867c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static bool ShouldShowContextMenuOnMousePress();
868c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Drag and drop -------------------------------------------------------------
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DragController* drag_controller() { return drag_controller_; }
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_drag_controller(DragController* drag_controller) {
8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    drag_controller_ = drag_controller;
8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // During a drag and drop session when the mouse moves the view under the
8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // mouse is queried for the drop types it supports by way of the
8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetDropFormats methods. If the view returns true and the drag site can
8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // provide data in one of the formats, the view is asked if the drop data
8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is required before any other drop events are sent. Once the
8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // data is available the view is asked if it supports the drop (by way of
8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the CanDrop method). If a view returns true from CanDrop,
8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // OnDragEntered is sent to the view when the mouse first enters the view,
8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as the mouse moves around within the view OnDragUpdated is invoked.
8855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If the user releases the mouse over the view and OnDragUpdated returns a
8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // valid drop, then OnPerformDrop is invoked. If the mouse moves outside the
8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view or over another view that wants the drag, OnDragExited is invoked.
8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
8895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Similar to mouse events, the deepest view under the mouse is first checked
8905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if it supports the drop (Drop). If the deepest view under
8915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the mouse does not support the drop, the ancestors are walked until one
8925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is found that supports the drop.
8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override and return the set of formats that can be dropped on this view.
8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |formats| is a bitmask of the formats defined bye OSExchangeData::Format.
8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The default implementation returns false, which means the view doesn't
8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // support dropping.
8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetDropFormats(
8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int* formats,
9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      std::set<OSExchangeData::CustomFormat>* custom_formats);
9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override and return true if the data must be available before any drop
9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // methods should be invoked. The default is false.
9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool AreDropTypesRequired();
9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A view that supports drag and drop must override this and return true if
9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // data contains a type that may be dropped on this view.
9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool CanDrop(const OSExchangeData& data);
9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // OnDragEntered is invoked when the mouse enters this view during a drag and
9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // drop session and CanDrop returns true. This is immediately
9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // followed by an invocation of OnDragUpdated, and eventually one of
9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // OnDragExited or OnPerformDrop.
9145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnDragEntered(const ui::DropTargetEvent& event);
9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked during a drag and drop session while the mouse is over the view.
9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This should return a bitmask of the DragDropTypes::DragOperation supported
9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // based on the location of the event. Return 0 to indicate the drop should
9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not be accepted.
9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int OnDragUpdated(const ui::DropTargetEvent& event);
9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked during a drag and drop session when the mouse exits the views, or
9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when the drag session was canceled and the mouse was over the view.
9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnDragExited();
9255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked during a drag and drop session when OnDragUpdated returns a valid
9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // operation and the user release the mouse.
9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int OnPerformDrop(const ui::DropTargetEvent& event);
9295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked from DoDrag after the drag completes. This implementation does
9315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // nothing, and is intended for subclasses to do cleanup.
9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnDragDone();
9335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the mouse was dragged enough to start a drag operation.
9355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // delta_x and y are the distance the mouse was dragged.
9365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool ExceededDragThreshold(const gfx::Vector2d& delta);
9375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accessibility -------------------------------------------------------------
9395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Modifies |state| to reflect the current accessible state of this view.
941a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void GetAccessibleState(ui::AXViewState* state) { }
9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns an instance of the native accessibility interface for this view.
9445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::NativeViewAccessible GetNativeViewAccessible();
9455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Notifies assistive technology that an accessibility event has
9472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // occurred on this view, such as when the view is focused or when its
9482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // value changes. Pass true for |send_native_event| except for rare
9492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // cases where the view is a native control that's already sending a
9502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // native accessibility event and the duplicate event would cause
9512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // problems.
952a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void NotifyAccessibilityEvent(ui::AXEvent event_type,
9532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                bool send_native_event);
9542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
9555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Scrolling -----------------------------------------------------------------
9565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(beng): Figure out if this can live somewhere other than View, i.e.
9575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //             closer to ScrollView.
9585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Scrolls the specified region, in this View's coordinate system, to be
9605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // visible. View's implementation passes the call onto the parent View (after
9615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // adjusting the coordinates). It is up to views that only show a portion of
9625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the child view, such as Viewport, to override appropriately.
9635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ScrollRectToVisible(const gfx::Rect& rect);
9645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The following methods are used by ScrollView to determine the amount
9665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to scroll relative to the visible bounds of the view. For example, a
9675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // return value of 10 indicates the scrollview should scroll 10 pixels in
9685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the appropriate direction.
9695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
9705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Each method takes the following parameters:
9715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
9725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is_horizontal: if true, scrolling is along the horizontal axis, otherwise
9735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //                the vertical axis.
9745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is_positive: if true, scrolling is by a positive amount. Along the
9755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //              vertical axis scrolling by a positive amount equates to
9765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //              scrolling down.
9775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
9785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The return value should always be positive and gives the number of pixels
9795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to scroll. ScrollView interprets a return value of 0 (or negative)
9805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to scroll by a default amount.
9815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
9825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See VariableRowHeightScrollHelper and FixedRowHeightScrollHelper for
9835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // implementations of common cases.
9845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetPageScrollIncrement(ScrollView* scroll_view,
9855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                     bool is_horizontal, bool is_positive);
9865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetLineScrollIncrement(ScrollView* scroll_view,
9875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                     bool is_horizontal, bool is_positive);
9885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
9902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Used to track a drag. RootView passes this into
9912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // ProcessMousePressed/Dragged.
9922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  struct DragInfo {
9932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Sets possible_drag to false and start_x/y to 0. This is invoked by
9942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // RootView prior to invoke ProcessMousePressed.
9952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void Reset();
9962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
9972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Sets possible_drag to true and start_pt to the specified point.
9982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // This is invoked by the target view if it detects the press may generate
9992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // a drag.
10002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void PossibleDrag(const gfx::Point& p);
10012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Whether the press may generate a drag.
10032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool possible_drag;
10042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Coordinates of the mouse press.
10062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    gfx::Point start_pt;
10072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
10082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size and disposition ------------------------------------------------------
10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to be notified when the bounds of the view have changed.
10125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnBoundsChanged(const gfx::Rect& previous_bounds);
10135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the preferred size of a child view changed.  This gives the
10155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // parent an opportunity to do a fresh layout if that makes sense.
10165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ChildPreferredSizeChanged(View* child) {}
10175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the visibility of a child view changed.  This gives the parent
10195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // an opportunity to do a fresh layout if that makes sense.
10205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ChildVisibilityChanged(View* child) {}
10215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invalidates the layout and calls ChildPreferredSizeChanged on the parent
10235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if there is one. Be sure to call View::PreferredSizeChanged when
10245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // overriding such that the layout is properly invalidated.
10255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void PreferredSizeChanged();
10265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override returning true when the view needs to be notified when its visible
10285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // bounds relative to the root view may have changed. Only used by
10295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NativeViewHost.
10301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const;
10315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that this View's visible bounds relative to the root view may
10335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // have changed. The visible bounds are the region of the View not clipped by
10345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // its ancestors. This is used for clipping NativeViewHost.
10355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnVisibleBoundsChanged();
10365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to be notified when the enabled state of this View has
10385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // changed. The default implementation calls SchedulePaint() on this View.
10395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnEnabledChanged();
10405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1041effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  bool needs_layout() const { return needs_layout_; }
1042effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
10435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tree operations -----------------------------------------------------------
10445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the tree changes.
10465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
10475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When a view is removed, it is invoked for all children and grand
10485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // children. For each of these views, a notification is sent to the
10495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view and all parents.
10505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
10515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When a view is added, a notification is sent to the view, all its
10525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // parents, and all its children (and grand children)
10535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
10545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default implementation does nothing. Override to perform operations
10555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // required when a view is added or removed from a view hierarchy
10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1057a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|.
1058a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details);
10595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When SetVisible() changes the visibility of a view, this method is
10615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked for that view as well as all the children recursively.
10625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void VisibilityChanged(View* starting_from, bool is_visible);
10635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1064424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // This method is invoked when the parent NativeView of the widget that the
1065424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // view is attached to has changed and the view hierarchy has not changed.
1066424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // ViewHierarchyChanged() is called when the parent NativeView of the widget
1067424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // that the view is attached to is changed as a result of changing the view
1068424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // hierarchy. Overriding this method is useful for tracking which
1069424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // FocusManager manages this view.
1070424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void NativeViewHierarchyChanged();
10715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Painting ------------------------------------------------------------------
10735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Responsible for calling Paint() on child Views. Override to control the
10755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // order child Views are painted.
1076cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void PaintChildren(gfx::Canvas* canvas, const CullSet& cull_set);
10775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to provide rendering in any part of the View's bounds. Typically
10795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this is the "contents" of the view. If you override this method you will
10805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // have to call the subsequent OnPaint*() methods manually.
10815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPaint(gfx::Canvas* canvas);
10825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to paint a background before any content is drawn. Typically this
10845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is done if you are satisfied with a default OnPaint handler but wish to
10855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // supply a different background.
10865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPaintBackground(gfx::Canvas* canvas);
10875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to paint a border not specified by SetBorder().
10895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPaintBorder(gfx::Canvas* canvas);
10905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1091cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Returns true if this View is the root for paint events, and should
1092cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // therefore maintain a |bounds_tree_| member and use it for paint damage rect
1093cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // calculations.
1094cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual bool IsPaintRoot();
1095cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
10965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerated painting ------------------------------------------------------
10975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the offset from this view to the nearest ancestor with a layer. If
10992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |layer_parent| is non-NULL it is set to the nearest ancestor with a layer.
11002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
11015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      ui::Layer** layer_parent);
11025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
110390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Updates the view's layer's parent. Called when a view is added to a view
110490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // hierarchy, responsible for parenting the view's layer to the enclosing
110590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // layer in the hierarchy.
110690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual void UpdateParentLayer();
110790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
11085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this view has a layer, the layer is reparented to |parent_layer| and its
11095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // bounds is set based on |point|. If this view does not have a layer, then
11105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // recurses through all children. This is used when adding a layer to an
11115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // existing view to make sure all descendants that have layers are parented to
11125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the right layer.
1113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void MoveLayerToParent(ui::Layer* parent_layer, const gfx::Point& point);
11145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to update the bounds of any child layers within this View's
11165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // hierarchy when something happens to the hierarchy.
1117a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void UpdateChildLayerBounds(const gfx::Vector2d& offset);
11185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from ui::LayerDelegate:
11205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
11211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void OnDelegatedFrameDamage(
11221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const gfx::Rect& damage_rect_in_dip) OVERRIDE;
11235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
11245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;
11255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finds the layer that this view paints to (it may belong to an ancestor
11275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view), then reorders the immediate children of that layer to match the
11285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // order of the view tree.
11295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ReorderLayers();
11305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This reorders the immediate children of |*parent_layer| to match the
1132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // order of the view tree. Child layers which are owned by a view are
1133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // reordered so that they are below any child layers not owned by a view.
1134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Widget::ReorderNativeViews() should be called to reorder any child layers
1135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // with an associated view. Widget::ReorderNativeViews() may reorder layers
1136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // below layers owned by a view.
11375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ReorderChildLayers(ui::Layer* parent_layer);
11385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Input ---------------------------------------------------------------------
11405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual DragInfo* GetDragInfo();
11422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
11435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus ---------------------------------------------------------------------
11445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns last value passed to SetFocusable(). Use IsFocusable() to determine
11465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // if a view can take focus right now.
11475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool focusable() const { return focusable_; }
11485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Override to be notified when focus has changed either to or from this View.
11505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnFocus();
11515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnBlur();
11525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handle view focus/blur events for this view.
11545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Focus();
11555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Blur();
11565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // System events -------------------------------------------------------------
11585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the UI theme (not the NativeTheme) has changed, overriding
11605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // allows individual Views to do special cleanup and processing (such as
11615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // dropping resource caches).  To dispatch a theme changed notification, call
11625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Widget::ThemeChanged().
11635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnThemeChanged() {}
11645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the locale has changed, overriding allows individual Views to
11665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // update locale-dependent strings.
11675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // To dispatch a locale changed notification, call Widget::LocaleChanged().
11685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnLocaleChanged() {}
11695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tooltips ------------------------------------------------------------------
11715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Views must invoke this when the tooltip text they are to display changes.
11735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void TooltipTextChanged();
11745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Context menus -------------------------------------------------------------
11765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the location, in screen coordinates, to show the context menu at
11785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when the context menu is shown from the keyboard. This implementation
11795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // returns the middle of the visible region of this view.
11805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
11815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is invoked when the context menu is shown by way of the
11825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // keyboard.
11835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Point GetKeyboardContextMenuLocation();
11845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Drag and drop -------------------------------------------------------------
11865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These are cover methods that invoke the method of the same name on
11885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the DragController. Subclasses may wish to override rather than install
11895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a DragController.
11905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See DragController for a description of these methods.
11915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetDragOperations(const gfx::Point& press_pt);
11925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WriteDragData(const gfx::Point& press_pt, OSExchangeData* data);
11935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether we're in the middle of a drag session that was initiated
11955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by us.
11965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool InDrag();
11975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns how much the mouse needs to move in one direction to start a
11995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // drag. These methods cache in a platform-appropriate way. These values are
12005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used by the public static method ExceededDragThreshold().
12015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static int GetHorizontalDragThreshold();
12025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static int GetVerticalDragThreshold();
12035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NativeTheme ---------------------------------------------------------------
12055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when the NativeTheme associated with this View changes.
12075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) {}
12085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Debugging -----------------------------------------------------------------
12105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(NDEBUG)
12125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns string containing a graph of the views hierarchy in graphViz DOT
12135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // language (http://graphviz.org/). Can be called within debugger and save
12145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to a file to compile/view.
12155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: Assumes initial call made with first = true.
12165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual std::string PrintViewGraph(bool first);
12175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Some classes may own an object which contains the children to displayed in
12195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the views hierarchy. The above function gives the class the flexibility to
12205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // decide which object should be used to obtain the children, but this
12215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // function makes the decision explicit.
12225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string DoPrintViewGraph(bool first, View* view_with_children);
12235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
12245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1226e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  friend class internal::PreEventDispatchHandler;
12272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class internal::PostEventDispatchHandler;
12285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class internal::RootView;
12295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class FocusManager;
12305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class Widget;
12315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  typedef gfx::RTree<intptr_t> BoundsTree;
12336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
12345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Painting  -----------------------------------------------------------------
12355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum SchedulePaintType {
12375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Indicates the size is the same (only the origin changed).
12385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SCHEDULE_PAINT_SIZE_SAME,
12395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Indicates the size changed (and possibly the origin).
12415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SCHEDULE_PAINT_SIZE_CHANGED
12425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
12435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked before and after the bounds change to schedule painting the old and
12455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // new bounds.
12465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SchedulePaintBoundsChanged(SchedulePaintType type);
12475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Common Paint() code shared by accelerated and non-accelerated code paths to
12495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoke OnPaint() on the View.
1250cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void PaintCommon(gfx::Canvas* canvas, const CullSet& cull_set);
12515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tree operations -----------------------------------------------------------
12535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Removes |view| from the hierarchy tree.  If |update_focus_cycle| is true,
12555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the next and previous focusable views of views pointing to this view are
12565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // updated.  If |update_tool_tip| is true, the tooltip is updated.  If
12575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |delete_removed_view| is true, the view is also deleted (if it is parent
1258a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // owned).  If |new_parent| is not NULL, the remove is the result of
1259a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // AddChildView() to a new parent.  For this case, |new_parent| is the View
1260a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // that |view| is going to be added to after the remove completes.
12615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DoRemoveChildView(View* view,
12625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         bool update_focus_cycle,
12635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         bool update_tool_tip,
1264a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                         bool delete_removed_view,
1265a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                         View* new_parent);
12665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1267a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Call ViewHierarchyChanged() for all child views and all parents.
1268a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // |old_parent| is the original parent of the View that was removed.
1269a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // If |new_parent| is not NULL, the View that was removed will be reparented
1270a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // to |new_parent| after the remove operation.
1271a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void PropagateRemoveNotifications(View* old_parent, View* new_parent);
12725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1273a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Call ViewHierarchyChanged() for all children.
1274a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void PropagateAddNotifications(const ViewHierarchyChangedDetails& details);
12755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Propagates NativeViewHierarchyChanged() notification through all the
12775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // children.
1278424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  void PropagateNativeViewHierarchyChanged();
12795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Takes care of registering/unregistering accelerators if
12815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |register_accelerators| true and calls ViewHierarchyChanged().
12825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ViewHierarchyChangedImpl(bool register_accelerators,
1283a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                const ViewHierarchyChangedDetails& details);
12845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invokes OnNativeThemeChanged() on this and all descendants.
12865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PropagateNativeThemeChanged(const ui::NativeTheme* theme);
12875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size and disposition ------------------------------------------------------
12895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Call VisibilityChanged() recursively for all children.
12915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PropagateVisibilityNotifications(View* from, bool is_visible);
12925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registers/unregisters accelerators as necessary and calls
12945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // VisibilityChanged().
12955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void VisibilityChangedImpl(View* starting_from, bool is_visible);
12965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Responsible for propagating bounds change notifications to relevant
12985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views.
12995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void BoundsChanged(const gfx::Rect& previous_bounds);
13005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Visible bounds notification registration.
13025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When a view is added to a hierarchy, it and all its children are asked if
13035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // they need to be registered for "visible bounds within root" notifications
13045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (see comment on OnVisibleBoundsChanged()). If they do, they are registered
13055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // with every ancestor between them and the root of the hierarchy.
13065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void RegisterChildrenForVisibleBoundsNotification(View* view);
13075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void UnregisterChildrenForVisibleBoundsNotification(View* view);
13085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RegisterForVisibleBoundsNotification();
13095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UnregisterForVisibleBoundsNotification();
13105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Adds/removes view to the list of descendants that are notified any time
13125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this views location and possibly size are changed.
13135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddDescendantToNotify(View* view);
13145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RemoveDescendantToNotify(View* view);
13155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the layer's bounds given in DIP coordinates.
13175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetLayerBounds(const gfx::Rect& bounds_in_dip);
13185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1319cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Sets the bit indicating that the cached bounds for this object within the
1320cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // root view bounds tree are no longer valid. If |origin_changed| is true sets
1321cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // the same bit for all of our children as well.
1322cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void SetRootBoundsDirty(bool origin_changed);
1323cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
1324cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // If needed, updates the bounds rectangle in paint root coordinate space
1325cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // in the supplied RTree. Recurses to children for recomputation as well.
13266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  void UpdateRootBounds(BoundsTree* bounds_tree, const gfx::Vector2d& offset);
1327cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
1328cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Remove self and all children from the supplied bounds tree. This is used,
1329cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // for example, when a view gets a layer and therefore becomes paint root. It
1330cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // needs to remove all references to itself and its children from any previous
1331cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // paint root that may have been tracking it.
13326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  void RemoveRootBounds(BoundsTree* bounds_tree);
1333cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
1334cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Traverse up the View hierarchy to the first ancestor that is a paint root
1335cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // and return a pointer to its |bounds_tree_| or NULL if no tree is found.
13366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  BoundsTree* GetBoundsTreeFromPaintRoot();
1337cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
13385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Transformations -----------------------------------------------------------
13395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns in |transform| the transform to get from coordinates of |ancestor|
13415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to this. Returns true if |ancestor| is found. If |ancestor| is not found,
13425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // or NULL, |transform| is set to convert from root view coordinates to this.
13435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetTransformRelativeTo(const View* ancestor,
13445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              gfx::Transform* transform) const;
13455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Coordinate conversion -----------------------------------------------------
13475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point in the view's coordinate to an ancestor view's coordinate
13495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system using necessary transformations. Returns whether the point was
13505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // successfully converted to the ancestor's coordinate system.
13515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ConvertPointForAncestor(const View* ancestor, gfx::Point* point) const;
13525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convert a point in the ancestor's coordinate system to the view's
13545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinate system using necessary transformations. Returns whether the
13558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // point was successfully converted from the ancestor's coordinate system
13568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // to the view's coordinate system.
13575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ConvertPointFromAncestor(const View* ancestor, gfx::Point* point) const;
13585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Convert a rect in the view's coordinate to an ancestor view's coordinate
13608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // system using necessary transformations. Returns whether the rect was
13618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // successfully converted to the ancestor's coordinate system.
13628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool ConvertRectForAncestor(const View* ancestor, gfx::RectF* rect) const;
13638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
13648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Convert a rect in the ancestor's coordinate system to the view's
13658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // coordinate system using necessary transformations. Returns whether the
13668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // rect was successfully converted from the ancestor's coordinate system
13678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // to the view's coordinate system.
13688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool ConvertRectFromAncestor(const View* ancestor, gfx::RectF* rect) const;
13698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
13705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerated painting ------------------------------------------------------
13715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates the layer and related fields for this view.
13735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CreateLayer();
13745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Parents all un-parented layers within this view's hierarchy to this view's
13765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // layer.
13775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateParentLayers();
13785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Parents this view's layer to |parent_layer|, and sets its bounds and other
13805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // properties in accordance to |offset|, the view's offset from the
13815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |parent_layer|.
13822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer);
13835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to update the layer visibility. The layer will be visible if the
13855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // View itself, and all its parent Views are visible. This also updates
13865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // visibility of the child layers.
13875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateLayerVisibility();
13885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateChildLayerVisibility(bool visible);
13895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Orphans the layers in this subtree that are parented to layers outside of
13915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this subtree.
13925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OrphanLayers();
13935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Destroys the layer associated with this view, and reparents any descendants
13955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to the destroyed layer's parent.
13965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DestroyLayer();
13975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Input ---------------------------------------------------------------------
13995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool ProcessMousePressed(const ui::MouseEvent& event);
14012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool ProcessMouseDragged(const ui::MouseEvent& event);
14025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ProcessMouseReleased(const ui::MouseEvent& event);
14035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerators --------------------------------------------------------------
14055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registers this view's keyboard accelerators that are not registered to
14075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // FocusManager yet, if possible.
14085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RegisterPendingAccelerators();
14095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Unregisters all the keyboard accelerators associated with this view.
14115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |leave_data_intact| if true does not remove data from accelerators_ array,
14125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // so it could be re-registered with other focus manager
14135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UnregisterAccelerators(bool leave_data_intact);
14145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus ---------------------------------------------------------------------
14165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initialize the previous/next focusable views of the specified view relative
14185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to the view at the specified index.
14195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InitFocusSiblings(View* view, int index);
14205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Helper function to advance focus, in case the currently focused view has
14226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // become unfocusable.
14236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void AdvanceFocusIfNecessary();
14246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
14255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // System events -------------------------------------------------------------
14265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to propagate theme changed notifications from the root view to all
14285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views in the hierarchy.
14295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void PropagateThemeChanged();
14305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to propagate locale changed notifications from the root view to all
14325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views in the hierarchy.
14335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void PropagateLocaleChanged();
14345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tooltips ------------------------------------------------------------------
14365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Propagates UpdateTooltip() to the TooltipManager for the Widget.
14385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This must be invoked any time the View hierarchy changes in such a way
14395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the view under the mouse differs. For example, if the bounds of a View is
14405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // changed, this is invoked. Similarly, as Views are added/removed, this
14415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is invoked.
14425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateTooltip();
14435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Drag and drop -------------------------------------------------------------
14455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Starts a drag and drop operation originating from this view. This invokes
14475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WriteDragData to write the data and GetDragOperations to determine the
14485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // supported drag operations. When done, OnDragDone is invoked. |press_pt| is
14495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in the view's coordinate system.
14505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if a drag was started.
14515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool DoDrag(const ui::LocatedEvent& event,
14525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)              const gfx::Point& press_pt,
14535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)              ui::DragDropTypes::DragEventSource source);
14545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //////////////////////////////////////////////////////////////////////////////
14565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creation and lifetime -----------------------------------------------------
14585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // False if this View is owned by its parent - i.e. it will be deleted by its
14605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // parent during its parents destruction. False is the default.
14615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool owned_by_client_;
14625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Attributes ----------------------------------------------------------------
14645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The id of this View. Used to find this View.
14665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int id_;
14675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The group of this view. Some view subclasses use this id to find other
14695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views of the same group. For example radio button uses this information
14705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to find other radio buttons.
14715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int group_;
14725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tree operations -----------------------------------------------------------
14745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This view's parent.
14765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* parent_;
14775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This view's children.
14795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Views children_;
14805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size and disposition ------------------------------------------------------
14825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This View's bounds in the parent coordinate system.
14845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect bounds_;
14855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this view is visible.
14875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool visible_;
14885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this view is enabled.
14905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool enabled_;
14915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When this flag is on, a View receives a mouse-enter and mouse-leave event
14935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // even if a descendant View is the event-recipient for the real mouse
14945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // events. When this flag is turned on, and mouse moves from outside of the
14955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // view into a child view, both the child view and this view receives
14965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // mouse-enter event. Similarly, if the mouse moves from inside a child view
14975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and out of this view, then both views receive a mouse-leave event.
14985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When this flag is turned off, if the mouse moves from inside this view into
14995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a child view, then this view receives a mouse-leave event. When this flag
15005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is turned on, it does not receive the mouse-leave event in this case.
15015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When the mouse moves from inside the child view out of the child view but
15025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // still into this view, this view receives a mouse-enter event if this flag
15035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is turned off, but doesn't if this flag is turned on.
15045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This flag is initialized to false.
15055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool notify_enter_exit_on_child_;
15065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether or not RegisterViewForVisibleBoundsNotification on the RootView
15085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // has been invoked.
15095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool registered_for_visible_bounds_notification_;
15105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // List of descendants wanting notification when their visible bounds change.
15125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<Views> descendants_to_notify_;
15135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1514cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // True if the bounds on this object have changed since the last time the
1515cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // paint root view constructed the spatial database.
1516cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  bool root_bounds_dirty_;
1517cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
1518cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // If this View IsPaintRoot() then this will be a pointer to a spatial data
1519cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // structure where we will keep the bounding boxes of all our children, for
1520cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // efficient paint damage rectangle intersection.
15216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  scoped_ptr<BoundsTree> bounds_tree_;
1522cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
15235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Transformations -----------------------------------------------------------
15245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Clipping parameters. skia transformation matrix does not give us clipping.
15265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // So we do it ourselves.
15275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Insets clip_insets_;
15285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Layout --------------------------------------------------------------------
15305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether the view needs to be laid out.
15325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool needs_layout_;
15335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The View's LayoutManager defines the sizing heuristics applied to child
15355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Views. The default is absolute positioning according to bounds_.
15365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<LayoutManager> layout_manager_;
15375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1538116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Whether this View's layer should be snapped to the pixel boundary.
1539116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool snap_layer_to_pixel_boundary_;
1540116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
15415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Painting ------------------------------------------------------------------
15425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Background
15445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<Background> background_;
15455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Border.
15475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<Border> border_;
15485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RTL painting --------------------------------------------------------------
15505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates whether or not the gfx::Canvas object passed to View::Paint()
15525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is going to be flipped horizontally (using the appropriate transform) on
15535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // right-to-left locales for this View.
15545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool flip_canvas_on_paint_for_rtl_ui_;
15555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerated painting ------------------------------------------------------
15575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool paint_to_layer_;
15595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accelerators --------------------------------------------------------------
15615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus manager accelerators registered on.
15635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FocusManager* accelerator_focus_manager_;
15645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The list of accelerators. List elements in the range
15665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // [0, registered_accelerator_count_) are already registered to FocusManager,
15675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and the rest are not yet.
15685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<std::vector<ui::Accelerator> > accelerators_;
15695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  size_t registered_accelerator_count_;
15705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Focus ---------------------------------------------------------------------
15725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Next view to be focused when the Tab key is pressed.
15745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* next_focusable_view_;
15755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Next view to be focused when the Shift-Tab key combination is pressed.
15775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  View* previous_focusable_view_;
15785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this view can be focused.
15805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool focusable_;
15815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this view is focusable if the user requires full keyboard access,
15835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // even though it may not be normally focusable.
15845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool accessibility_focusable_;
15855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Context menus -------------------------------------------------------------
15875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The menu controller.
15895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ContextMenuController* context_menu_controller_;
15905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Drag and drop -------------------------------------------------------------
15925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DragController* drag_controller_;
15945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Input  --------------------------------------------------------------------
15962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1597116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  scoped_ptr<ViewTargeter> targeter_;
15982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
15995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Accessibility -------------------------------------------------------------
16005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Belongs to this view, but it's reference-counted on some platforms
16022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // so we can't use a scoped_ptr. It's dereferenced in the destructor.
16032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  NativeViewAccessibility* native_view_accessibility_;
16045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(View);
16065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
16075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace views
16095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // UI_VIEWS_VIEW_H_
1611