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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 void SetTransform(const gfx::Transform& transform); | 333 void SetTransform(const gfx::Transform& transform); |
334 | 334 |
335 // Sets whether this view paints to a layer. A view paints to a layer if | 335 // Sets whether this view paints to a layer. A view paints to a layer if |
336 // either of the following are true: | 336 // either of the following are true: |
337 // . the view has a non-identity transform. | 337 // . the view has a non-identity transform. |
338 // . SetPaintToLayer(ui::LayerType) has been invoked. | 338 // . SetPaintToLayer(ui::LayerType) has been invoked. |
339 // View creates the Layer only when it exists in a Widget with a non-NULL | 339 // View creates the Layer only when it exists in a Widget with a non-NULL |
340 // Compositor. | 340 // Compositor. |
341 void SetPaintToLayer(ui::LayerType layer_type = ui::LAYER_TEXTURED); | 341 void SetPaintToLayer(ui::LayerType layer_type = ui::LAYER_TEXTURED); |
342 | 342 |
343 enum LayerChangeNotifyBehavior { | |
sky
2017/04/18 23:02:21
enum class
ananta
2017/04/18 23:14:46
Done.
| |
344 // Notify the parent chain about the layer change. | |
345 NOTIFY, | |
346 // Don't notify the parent chain about the layer change. | |
347 DONT_NOTIFY | |
348 }; | |
349 | |
350 // Please refer to the comments above the DestroyLayerImpl() function for | |
351 // details. | |
352 void DestroyLayer(); | |
353 | |
343 // Destroys the layer associated with this view, and reparents any descendants | 354 // Destroys the layer associated with this view, and reparents any descendants |
344 // to the destroyed layer's parent. If the view does not currently have a | 355 // to the destroyed layer's parent. If the view does not currently have a |
345 // layer, this has no effect. | 356 // layer, this has no effect. |
346 void DestroyLayer(); | 357 // The |notify_parents| enum controls whether a notification about the layer |
358 // change is sent to the parents. | |
359 void DestroyLayerImpl(LayerChangeNotifyBehavior notify_parents); | |
sky
2017/04/18 23:02:21
Move this (and enum) to the private section in the
ananta
2017/04/18 23:14:46
Done.
| |
347 | 360 |
348 // Overridden from ui::LayerOwner: | 361 // Overridden from ui::LayerOwner: |
349 std::unique_ptr<ui::Layer> RecreateLayer() override; | 362 std::unique_ptr<ui::Layer> RecreateLayer() override; |
350 | 363 |
351 // RTL positioning ----------------------------------------------------------- | 364 // RTL positioning ----------------------------------------------------------- |
352 | 365 |
353 // Methods for accessing the bounds and position of the view, relative to its | 366 // Methods for accessing the bounds and position of the view, relative to its |
354 // parent. The position returned is mirrored if the parent view is using a RTL | 367 // parent. The position returned is mirrored if the parent view is using a RTL |
355 // layout. | 368 // layout. |
356 // | 369 // |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1182 virtual void ReorderLayers(); | 1195 virtual void ReorderLayers(); |
1183 | 1196 |
1184 // This reorders the immediate children of |*parent_layer| to match the | 1197 // This reorders the immediate children of |*parent_layer| to match the |
1185 // order of the view tree. Child layers which are owned by a view are | 1198 // order of the view tree. Child layers which are owned by a view are |
1186 // reordered so that they are below any child layers not owned by a view. | 1199 // reordered so that they are below any child layers not owned by a view. |
1187 // Widget::ReorderNativeViews() should be called to reorder any child layers | 1200 // Widget::ReorderNativeViews() should be called to reorder any child layers |
1188 // with an associated view. Widget::ReorderNativeViews() may reorder layers | 1201 // with an associated view. Widget::ReorderNativeViews() may reorder layers |
1189 // below layers owned by a view. | 1202 // below layers owned by a view. |
1190 virtual void ReorderChildLayers(ui::Layer* parent_layer); | 1203 virtual void ReorderChildLayers(ui::Layer* parent_layer); |
1191 | 1204 |
1205 // Notifies parents about a layer being created or destroyed in a child. An | |
1206 // example where a subclass may override this method is when it wants to clip | |
1207 // the child by adding its own layer. | |
1208 virtual void OnChildLayerChanged(View* child); | |
1209 | |
1192 // Input --------------------------------------------------------------------- | 1210 // Input --------------------------------------------------------------------- |
1193 | 1211 |
1194 virtual DragInfo* GetDragInfo(); | 1212 virtual DragInfo* GetDragInfo(); |
1195 | 1213 |
1196 // Focus --------------------------------------------------------------------- | 1214 // Focus --------------------------------------------------------------------- |
1197 | 1215 |
1198 // Returns last set focus behavior. | 1216 // Returns last set focus behavior. |
1199 FocusBehavior focus_behavior() const { return focus_behavior_; } | 1217 FocusBehavior focus_behavior() const { return focus_behavior_; } |
1200 | 1218 |
1201 // Override to be notified when focus has changed either to or from this View. | 1219 // Override to be notified when focus has changed either to or from this View. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1508 // WriteDragData to write the data and GetDragOperations to determine the | 1526 // WriteDragData to write the data and GetDragOperations to determine the |
1509 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is | 1527 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is |
1510 // in the view's coordinate system. | 1528 // in the view's coordinate system. |
1511 // Returns true if a drag was started. | 1529 // Returns true if a drag was started. |
1512 bool DoDrag(const ui::LocatedEvent& event, | 1530 bool DoDrag(const ui::LocatedEvent& event, |
1513 const gfx::Point& press_pt, | 1531 const gfx::Point& press_pt, |
1514 ui::DragDropTypes::DragEventSource source); | 1532 ui::DragDropTypes::DragEventSource source); |
1515 | 1533 |
1516 ////////////////////////////////////////////////////////////////////////////// | 1534 ////////////////////////////////////////////////////////////////////////////// |
1517 | 1535 |
1536 // Notifies parents about layering changes in the view. This includes layer | |
1537 // creation and destruction. | |
1538 void NotifyParentsOfLayerChange(); | |
sky
2017/04/18 23:02:21
Move this to the "Accelerated painting" section ab
| |
1539 | |
1518 // Creation and lifetime ----------------------------------------------------- | 1540 // Creation and lifetime ----------------------------------------------------- |
1519 | 1541 |
1520 // False if this View is owned by its parent - i.e. it will be deleted by its | 1542 // False if this View is owned by its parent - i.e. it will be deleted by its |
1521 // parent during its parents destruction. False is the default. | 1543 // parent during its parents destruction. False is the default. |
1522 bool owned_by_client_; | 1544 bool owned_by_client_; |
1523 | 1545 |
1524 // Attributes ---------------------------------------------------------------- | 1546 // Attributes ---------------------------------------------------------------- |
1525 | 1547 |
1526 // The id of this View. Used to find this View. | 1548 // The id of this View. Used to find this View. |
1527 int id_; | 1549 int id_; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1670 // Observers ------------------------------------------------------------- | 1692 // Observers ------------------------------------------------------------- |
1671 | 1693 |
1672 base::ObserverList<ViewObserver> observers_; | 1694 base::ObserverList<ViewObserver> observers_; |
1673 | 1695 |
1674 DISALLOW_COPY_AND_ASSIGN(View); | 1696 DISALLOW_COPY_AND_ASSIGN(View); |
1675 }; | 1697 }; |
1676 | 1698 |
1677 } // namespace views | 1699 } // namespace views |
1678 | 1700 |
1679 #endif // UI_VIEWS_VIEW_H_ | 1701 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |