OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 APPS_SIZE_CONSTRAINTS_H_ | 5 #ifndef APPS_SIZE_CONSTRAINTS_H_ |
6 #define APPS_SIZE_CONSTRAINTS_H_ | 6 #define APPS_SIZE_CONSTRAINTS_H_ |
7 | 7 |
8 #include "ui/gfx/geometry/size.h" | 8 #include "ui/gfx/geometry/size.h" |
9 | 9 |
| 10 namespace gfx { |
| 11 class Insets; |
| 12 } |
| 13 |
10 namespace apps { | 14 namespace apps { |
11 | 15 |
12 class SizeConstraints { | 16 class SizeConstraints { |
13 public: | 17 public: |
14 // The value SizeConstraints uses to represent an unbounded width or height. | 18 // The value SizeConstraints uses to represent an unbounded width or height. |
15 // This is an enum so that it can be declared inline here. | 19 // This is an enum so that it can be declared inline here. |
16 enum { kUnboundedSize = 0 }; | 20 enum { kUnboundedSize = 0 }; |
17 | 21 |
18 SizeConstraints(); | 22 SizeConstraints(); |
19 SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size); | 23 SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size); |
20 ~SizeConstraints(); | 24 ~SizeConstraints(); |
21 | 25 |
| 26 // Adds frame insets to a size constraint. |
| 27 static gfx::Size AddFrameToConstraints(const gfx::Size& size_constraints, |
| 28 const gfx::Insets& frame_insets); |
| 29 |
22 // Returns the bounds with its size clamped to the min/max size. | 30 // Returns the bounds with its size clamped to the min/max size. |
23 gfx::Size ClampSize(gfx::Size size) const; | 31 gfx::Size ClampSize(gfx::Size size) const; |
24 | 32 |
25 // When gfx::Size is used as a min/max size, a zero represents an unbounded | 33 // When gfx::Size is used as a min/max size, a zero represents an unbounded |
26 // component. This method checks whether either component is specified. | 34 // component. This method checks whether either component is specified. |
27 // Note we can't use gfx::Size::IsEmpty as it returns true if either width | 35 // Note we can't use gfx::Size::IsEmpty as it returns true if either width |
28 // or height is zero. | 36 // or height is zero. |
29 bool HasMinimumSize() const; | 37 bool HasMinimumSize() const; |
30 bool HasMaximumSize() const; | 38 bool HasMaximumSize() const; |
31 | 39 |
32 // This returns true if all components are specified, and min and max are | 40 // This returns true if all components are specified, and min and max are |
33 // equal. | 41 // equal. |
34 bool HasFixedSize() const; | 42 bool HasFixedSize() const; |
35 | 43 |
36 gfx::Size GetMaximumSize() const; | 44 gfx::Size GetMaximumSize() const; |
37 gfx::Size GetMinimumSize() const; | 45 gfx::Size GetMinimumSize() const; |
38 | 46 |
39 void set_minimum_size(const gfx::Size& min_size); | 47 void set_minimum_size(const gfx::Size& min_size); |
40 void set_maximum_size(const gfx::Size& max_size); | 48 void set_maximum_size(const gfx::Size& max_size); |
41 | 49 |
42 private: | 50 private: |
43 gfx::Size minimum_size_; | 51 gfx::Size minimum_size_; |
44 gfx::Size maximum_size_; | 52 gfx::Size maximum_size_; |
45 }; | 53 }; |
46 | 54 |
47 } // namespace apps | 55 } // namespace apps |
48 | 56 |
49 #endif // APPS_SIZE_CONSTRAINTS_H_ | 57 #endif // APPS_SIZE_CONSTRAINTS_H_ |
OLD | NEW |