PSizef.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 #include <PMath.h>
18 
19 PAPILLON_BEGIN_NAMESPACE
20 
21 class PSizei;
22 
28 class PAPILLON_API_CORE PSizef : public PObject
29 {
30 public:
34  static const PSizef& Zero() { static const PSizef ZERO(0.0f,0.0f); return ZERO; }
35 
39  static const PSizef& Bad() { static const PSizef BAD(PMath::NaNf(),PMath::NaNf()); return BAD; }
40 
44  PSizef();
45 
49  explicit PSizef(float s);
50 
54  explicit PSizef(float width, float height);
55 
59  PSizef(const PSizef& other);
60 
64  virtual ~PSizef();
65 
69  PSizef& operator=(const PSizef& other);
70 
75  bool operator==(const PSizef& other) const;
76 
81  bool operator!=(const PSizef& other) const;
82 
87  bool IsValid() const;
88 
92  float GetWidth() const;
93 
97  float GetHeight() const;
98 
102  PSizef Scaled(float factor) const;
103 
107  PSizef Clamped(float min, float max);
108 
113  PSizef ClampedWH(float minW, float maxW, float minH, float maxH);
114 
118  PSizei ToSizei() const;
119 
126  static PResult FromString(const PString& s, PSizef& size);
127 
131  PString ToStringShort() const;
132 };
133 
134 PAPILLON_END_NAMESPACE
static float NaNf()
Returns NaN (Not a Number) value for float numbers.
Definition: PMath.h:41
The PString class provides an Unicode character strings.
Definition: PString.h:37
The PSizei class represents the size of an image or a rectangle: width (int) and height (int); PSizei...
Definition: PSizei.h:27
The PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
static const PSizef & Zero()
Returns the constant holding the 0 x 0 size.
Definition: PSizef.h:34
PResult FromString(const PString &s)
Builds a PObject from a string (destringify).
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
static const PSizef & Bad()
Returns the constant holding the NaN x NaN size.
Definition: PSizef.h:39
Math toolbox.
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45
The PSizef class represents the size of an image or a rectangle: width (float) and height (float); PS...
Definition: PSizef.h:28