summaryrefslogtreecommitdiffstats
path: root/src/sp-root.cpp
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2017-10-05 13:21:22 +0000
committerShlomi Fish <shlomif@shlomifish.org>2017-10-05 13:21:22 +0000
commit3207522f0f2597248f479075c395e9e9d589e181 (patch)
tree6de848b0b17077dbdfa89abc082c9cf1dc500197 /src/sp-root.cpp
parentExtract unset_x_and_y(). (diff)
downloadinkscape-3207522f0f2597248f479075c395e9e9d589e181.tar.gz
inkscape-3207522f0f2597248f479075c395e9e9d589e181.zip
Extract SPRoot::setRootDimensions .
Diffstat (limited to 'src/sp-root.cpp')
-rw-r--r--src/sp-root.cpp82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index fc35e26e9..d69f5300d 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -211,55 +211,59 @@ void SPRoot::remove_child(Inkscape::XML::Node *child)
SPGroup::remove_child(child);
}
-void SPRoot::update(SPCtx *ctx, guint flags)
+void SPRoot::setRootDimensions()
{
- SPItemCtx const *ictx = (SPItemCtx const *) ctx;
-
- if( !this->parent ) {
+ /*
+ * This is the root SVG element:
+ *
+ * x, y, width, and height apply to positioning the SVG element inside a parent.
+ * For the root SVG in Inkscape there is no parent, thus special rules apply:
+ * If width, height not set, width = 100%, height = 100% (as always).
+ * If width and height are in percent, they are percent of viewBox width/height.
+ * If width, height, and viewBox are not set... pick "random" width/height.
+ * x, y are ignored.
+ * initial viewport = (0 0 width height)
+ */
+ if( this->viewBox_set ) {
- /*
- * This is the root SVG element:
- *
- * x, y, width, and height apply to positioning the SVG element inside a parent.
- * For the root SVG in Inkscape there is no parent, thus special rules apply:
- * If width, height not set, width = 100%, height = 100% (as always).
- * If width and height are in percent, they are percent of viewBox width/height.
- * If width, height, and viewBox are not set... pick "random" width/height.
- * x, y are ignored.
- * initial viewport = (0 0 width height)
- */
- if( this->viewBox_set ) {
-
- if( this->width._set ) {
- // Check if this is necessary
- if (this->width.unit == SVGLength::PERCENT) {
- this->width.computed = this->width.value * this->viewBox.width();
- }
- } else {
- this->width.set( SVGLength::PX, this->viewBox.width(), this->viewBox.width() );
+ if( this->width._set ) {
+ // Check if this is necessary
+ if (this->width.unit == SVGLength::PERCENT) {
+ this->width.computed = this->width.value * this->viewBox.width();
}
+ } else {
+ this->width.set( SVGLength::PX, this->viewBox.width(), this->viewBox.width() );
+ }
- if( this->height._set ) {
- if (this->height.unit == SVGLength::PERCENT) {
- this->height.computed = this->height.value * this->viewBox.height();
- }
- } else {
- this->height.set(SVGLength::PX, this->viewBox.height(), this->viewBox.height() );
+ if( this->height._set ) {
+ if (this->height.unit == SVGLength::PERCENT) {
+ this->height.computed = this->height.value * this->viewBox.height();
}
-
} else {
+ this->height.set(SVGLength::PX, this->viewBox.height(), this->viewBox.height() );
+ }
- if( !this->width._set ) {
- this->width.set( SVGLength::PX, 100, 100 ); // Random default
- }
+ } else {
- if( !this->height._set ) {
- this->height.set( SVGLength::PX, 100, 100 ); // Random default
- }
+ if( !this->width._set ) {
+ this->width.set( SVGLength::PX, 100, 100 ); // Random default
}
- // Ignore x, y values for root element
- this->unset_x_and_y();
+ if( !this->height._set ) {
+ this->height.set( SVGLength::PX, 100, 100 ); // Random default
+ }
+ }
+
+ // Ignore x, y values for root element
+ this->unset_x_and_y();
+}
+
+void SPRoot::update(SPCtx *ctx, guint flags)
+{
+ SPItemCtx const *ictx = (SPItemCtx const *) ctx;
+
+ if( !this->parent ) {
+ this->setRootDimensions();
}
// Calculate x, y, width, height from parent/initial viewport