blob: a86d1cec074599536e4fa73b64271e42942b3645 [file] [log] [blame]
Xianzhu Wanga1aa0552022-01-11 05:45:571// 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 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.
15class GEOMETRY_EXPORT OutsetsF : public InsetsOutsetsFBase<OutsetsF> {
16 public:
17 using InsetsOutsetsFBase::InsetsOutsetsFBase;
Xianzhu Wange01a69a2022-03-16 06:10:3918
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 Wanga1aa0552022-01-11 05:45:5727};
28
29inline OutsetsF operator+(OutsetsF lhs, const OutsetsF& rhs) {
30 lhs += rhs;
31 return lhs;
32}
33
34inline 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.
42void PrintTo(const OutsetsF&, ::std::ostream* os);
43
44} // namespace gfx
45
46#endif // UI_GFX_GEOMETRY_OUTSETS_F_H_