summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-11-04 21:45:34 +0000
committerVaxry <vaxry@vaxry.net>2023-11-04 21:45:34 +0000
commit931927de29256a46004cd6f71fdf45ed76470b73 (patch)
treeb8ae286034e1ac782cca4d72e842f3dcf900eeb6 /src/helpers
parent74cf2281dd38a533916eb0b201c3128423b94d7c (diff)
dwindle: move to CBox for expressing nodes
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/Box.cpp10
-rw-r--r--src/helpers/Box.hpp14
2 files changed, 23 insertions, 1 deletions
diff --git a/src/helpers/Box.cpp b/src/helpers/Box.cpp
index 450871cb..e71ed622 100644
--- a/src/helpers/Box.cpp
+++ b/src/helpers/Box.cpp
@@ -101,4 +101,12 @@ CBox CBox::roundInternal() {
float newH = y + h - std::floor(y);
return CBox{std::floor(x), std::floor(y), std::floor(newW), std::floor(newH)};
-} \ No newline at end of file
+}
+
+Vector2D CBox::pos() const {
+ return {x, y};
+}
+
+Vector2D CBox::size() const {
+ return {w, h};
+}
diff --git a/src/helpers/Box.hpp b/src/helpers/Box.hpp
index 7a8aa939..a5f24d7b 100644
--- a/src/helpers/Box.hpp
+++ b/src/helpers/Box.hpp
@@ -32,6 +32,13 @@ class CBox {
h = d;
}
+ CBox(const Vector2D& pos, const Vector2D& size) {
+ x = pos.x;
+ y = pos.y;
+ w = size.x;
+ h = size.y;
+ }
+
wlr_box wlr();
wlr_box* pWlr();
@@ -45,6 +52,8 @@ class CBox {
CBox& addExtents(const SWindowDecorationExtents& e);
Vector2D middle() const;
+ Vector2D pos() const;
+ Vector2D size() const;
bool containsPoint(const Vector2D& vec) const;
bool empty() const;
@@ -59,6 +68,11 @@ class CBox {
double height;
};
+ //
+ bool operator==(const CBox& rhs) const {
+ return x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h;
+ }
+
private:
CBox roundInternal();