FifeGUI 0.3.0
A C++ GUI library designed for games.
rectangle.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_RECTANGLE_HPP_
6#define INCLUDE_FIFECHAN_RECTANGLE_HPP_
7
8// Standard library includes
9#include <iostream>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14namespace fcn
15{
21 class FIFEGUI_API Rectangle
22 {
23 public:
29 Rectangle();
30
39 Rectangle(int x, int y, int width, int height);
40
49 void setAll(int x, int y, int width, int height);
50
57 bool isIntersecting(Rectangle const & rectangle) const;
58
67 bool isContaining(int x, int y) const;
68
76 bool isContaining(Rectangle const & other) const;
77
86 bool isEmpty() const;
87
96 Rectangle operator+(Rectangle const & rh) const;
97
106 Rectangle const & operator+=(Rectangle const & rh);
107
114 Rectangle intersection(Rectangle const & rh) const;
115
122 friend FIFEGUI_API std::ostream& operator<<(std::ostream& out, Rectangle const & rectangle);
123
127 int x;
128
132 int y;
133
137 int width;
138
143 };
144} // namespace fcn
145
146#endif // INCLUDE_FIFECHAN_RECTANGLE_HPP_
friend FIFEGUI_API std::ostream & operator<<(std::ostream &out, Rectangle const &rectangle)
Output operator for output.
Rectangle()
Constructor.
Definition rectangle.cpp:14
bool isContaining(int x, int y) const
Checks the rectangle contains a point.
Definition rectangle.cpp:63
int width
Holds the width of the rectangle.
Rectangle intersection(Rectangle const &rh) const
Gets the intersection between two rectangles.
int y
Holds the x coordinate of the rectangle.
void setAll(int x, int y, int width, int height)
Sets the dimension of a rectangle.
Definition rectangle.cpp:24
Rectangle operator+(Rectangle const &rh) const
Adds a rectangle to this rectangle.
Definition rectangle.cpp:87
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
Rectangle const & operator+=(Rectangle const &rh)
Adds a rectangle to this rectangle.
bool isIntersecting(Rectangle const &rectangle) const
Checks if another rectangle intersects with the rectangle.
Definition rectangle.cpp:34
bool isEmpty() const
Checks whether the rectangle is empty or not.
Definition rectangle.cpp:82
Used replacement tokens by configure_file():