Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_GFX_GEOMETRY_OUTSETS_F_H_ |
| 6 | #define UI_GFX_GEOMETRY_OUTSETS_F_H_ |
| 7 | |
| 8 | #include "ui/gfx/geometry/geometry_export.h" |
Xianzhu Wang | e01a69a | 2022-03-16 06:10:39 | [diff] [blame^] | 9 | #include "ui/gfx/geometry/insets_f.h" |
Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 10 | #include "ui/gfx/geometry/insets_outsets_f_base.h" |
| 11 | |
| 12 | namespace gfx { |
| 13 | |
| 14 | // A floating point version of gfx::Outsets. |
| 15 | class GEOMETRY_EXPORT OutsetsF : public InsetsOutsetsFBase<OutsetsF> { |
| 16 | public: |
| 17 | using InsetsOutsetsFBase::InsetsOutsetsFBase; |
Xianzhu Wang | e01a69a | 2022-03-16 06:10:39 | [diff] [blame^] | 18 | |
| 19 | // Conversion from OutsetsF to InsetsF negates all components. |
| 20 | InsetsF ToInsets() const { |
| 21 | return InsetsF() |
| 22 | .set_left(-left()) |
| 23 | .set_right(-right()) |
| 24 | .set_top(-top()) |
| 25 | .set_bottom(-bottom()); |
| 26 | } |
Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | inline OutsetsF operator+(OutsetsF lhs, const OutsetsF& rhs) { |
| 30 | lhs += rhs; |
| 31 | return lhs; |
| 32 | } |
| 33 | |
| 34 | inline OutsetsF operator-(OutsetsF lhs, const OutsetsF& rhs) { |
| 35 | lhs -= rhs; |
| 36 | return lhs; |
| 37 | } |
| 38 | |
| 39 | // This is declared here for use in gtest-based unit tests but is defined in |
| 40 | // the //ui/gfx:test_support target. Depend on that to use this in your unit |
| 41 | // test. This should not be used in production code - call ToString() instead. |
| 42 | void PrintTo(const OutsetsF&, ::std::ostream* os); |
| 43 | |
| 44 | } // namespace gfx |
| 45 | |
| 46 | #endif // UI_GFX_GEOMETRY_OUTSETS_F_H_ |