summaryrefslogtreecommitdiff
path: root/src/rect.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 18:00:56 +0200
committerDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 18:00:56 +0200
commit84fbdc90df2b2a53dd94cae3d1f51a012ac42c49 (patch)
tree1f877dc74f230008e5443d53c06c23771c166889 /src/rect.cpp
parent6d03dac7963e2b17d3e499b301cbced515e0ea04 (diff)
downloadunity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.gz
unity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.bz2
CompRect class.
Diffstat (limited to 'src/rect.cpp')
-rw-r--r--src/rect.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/rect.cpp b/src/rect.cpp
new file mode 100644
index 0000000..892e369
--- /dev/null
+++ b/src/rect.cpp
@@ -0,0 +1,90 @@
+#include <compiz-core.h>
+#include <comprect.h>
+
+CompRect::CompRect ()
+{
+ mRegion.rects = &mRegion.extents;
+ mRegion.numRects = 1;
+ mRegion.extents.x1 = 0;
+ mRegion.extents.x2 = 0;
+ mRegion.extents.y1 = 0;
+ mRegion.extents.y2 = 0;
+}
+
+CompRect::CompRect (int x1, int x2, int y1, int y2)
+{
+ CompRect ();
+ setGeometry (x1, x2, y1, y2);
+}
+
+int
+CompRect::x ()
+{
+ return mRegion.extents.x1;
+}
+
+int
+CompRect::y ()
+{
+ return mRegion.extents.y1;
+}
+
+int
+CompRect::x1 ()
+{
+ return mRegion.extents.x1;
+}
+
+int
+CompRect::y1 ()
+{
+ return mRegion.extents.y1;
+}
+
+int
+CompRect::x2 ()
+{
+ return mRegion.extents.x2;
+}
+
+int
+CompRect::y2 ()
+{
+ return mRegion.extents.y2;
+}
+
+unsigned int
+CompRect::width ()
+{
+ return mRegion.extents.x2 - mRegion.extents.x1;
+}
+
+unsigned int
+CompRect::height ()
+{
+ return mRegion.extents.y2 - mRegion.extents.y1;
+}
+
+Region
+CompRect::region ()
+{
+ return &mRegion;
+}
+
+void
+CompRect::setGeometry (int x1, int x2, int y1, int y2)
+{
+ mRegion.extents.x1 = x1;
+ mRegion.extents.y1 = y1;
+
+ if (x2 < x1)
+ mRegion.extents.x2 = x1;
+ else
+ mRegion.extents.x2 = x2;
+
+ if (y2 < y1)
+ mRegion.extents.y2 = y1;
+ else
+ mRegion.extents.y2 = y2;
+}
+