insets_f.h 1.4 KB

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