| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 gfx::Rect GetVisibleBounds() const; | 266 gfx::Rect GetVisibleBounds() const; |
| 267 | 267 |
| 268 // Return the bounds of the View in screen coordinate system. | 268 // Return the bounds of the View in screen coordinate system. |
| 269 gfx::Rect GetBoundsInScreen() const; | 269 gfx::Rect GetBoundsInScreen() const; |
| 270 | 270 |
| 271 // Returns the baseline of this view, or -1 if this view has no baseline. The | 271 // Returns the baseline of this view, or -1 if this view has no baseline. The |
| 272 // return value is relative to the preferred height. | 272 // return value is relative to the preferred height. |
| 273 virtual int GetBaseline() const; | 273 virtual int GetBaseline() const; |
| 274 | 274 |
| 275 // Get the size the View would like to be, if enough space were available. | 275 // Get the size the View would like to be, if enough space were available. |
| 276 // First checks |preferred_size_|, then |layout_manager_|, then |
| 277 // CalculatePreferredSize(). |
| 278 // TODO(estade): migrate existing GetPreferredSize() overrides to |
| 279 // CalculatePreferredSize() and make this function non-virtual. |
| 276 virtual gfx::Size GetPreferredSize() const; | 280 virtual gfx::Size GetPreferredSize() const; |
| 277 | 281 |
| 282 // Sets the size that this View will request during layout. The actual size |
| 283 // may differ. It should rarely be necessary to set this; usually the right |
| 284 // approach is controlling the parent's layout via a LayoutManager. |
| 285 void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; } |
| 286 |
| 278 // Convenience method that sizes this view to its preferred size. | 287 // Convenience method that sizes this view to its preferred size. |
| 279 void SizeToPreferredSize(); | 288 void SizeToPreferredSize(); |
| 280 | 289 |
| 281 // Gets the minimum size of the view. View's implementation invokes | 290 // Gets the minimum size of the view. View's implementation invokes |
| 282 // GetPreferredSize. | 291 // GetPreferredSize. |
| 283 virtual gfx::Size GetMinimumSize() const; | 292 virtual gfx::Size GetMinimumSize() const; |
| 284 | 293 |
| 285 // Gets the maximum size of the view. Currently only used for sizing shell | 294 // Gets the maximum size of the view. Currently only used for sizing shell |
| 286 // windows. | 295 // windows. |
| 287 virtual gfx::Size GetMaximumSize() const; | 296 virtual gfx::Size GetMaximumSize() const; |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 | 1057 |
| 1049 // Whether the press may generate a drag. | 1058 // Whether the press may generate a drag. |
| 1050 bool possible_drag; | 1059 bool possible_drag; |
| 1051 | 1060 |
| 1052 // Coordinates of the mouse press. | 1061 // Coordinates of the mouse press. |
| 1053 gfx::Point start_pt; | 1062 gfx::Point start_pt; |
| 1054 }; | 1063 }; |
| 1055 | 1064 |
| 1056 // Size and disposition ------------------------------------------------------ | 1065 // Size and disposition ------------------------------------------------------ |
| 1057 | 1066 |
| 1067 // Calculates the natural size for the View, to be taken into consideration |
| 1068 // when the parent is performing layout. |
| 1069 virtual gfx::Size CalculatePreferredSize() const; |
| 1070 |
| 1058 // Override to be notified when the bounds of the view have changed. | 1071 // Override to be notified when the bounds of the view have changed. |
| 1059 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); | 1072 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); |
| 1060 | 1073 |
| 1061 // Called when the preferred size of a child view changed. This gives the | 1074 // Called when the preferred size of a child view changed. This gives the |
| 1062 // parent an opportunity to do a fresh layout if that makes sense. | 1075 // parent an opportunity to do a fresh layout if that makes sense. |
| 1063 virtual void ChildPreferredSizeChanged(View* child) {} | 1076 virtual void ChildPreferredSizeChanged(View* child) {} |
| 1064 | 1077 |
| 1065 // Called when the visibility of a child view changed. This gives the parent | 1078 // Called when the visibility of a child view changed. This gives the parent |
| 1066 // an opportunity to do a fresh layout if that makes sense. | 1079 // an opportunity to do a fresh layout if that makes sense. |
| 1067 virtual void ChildVisibilityChanged(View* child) {} | 1080 virtual void ChildVisibilityChanged(View* child) {} |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 #if DCHECK_IS_ON() | 1578 #if DCHECK_IS_ON() |
| 1566 // True while iterating over |children_|. Used to detect and DCHECK when | 1579 // True while iterating over |children_|. Used to detect and DCHECK when |
| 1567 // |children_| is mutated during iteration. | 1580 // |children_| is mutated during iteration. |
| 1568 mutable bool iterating_; | 1581 mutable bool iterating_; |
| 1569 #endif | 1582 #endif |
| 1570 | 1583 |
| 1571 bool can_process_events_within_subtree_; | 1584 bool can_process_events_within_subtree_; |
| 1572 | 1585 |
| 1573 // Size and disposition ------------------------------------------------------ | 1586 // Size and disposition ------------------------------------------------------ |
| 1574 | 1587 |
| 1588 base::Optional<gfx::Size> preferred_size_; |
| 1589 |
| 1575 // This View's bounds in the parent coordinate system. | 1590 // This View's bounds in the parent coordinate system. |
| 1576 gfx::Rect bounds_; | 1591 gfx::Rect bounds_; |
| 1577 | 1592 |
| 1578 // Whether this view is visible. | 1593 // Whether this view is visible. |
| 1579 bool visible_; | 1594 bool visible_; |
| 1580 | 1595 |
| 1581 // Whether this view is enabled. | 1596 // Whether this view is enabled. |
| 1582 bool enabled_; | 1597 bool enabled_; |
| 1583 | 1598 |
| 1584 // When this flag is on, a View receives a mouse-enter and mouse-leave event | 1599 // When this flag is on, a View receives a mouse-enter and mouse-leave event |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 // Observers ------------------------------------------------------------- | 1708 // Observers ------------------------------------------------------------- |
| 1694 | 1709 |
| 1695 base::ObserverList<ViewObserver> observers_; | 1710 base::ObserverList<ViewObserver> observers_; |
| 1696 | 1711 |
| 1697 DISALLOW_COPY_AND_ASSIGN(View); | 1712 DISALLOW_COPY_AND_ASSIGN(View); |
| 1698 }; | 1713 }; |
| 1699 | 1714 |
| 1700 } // namespace views | 1715 } // namespace views |
| 1701 | 1716 |
| 1702 #endif // UI_VIEWS_VIEW_H_ | 1717 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |