summaryrefslogtreecommitdiff
path: root/src/helpers/Box.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-11-04 17:03:05 +0000
committerGitHub <noreply@github.com>2023-11-04 17:03:05 +0000
commit55b4f84fea33adee3ec4b0a69c2bca6e7a1f5754 (patch)
treebe7db4f841b4ac049527daae01e683701bf92b92 /src/helpers/Box.hpp
parent73e78f05ad5cafa20ac5bf177c94ac9ecca37097 (diff)
Internal: Hyprland box implementation (#3755)
* box impl * remove unused operators * missed applyfromwlr
Diffstat (limited to 'src/helpers/Box.hpp')
-rw-r--r--src/helpers/Box.hpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/helpers/Box.hpp b/src/helpers/Box.hpp
new file mode 100644
index 00000000..7a8aa939
--- /dev/null
+++ b/src/helpers/Box.hpp
@@ -0,0 +1,66 @@
+#pragma once
+
+#include <wlr/util/box.h>
+#include "Vector2D.hpp"
+#include "../SharedDefs.hpp"
+
+class CBox {
+ public:
+ CBox(double x_, double y_, double w_, double h_) {
+ x = x_;
+ y = y_;
+ w = w_;
+ h = h_;
+ }
+
+ CBox() {
+ w = 0;
+ h = 0;
+ }
+
+ CBox(const wlr_box& box) {
+ x = box.x;
+ y = box.y;
+ w = box.width;
+ h = box.height;
+ }
+
+ CBox(const double d) {
+ x = d;
+ y = d;
+ w = d;
+ h = d;
+ }
+
+ wlr_box wlr();
+ wlr_box* pWlr();
+
+ CBox& applyFromWlr();
+ CBox& scale(double scale);
+ CBox& scaleFromCenter(double scale);
+ CBox& scale(const Vector2D& scale);
+ CBox& translate(const Vector2D& vec);
+ CBox& round();
+ CBox& transform(const wl_output_transform t, double w, double h);
+ CBox& addExtents(const SWindowDecorationExtents& e);
+
+ Vector2D middle() const;
+
+ bool containsPoint(const Vector2D& vec) const;
+ bool empty() const;
+
+ double x = 0, y = 0;
+ union {
+ double w;
+ double width;
+ };
+ union {
+ double h;
+ double height;
+ };
+
+ private:
+ CBox roundInternal();
+
+ wlr_box m_bWlrBox;
+}; \ No newline at end of file