summaryrefslogtreecommitdiffstats
path: root/src/libnr/nr-rect.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2007-03-05 05:50:20 +0000
committermental <mental@users.sourceforge.net>2007-03-05 05:50:20 +0000
commitd4867888572ff1cf3d5bbeaed8c68431f6834941 (patch)
tree95fbc8812495b00ce09c6f7dc46610eeba9fc9ca /src/libnr/nr-rect.cpp
parentclean up operators/constructors, and give reference-maybes a more compact (diff)
downloadinkscape-d4867888572ff1cf3d5bbeaed8c68431f6834941.tar.gz
inkscape-d4867888572ff1cf3d5bbeaed8c68431f6834941.zip
Separate NRRect and NR::Rect a bit further; the goal is to get to the point where there is no way to create an empty NR::Rect
(bzr r2551)
Diffstat (limited to 'src/libnr/nr-rect.cpp')
-rw-r--r--src/libnr/nr-rect.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
index 76d7fff8d..21d3f470a 100644
--- a/src/libnr/nr-rect.cpp
+++ b/src/libnr/nr-rect.cpp
@@ -11,6 +11,30 @@
#include "nr-rect-l.h"
+NRRect::NRRect(NR::Rect const &rect)
+: x0(rect.min()[NR::X]), y0(rect.min()[NR::Y]),
+ x1(rect.max()[NR::X]), y1(rect.max()[NR::Y])
+{}
+
+NRRect::NRRect(NR::Maybe<NR::Rect> const &rect) {
+ if (rect) {
+ x0 = rect->min()[NR::X];
+ y0 = rect->min()[NR::Y];
+ x1 = rect->max()[NR::X];
+ y1 = rect->max()[NR::Y];
+ } else {
+ nr_rect_d_set_empty(this);
+ }
+}
+
+NR::Maybe<NR::Rect> NRRect::upgrade() const {
+ if (nr_rect_d_test_empty(this)) {
+ return NR::Nothing();
+ } else {
+ return NR::Rect(NR::Point(x0, y0), NR::Point(x1, y1));
+ }
+}
+
/**
* \param r0 Rectangle.
* \param r1 Another rectangle.