26#ifndef TGUI_VECTOR2F_HPP
27#define TGUI_VECTOR2F_HPP
29#include <TGUI/Global.hpp>
30#include <TGUI/String.hpp>
31#include <SFML/System/Vector2.hpp>
32#include <SFML/System/Err.hpp>
53 TGUI_CONSTEXPR
Vector2f(
float xValue,
float yValue) :
83 TGUI_PRINT_WARNING(
"Failed to parse Vector2f. String was empty.");
88 if (((str.front() ==
'(') && (str.back() ==
')')) || ((str.front() ==
'{') && (str.back() ==
'}')))
89 str = str.substr(1, str.length() - 2);
98 auto commaPos = str.find(
',');
99 if (commaPos == std::string::npos)
101 TGUI_PRINT_WARNING(
"Failed to parse Vector2f '" + str +
"'. Expected numbers separated with a comma.");
113 operator sf::Vector2f()
const
115 return sf::Vector2f{x, y};
134 return {-right.
x, -right.
y};
162 return {left.
x + right.
x, left.
y + right.
y};
170 return {left.
x - right.
x, left.
y - right.
y};
178 return {left.
x * right, left.
y * right};
186 return {left * right.
x, left * right.
y};
204 return {left.
x / right, left.
y / right};
222 return (left.
x == right.
x) && (left.
y == right.
y);
230 return !(left == right);
Definition: Vector2f.hpp:39
Vector2f(const char *str)
Constructor to create from a string.
Definition: Vector2f.hpp:71
Vector2f(const sf::Vector2f &vec)
Copy constructor to create from an sf::Vector2f.
Definition: Vector2f.hpp:62
TGUI_CONSTEXPR Vector2f(float xValue, float yValue)
Constructor to create from X and Y values.
Definition: Vector2f.hpp:53
Vector2f(std::string str)
Constructor to create from a string.
Definition: Vector2f.hpp:79
float x
X coordinate of the vector.
Definition: Vector2f.hpp:122
TGUI_CONSTEXPR Vector2f()
Default constructor.
Definition: Vector2f.hpp:45
float y
Y coordinate of the vector.
Definition: Vector2f.hpp:123
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37
TGUI_CONSTEXPR Vector2f & operator*=(Vector2f &left, float right)
Overload of binary operator *=.
Definition: Vector2f.hpp:192
TGUI_API Layout operator+(Layout left, Layout right)
operator for the Layout class
TGUI_API float strToFloat(const std::string &str, float defaultValue=0)
Converts a string to a float.
TGUI_API std::string trim(const std::string &str)
Trims the whitespace from a string.
TGUI_API Layout operator/(Layout left, Layout right)
/ operator for the Layout class
TGUI_API Layout operator*(Layout left, Layout right)
operator for the Layout class
TGUI_CONSTEXPR Vector2f & operator-=(Vector2f &left, const Vector2f &right)
Overload of binary operator -=.
Definition: Vector2f.hpp:150
TGUI_API Layout operator-(Layout right)
Unary minus operator for the Layout class.
TGUI_CONSTEXPR Vector2f & operator/=(Vector2f &left, float right)
Overload of binary operator /=.
Definition: Vector2f.hpp:210
TGUI_CONSTEXPR Vector2f & operator+=(Vector2f &left, const Vector2f &right)
Overload of binary operator +=.
Definition: Vector2f.hpp:140