| 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_RECT_F_H_ | 5 #ifndef UI_GFX_RECT_F_H_ |
| 6 #define UI_GFX_RECT_F_H_ | 6 #define UI_GFX_RECT_F_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
| 11 #include "ui/gfx/rect_base.h" | 11 #include "ui/gfx/rect_base.h" |
| 12 #include "ui/gfx/size_f.h" | 12 #include "ui/gfx/size_f.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 | 15 |
| 16 class InsetsF; | 16 class InsetsF; |
| 17 | 17 |
| 18 // A floating version of gfx::Rect. | 18 // A floating version of gfx::Rect. |
| 19 class UI_EXPORT RectF : public RectBase<RectF, PointF, SizeF, InsetsF, float> { | 19 class UI_EXPORT RectF : public RectBase<RectF, PointF, SizeF, InsetsF, float> { |
| 20 public: | 20 public: |
| 21 RectF(); | 21 RectF(); |
| 22 RectF(float width, float height); | 22 RectF(float width, float height); |
| 23 RectF(float x, float y, float width, float height); | 23 RectF(float x, float y, float width, float height); |
| 24 explicit RectF(const gfx::SizeF& size); | 24 explicit RectF(const gfx::SizeF& size); |
| 25 RectF(const gfx::PointF& origin, const gfx::SizeF& size); | 25 RectF(const gfx::PointF& origin, const gfx::SizeF& size); |
| 26 | 26 |
| 27 ~RectF(); | 27 ~RectF(); |
| 28 | 28 |
| 29 /// Scales the rectangle by |scale|. | 29 /// Scales the rectangle by |scale|. |
| 30 RectF Scale(float scale) const WARN_UNUSED_RESULT { | 30 void Scale(float scale) { |
| 31 return Scale(scale, scale); | 31 Scale(scale, scale); |
| 32 } | 32 } |
| 33 | 33 |
| 34 RectF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { | 34 void Scale(float x_scale, float y_scale) { |
| 35 SizeF newSize = size().Scale(x_scale, y_scale); | 35 SizeF newSize = size().Scale(x_scale, y_scale); |
| 36 newSize.ClampToNonNegative(); | 36 newSize.ClampToNonNegative(); |
| 37 return RectF(origin().Scale(x_scale, y_scale), newSize); | 37 set_origin(origin().Scale(x_scale, y_scale)); |
| 38 set_size(newSize); |
| 38 } | 39 } |
| 39 | 40 |
| 40 std::string ToString() const; | 41 std::string ToString() const; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 inline bool operator==(const RectF& lhs, const RectF& rhs) { | 44 inline bool operator==(const RectF& lhs, const RectF& rhs) { |
| 44 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); | 45 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 inline bool operator!=(const RectF& lhs, const RectF& rhs) { | 48 inline bool operator!=(const RectF& lhs, const RectF& rhs) { |
| 48 return !(lhs == rhs); | 49 return !(lhs == rhs); |
| 49 } | 50 } |
| 50 | 51 |
| 51 #if !defined(COMPILER_MSVC) | 52 #if !defined(COMPILER_MSVC) |
| 52 extern template class RectBase<RectF, PointF, SizeF, InsetsF, float>; | 53 extern template class RectBase<RectF, PointF, SizeF, InsetsF, float>; |
| 53 #endif | 54 #endif |
| 54 | 55 |
| 55 } // namespace gfx | 56 } // namespace gfx |
| 56 | 57 |
| 57 #endif // UI_GFX_RECT_F_H_ | 58 #endif // UI_GFX_RECT_F_H_ |
| OLD | NEW |