outsets_f.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef UI_GFX_GEOMETRY_OUTSETS_F_H_
  5. #define UI_GFX_GEOMETRY_OUTSETS_F_H_
  6. #include "ui/gfx/geometry/geometry_export.h"
  7. #include "ui/gfx/geometry/insets_f.h"
  8. #include "ui/gfx/geometry/insets_outsets_f_base.h"
  9. namespace gfx {
  10. // A floating point version of gfx::Outsets.
  11. class GEOMETRY_EXPORT OutsetsF : public InsetsOutsetsFBase<OutsetsF> {
  12. public:
  13. using InsetsOutsetsFBase::InsetsOutsetsFBase;
  14. // Conversion from OutsetsF to InsetsF negates all components.
  15. InsetsF ToInsets() const {
  16. return InsetsF()
  17. .set_left(-left())
  18. .set_right(-right())
  19. .set_top(-top())
  20. .set_bottom(-bottom());
  21. }
  22. };
  23. inline OutsetsF operator+(OutsetsF lhs, const OutsetsF& rhs) {
  24. lhs += rhs;
  25. return lhs;
  26. }
  27. inline OutsetsF operator-(OutsetsF lhs, const OutsetsF& rhs) {
  28. lhs -= rhs;
  29. return lhs;
  30. }
  31. // This is declared here for use in gtest-based unit tests but is defined in
  32. // the //ui/gfx:test_support target. Depend on that to use this in your unit
  33. // test. This should not be used in production code - call ToString() instead.
  34. void PrintTo(const OutsetsF&, ::std::ostream* os);
  35. } // namespace gfx
  36. #endif // UI_GFX_GEOMETRY_OUTSETS_F_H_