summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/size_f.h
blob: a38d3f6caffffd1e3eb4941f015bb0c32a4f70cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_SIZE_F_H_
#define UI_GFX_SIZE_F_H_

#include <string>

#include "base/compiler_specific.h"
#include "ui/base/ui_export.h"
#include "ui/gfx/size_base.h"

namespace gfx {

// A floating version of gfx::Size.
class UI_EXPORT SizeF : public SizeBase<SizeF, float> {
 public:
  SizeF() : SizeBase<SizeF, float>(0, 0) {}
  SizeF(float width, float height) : SizeBase<SizeF, float>(width, height) {}
  ~SizeF() {}

  void Scale(float scale) {
    Scale(scale, scale);
  }

  void Scale(float x_scale, float y_scale) {
    SetSize(width() * x_scale, height() * y_scale);
  }

  std::string ToString() const;
};

inline bool operator==(const SizeF& lhs, const SizeF& rhs) {
  return lhs.width() == rhs.width() && lhs.height() == rhs.height();
}

inline bool operator!=(const SizeF& lhs, const SizeF& rhs) {
  return !(lhs == rhs);
}

UI_EXPORT SizeF ScaleSize(const SizeF& p, float x_scale, float y_scale);

inline SizeF ScaleSize(const SizeF& p, float scale) {
  return ScaleSize(p, scale, scale);
}

#if !defined(COMPILER_MSVC)
extern template class SizeBase<SizeF, float>;
#endif

}  // namespace gfx

#endif  // UI_GFX_SIZE_F_H_