2023-07-19 20:09:49 +02:00
|
|
|
#pragma once
|
|
|
|
#include <pixman.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "Vector2D.hpp"
|
2023-11-05 00:12:08 +01:00
|
|
|
#include "Box.hpp"
|
2023-07-19 20:09:49 +02:00
|
|
|
|
|
|
|
struct wlr_box;
|
|
|
|
|
|
|
|
class CRegion {
|
|
|
|
public:
|
|
|
|
/* Create an empty region */
|
|
|
|
CRegion();
|
|
|
|
/* Create from a reference. Copies, does not own. */
|
|
|
|
CRegion(pixman_region32_t* ref);
|
|
|
|
/* Create from a box */
|
|
|
|
CRegion(double x, double y, double w, double h);
|
|
|
|
/* Create from a wlr_box */
|
|
|
|
CRegion(wlr_box* box);
|
2023-11-04 18:03:05 +01:00
|
|
|
/* Create from a CBox */
|
2023-11-11 15:37:17 +01:00
|
|
|
CRegion(const CBox& box);
|
2023-07-20 18:27:28 +02:00
|
|
|
/* Create from a pixman_box32_t */
|
|
|
|
CRegion(pixman_box32_t* box);
|
2023-07-19 20:09:49 +02:00
|
|
|
|
|
|
|
CRegion(const CRegion&);
|
|
|
|
CRegion(CRegion&&);
|
|
|
|
|
|
|
|
~CRegion();
|
|
|
|
|
|
|
|
CRegion& operator=(CRegion&& other) {
|
|
|
|
pixman_region32_copy(&m_rRegion, other.pixman());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CRegion& operator=(CRegion& other) {
|
|
|
|
pixman_region32_copy(&m_rRegion, other.pixman());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CRegion& clear();
|
|
|
|
CRegion& set(const CRegion& other);
|
|
|
|
CRegion& add(const CRegion& other);
|
|
|
|
CRegion& add(double x, double y, double w, double h);
|
2023-11-11 15:37:17 +01:00
|
|
|
CRegion& add(const CBox& other);
|
2023-07-19 20:09:49 +02:00
|
|
|
CRegion& subtract(const CRegion& other);
|
|
|
|
CRegion& intersect(const CRegion& other);
|
|
|
|
CRegion& intersect(double x, double y, double w, double h);
|
|
|
|
CRegion& translate(const Vector2D& vec);
|
2023-11-24 11:54:21 +01:00
|
|
|
CRegion& transform(const wl_output_transform t, double w, double h);
|
2023-07-19 20:09:49 +02:00
|
|
|
CRegion& invert(pixman_box32_t* box);
|
2023-11-26 16:24:24 +01:00
|
|
|
CRegion& invert(const CBox& box);
|
2023-09-20 17:47:05 +02:00
|
|
|
CRegion& scale(float scale);
|
2024-02-19 12:24:54 +01:00
|
|
|
CRegion& scale(const Vector2D& scale);
|
2023-11-04 18:03:05 +01:00
|
|
|
CBox getExtents();
|
2023-09-20 17:47:05 +02:00
|
|
|
bool containsPoint(const Vector2D& vec) const;
|
|
|
|
bool empty() const;
|
|
|
|
Vector2D closestPoint(const Vector2D& vec) const;
|
2023-11-24 11:54:21 +01:00
|
|
|
CRegion copy() const;
|
2023-07-19 20:09:49 +02:00
|
|
|
|
|
|
|
std::vector<pixman_box32_t> getRects() const;
|
|
|
|
|
|
|
|
pixman_region32_t* pixman() {
|
2024-02-19 12:24:54 +01:00
|
|
|
return &m_rRegion;
|
2023-07-19 20:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
pixman_region32_t m_rRegion;
|
2023-08-30 17:39:22 +02:00
|
|
|
};
|