blob: 2b7b6e64cf677f624e7526f54a3ee429cfd42870 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2022 The Chromium Authors
Xianzhu Wanga1aa0552022-01-11 05:45:572// 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 Leeba222e72024-11-21 04:18:448#include "base/component_export.h"
Xianzhu Wange01a69a2022-03-16 06:10:399#include "ui/gfx/geometry/insets_f.h"
Xianzhu Wanga1aa0552022-01-11 05:45:5710#include "ui/gfx/geometry/insets_outsets_f_base.h"
11
12namespace gfx {
13
14// A floating point version of gfx::Outsets.
Kalvin Leeba222e72024-11-21 04:18:4415class COMPONENT_EXPORT(GEOMETRY) OutsetsF
16 : public InsetsOutsetsFBase<OutsetsF> {
Xianzhu Wanga1aa0552022-01-11 05:45:5717 public:
18 using InsetsOutsetsFBase::InsetsOutsetsFBase;
Xianzhu Wange01a69a2022-03-16 06:10:3919
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 Wanga1aa0552022-01-11 05:45:5728};
29
30inline OutsetsF operator+(OutsetsF lhs, const OutsetsF& rhs) {
31 lhs += rhs;
32 return lhs;
33}
34
35inline 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.
43void PrintTo(const OutsetsF&, ::std::ostream* os);
44
45} // namespace gfx
46
47#endif // UI_GFX_GEOMETRY_OUTSETS_F_H_