OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_VIEW_H_ | 5 #ifndef UI_VIEWS_VIEW_H_ |
6 #define UI_VIEWS_VIEW_H_ | 6 #define UI_VIEWS_VIEW_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // For the remove part of move, |move_view| is the new parent of the View | 138 // For the remove part of move, |move_view| is the new parent of the View |
139 // being removed. | 139 // being removed. |
140 // For the add part of move, |move_view| is the old parent of the View being | 140 // For the add part of move, |move_view| is the old parent of the View being |
141 // added. | 141 // added. |
142 View* move_view; | 142 View* move_view; |
143 }; | 143 }; |
144 | 144 |
145 // Creation and lifetime ----------------------------------------------------- | 145 // Creation and lifetime ----------------------------------------------------- |
146 | 146 |
147 View(); | 147 View(); |
148 virtual ~View(); | 148 ~View() override; |
149 | 149 |
150 // By default a View is owned by its parent unless specified otherwise here. | 150 // By default a View is owned by its parent unless specified otherwise here. |
151 void set_owned_by_client() { owned_by_client_ = true; } | 151 void set_owned_by_client() { owned_by_client_ = true; } |
152 | 152 |
153 // Tree operations ----------------------------------------------------------- | 153 // Tree operations ----------------------------------------------------------- |
154 | 154 |
155 // Get the Widget that hosts this View, if any. | 155 // Get the Widget that hosts this View, if any. |
156 virtual const Widget* GetWidget() const; | 156 virtual const Widget* GetWidget() const; |
157 virtual Widget* GetWidget(); | 157 virtual Widget* GetWidget(); |
158 | 158 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter); | 707 scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter); |
708 | 708 |
709 // Returns the ViewTargeter installed on |this| if one exists, | 709 // Returns the ViewTargeter installed on |this| if one exists, |
710 // otherwise returns the ViewTargeter installed on our root view. | 710 // otherwise returns the ViewTargeter installed on our root view. |
711 // The return value is guaranteed to be non-null. | 711 // The return value is guaranteed to be non-null. |
712 ViewTargeter* GetEffectiveViewTargeter() const; | 712 ViewTargeter* GetEffectiveViewTargeter() const; |
713 | 713 |
714 ViewTargeter* targeter() const { return targeter_.get(); } | 714 ViewTargeter* targeter() const { return targeter_.get(); } |
715 | 715 |
716 // Overridden from ui::EventTarget: | 716 // Overridden from ui::EventTarget: |
717 virtual bool CanAcceptEvent(const ui::Event& event) override; | 717 bool CanAcceptEvent(const ui::Event& event) override; |
718 virtual ui::EventTarget* GetParentTarget() override; | 718 ui::EventTarget* GetParentTarget() override; |
719 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 719 scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
720 virtual ui::EventTargeter* GetEventTargeter() override; | 720 ui::EventTargeter* GetEventTargeter() override; |
721 virtual void ConvertEventToTarget(ui::EventTarget* target, | 721 void ConvertEventToTarget(ui::EventTarget* target, |
722 ui::LocatedEvent* event) override; | 722 ui::LocatedEvent* event) override; |
723 | 723 |
724 // Overridden from ui::EventHandler: | 724 // Overridden from ui::EventHandler: |
725 virtual void OnKeyEvent(ui::KeyEvent* event) override; | 725 void OnKeyEvent(ui::KeyEvent* event) override; |
726 virtual void OnMouseEvent(ui::MouseEvent* event) override; | 726 void OnMouseEvent(ui::MouseEvent* event) override; |
727 virtual void OnScrollEvent(ui::ScrollEvent* event) override; | 727 void OnScrollEvent(ui::ScrollEvent* event) override; |
728 virtual void OnTouchEvent(ui::TouchEvent* event) override final; | 728 void OnTouchEvent(ui::TouchEvent* event) final; |
729 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 729 void OnGestureEvent(ui::GestureEvent* event) override; |
730 | 730 |
731 // Accelerators -------------------------------------------------------------- | 731 // Accelerators -------------------------------------------------------------- |
732 | 732 |
733 // Sets a keyboard accelerator for that view. When the user presses the | 733 // Sets a keyboard accelerator for that view. When the user presses the |
734 // accelerator key combination, the AcceleratorPressed method is invoked. | 734 // accelerator key combination, the AcceleratorPressed method is invoked. |
735 // Note that you can set multiple accelerators for a view by invoking this | 735 // Note that you can set multiple accelerators for a view by invoking this |
736 // method several times. Note also that AcceleratorPressed is invoked only | 736 // method several times. Note also that AcceleratorPressed is invoked only |
737 // when CanHandleAccelerators() is true. | 737 // when CanHandleAccelerators() is true. |
738 virtual void AddAccelerator(const ui::Accelerator& accelerator); | 738 virtual void AddAccelerator(const ui::Accelerator& accelerator); |
739 | 739 |
740 // Removes the specified accelerator for this view. | 740 // Removes the specified accelerator for this view. |
741 virtual void RemoveAccelerator(const ui::Accelerator& accelerator); | 741 virtual void RemoveAccelerator(const ui::Accelerator& accelerator); |
742 | 742 |
743 // Removes all the keyboard accelerators for this view. | 743 // Removes all the keyboard accelerators for this view. |
744 virtual void ResetAccelerators(); | 744 virtual void ResetAccelerators(); |
745 | 745 |
746 // Overridden from AcceleratorTarget: | 746 // Overridden from AcceleratorTarget: |
747 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 747 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
748 | 748 |
749 // Returns whether accelerators are enabled for this view. Accelerators are | 749 // Returns whether accelerators are enabled for this view. Accelerators are |
750 // enabled if the containing widget is visible and the view is enabled() and | 750 // enabled if the containing widget is visible and the view is enabled() and |
751 // IsDrawn() | 751 // IsDrawn() |
752 virtual bool CanHandleAccelerators() const override; | 752 bool CanHandleAccelerators() const override; |
753 | 753 |
754 // Focus --------------------------------------------------------------------- | 754 // Focus --------------------------------------------------------------------- |
755 | 755 |
756 // Returns whether this view currently has the focus. | 756 // Returns whether this view currently has the focus. |
757 virtual bool HasFocus() const; | 757 virtual bool HasFocus() const; |
758 | 758 |
759 // Returns the view that should be selected next when pressing Tab. | 759 // Returns the view that should be selected next when pressing Tab. |
760 View* GetNextFocusableView(); | 760 View* GetNextFocusableView(); |
761 const View* GetNextFocusableView() const; | 761 const View* GetNextFocusableView() const; |
762 | 762 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 // recurses through all children. This is used when adding a layer to an | 1110 // recurses through all children. This is used when adding a layer to an |
1111 // existing view to make sure all descendants that have layers are parented to | 1111 // existing view to make sure all descendants that have layers are parented to |
1112 // the right layer. | 1112 // the right layer. |
1113 void MoveLayerToParent(ui::Layer* parent_layer, const gfx::Point& point); | 1113 void MoveLayerToParent(ui::Layer* parent_layer, const gfx::Point& point); |
1114 | 1114 |
1115 // Called to update the bounds of any child layers within this View's | 1115 // Called to update the bounds of any child layers within this View's |
1116 // hierarchy when something happens to the hierarchy. | 1116 // hierarchy when something happens to the hierarchy. |
1117 void UpdateChildLayerBounds(const gfx::Vector2d& offset); | 1117 void UpdateChildLayerBounds(const gfx::Vector2d& offset); |
1118 | 1118 |
1119 // Overridden from ui::LayerDelegate: | 1119 // Overridden from ui::LayerDelegate: |
1120 virtual void OnPaintLayer(gfx::Canvas* canvas) override; | 1120 void OnPaintLayer(gfx::Canvas* canvas) override; |
1121 virtual void OnDelegatedFrameDamage( | 1121 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; |
1122 const gfx::Rect& damage_rect_in_dip) override; | 1122 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
1123 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 1123 base::Closure PrepareForLayerBoundsChange() override; |
1124 virtual base::Closure PrepareForLayerBoundsChange() override; | |
1125 | 1124 |
1126 // Finds the layer that this view paints to (it may belong to an ancestor | 1125 // Finds the layer that this view paints to (it may belong to an ancestor |
1127 // view), then reorders the immediate children of that layer to match the | 1126 // view), then reorders the immediate children of that layer to match the |
1128 // order of the view tree. | 1127 // order of the view tree. |
1129 virtual void ReorderLayers(); | 1128 virtual void ReorderLayers(); |
1130 | 1129 |
1131 // This reorders the immediate children of |*parent_layer| to match the | 1130 // This reorders the immediate children of |*parent_layer| to match the |
1132 // order of the view tree. Child layers which are owned by a view are | 1131 // order of the view tree. Child layers which are owned by a view are |
1133 // reordered so that they are below any child layers not owned by a view. | 1132 // reordered so that they are below any child layers not owned by a view. |
1134 // Widget::ReorderNativeViews() should be called to reorder any child layers | 1133 // Widget::ReorderNativeViews() should be called to reorder any child layers |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 // Belongs to this view, but it's reference-counted on some platforms | 1600 // Belongs to this view, but it's reference-counted on some platforms |
1602 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1601 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
1603 NativeViewAccessibility* native_view_accessibility_; | 1602 NativeViewAccessibility* native_view_accessibility_; |
1604 | 1603 |
1605 DISALLOW_COPY_AND_ASSIGN(View); | 1604 DISALLOW_COPY_AND_ASSIGN(View); |
1606 }; | 1605 }; |
1607 | 1606 |
1608 } // namespace views | 1607 } // namespace views |
1609 | 1608 |
1610 #endif // UI_VIEWS_VIEW_H_ | 1609 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |