aboutsummaryrefslogtreecommitdiff
path: root/src/engine/data/bounds.hpp
blob: 54445036ccaeb646d2d4daf7d7f6f8be38e7251e (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
#pragma once

#include "engine/data/vector2.hpp"

#include <cstdint>

enum CoordsValidation
{
	VALID,
	X_HIGH,
	X_LOW,
	Y_HIGH,
	Y_LOW
};

struct BoundsOptions
{
	uint32_t width;
	uint32_t height;
};

class Bounds
{
public:
	using Value = uint32_t;

	explicit Bounds(const BoundsOptions &options) noexcept;

	[[nodiscard]] auto get_width() const noexcept -> Value;

	void set_width(Value width) noexcept;

	[[nodiscard]] auto get_height() const noexcept -> Value;

	void set_height(Value height) noexcept;

	[[nodiscard]] auto validate_coords(const Vector2 &coords) const noexcept -> CoordsValidation;

	auto operator*=(const Bounds &rhs) noexcept -> const Bounds &;
	auto operator+=(const Bounds &rhs) noexcept -> const Bounds &;
	auto operator-=(const Bounds &rhs) noexcept -> const Bounds &;

	auto operator-(const Bounds &rhs) const noexcept -> Bounds;

private:
	Value _width = 0U;
	Value _height = 0U;
};