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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 : public RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> { | 21 : public RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> { |
22 public: | 22 public: |
23 RectF(); | 23 RectF(); |
24 RectF(float width, float height); | 24 RectF(float width, float height); |
25 RectF(float x, float y, float width, float height); | 25 RectF(float x, float y, float width, float height); |
26 explicit RectF(const gfx::SizeF& size); | 26 explicit RectF(const gfx::SizeF& size); |
27 RectF(const gfx::PointF& origin, const gfx::SizeF& size); | 27 RectF(const gfx::PointF& origin, const gfx::SizeF& size); |
28 | 28 |
29 ~RectF(); | 29 ~RectF(); |
30 | 30 |
31 /// Scales the rectangle by |scale|. | 31 // Scales the rectangle by |scale|. |
32 void Scale(float scale) { | 32 void Scale(float scale) { |
33 Scale(scale, scale); | 33 Scale(scale, scale); |
34 } | 34 } |
35 | 35 |
36 void Scale(float x_scale, float y_scale) { | 36 void Scale(float x_scale, float y_scale) { |
37 set_origin(ScalePoint(origin(), x_scale, y_scale)); | 37 set_origin(ScalePoint(origin(), x_scale, y_scale)); |
38 | 38 |
39 SizeF new_size = size().Scale(x_scale, y_scale); | 39 SizeF new_size = gfx::ScaleSize(size(), x_scale, y_scale); |
40 new_size.ClampToNonNegative(); | 40 new_size.ClampToNonNegative(); |
41 set_size(new_size); | 41 set_size(new_size); |
42 } | 42 } |
43 | 43 |
44 // This method reports if the RectF can be safely converted to an integer | 44 // This method reports if the RectF can be safely converted to an integer |
45 // Rect. When it is false, some dimension of the RectF is outside the bounds | 45 // Rect. When it is false, some dimension of the RectF is outside the bounds |
46 // of what an integer can represent, and converting it to a Rect will require | 46 // of what an integer can represent, and converting it to a Rect will require |
47 // clamping. | 47 // clamping. |
48 bool IsExpressibleAsRect() const; | 48 bool IsExpressibleAsRect() const; |
49 | 49 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // contained within the rect, because they will appear on one of these edges. | 82 // contained within the rect, because they will appear on one of these edges. |
83 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); | 83 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); |
84 | 84 |
85 #if !defined(COMPILER_MSVC) | 85 #if !defined(COMPILER_MSVC) |
86 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; | 86 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; |
87 #endif | 87 #endif |
88 | 88 |
89 } // namespace gfx | 89 } // namespace gfx |
90 | 90 |
91 #endif // UI_GFX_RECT_F_H_ | 91 #endif // UI_GFX_RECT_F_H_ |
OLD | NEW |