Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 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 | |
Kalvin Lee | ba222e7 | 2024-11-21 04:18:44 | [diff] [blame] | 8 | #include "base/component_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. |
Kalvin Lee | ba222e7 | 2024-11-21 04:18:44 | [diff] [blame] | 15 | class COMPONENT_EXPORT(GEOMETRY) OutsetsF |
| 16 | : public InsetsOutsetsFBase<OutsetsF> { |
Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 17 | public: |
| 18 | using InsetsOutsetsFBase::InsetsOutsetsFBase; |
Xianzhu Wang | e01a69a | 2022-03-16 06:10:39 | [diff] [blame] | 19 | |
| 20 | // Conversion from OutsetsF to InsetsF negates all components. |
| 21 | InsetsF ToInsets() const { |
| 22 | return InsetsF() |
| 23 | .set_left(-left()) |
| 24 | .set_right(-right()) |
| 25 | .set_top(-top()) |
| 26 | .set_bottom(-bottom()); |
| 27 | } |
Xianzhu Wang | a1aa055 | 2022-01-11 05:45:57 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | inline OutsetsF operator+(OutsetsF lhs, const OutsetsF& rhs) { |
| 31 | lhs += rhs; |
| 32 | return lhs; |
| 33 | } |
| 34 | |
| 35 | inline OutsetsF operator-(OutsetsF lhs, const OutsetsF& rhs) { |
| 36 | lhs -= rhs; |
| 37 | return lhs; |
| 38 | } |
| 39 | |
| 40 | // This is declared here for use in gtest-based unit tests but is defined in |
| 41 | // the //ui/gfx:test_support target. Depend on that to use this in your unit |
| 42 | // test. This should not be used in production code - call ToString() instead. |
| 43 | void PrintTo(const OutsetsF&, ::std::ostream* os); |
| 44 | |
| 45 | } // namespace gfx |
| 46 | |
| 47 | #endif // UI_GFX_GEOMETRY_OUTSETS_F_H_ |