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_GFX_SIZE_BASE_H_ | 5 #ifndef UI_GFX_SIZE_BASE_H_ |
6 #define UI_GFX_SIZE_BASE_H_ | 6 #define UI_GFX_SIZE_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 void Enlarge(Type width, Type height) { | 30 void Enlarge(Type width, Type height) { |
31 set_width(width_ + width); | 31 set_width(width_ + width); |
32 set_height(height_ + height); | 32 set_height(height_ + height); |
33 } | 33 } |
34 | 34 |
35 void set_width(Type width) { width_ = width; } | 35 void set_width(Type width) { width_ = width; } |
36 void set_height(Type height) { height_ = height; } | 36 void set_height(Type height) { height_ = height; } |
37 | 37 |
38 bool operator==(const Class& s) const { | |
39 return width_ == s.width_ && height_ == s.height_; | |
40 } | |
41 | |
42 bool operator!=(const Class& s) const { | |
43 return !(*this == s); | |
44 } | |
45 | |
46 bool IsEmpty() const { | 38 bool IsEmpty() const { |
47 return (width_ <= 0) || (height_ <= 0); | 39 return (width_ <= 0) || (height_ <= 0); |
48 } | 40 } |
49 | 41 |
50 void ClampToNonNegative() { | 42 void ClampToNonNegative() { |
51 if (width_ < 0) | 43 if (width_ < 0) |
52 width_ = 0; | 44 width_ = 0; |
53 if (height_ < 0) | 45 if (height_ < 0) |
54 height_ = 0; | 46 height_ = 0; |
55 } | 47 } |
56 | 48 |
57 protected: | 49 protected: |
58 SizeBase(Type width, Type height) | 50 SizeBase(Type width, Type height) |
59 : width_(width), | 51 : width_(width), |
60 height_(height) {} | 52 height_(height) {} |
61 | 53 |
62 // Destructor is intentionally made non virtual and protected. | 54 // Destructor is intentionally made non virtual and protected. |
63 // Do not make this public. | 55 // Do not make this public. |
64 ~SizeBase() {} | 56 ~SizeBase() {} |
65 | 57 |
66 private: | 58 private: |
67 Type width_; | 59 Type width_; |
68 Type height_; | 60 Type height_; |
69 }; | 61 }; |
70 | 62 |
71 } // namespace gfx | 63 } // namespace gfx |
72 | 64 |
73 #endif // UI_GFX_SIZE_BASE_H_ | 65 #endif // UI_GFX_SIZE_BASE_H_ |
OLD | NEW |