diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-02-06 14:29:15 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-02-06 14:29:15 +0000 |
| commit | 7dd239eed97761b22ef635b6896a8f65c4939462 (patch) | |
| tree | a9c4eb95e2ae1356cd584151683dc9373e4f1140 /src/sp-pattern.cpp | |
| parent | Extensions->Render submenu. Scaling of input parameters into document units, ... (diff) | |
| download | inkscape-7dd239eed97761b22ef635b6896a8f65c4939462.tar.gz inkscape-7dd239eed97761b22ef635b6896a8f65c4939462.zip | |
Added new base class to handle viewBox and preserveAspectRatio.
Updated sp-root, sp-symbol, sp-image, sp-pattern, marker to use new class.
Fixed some viewport issues when % used.
(bzr r13002)
Diffstat (limited to 'src/sp-pattern.cpp')
| -rw-r--r-- | src/sp-pattern.cpp | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ad5449f34..711f26428 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -53,7 +53,7 @@ namespace { bool patternRegistered = SPFactory::instance().registerObject("svg:pattern", createPattern); } -SPPattern::SPPattern() : SPPaintServer() { +SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->href = NULL; this->ref = new SPPatternReference(this); @@ -72,8 +72,6 @@ SPPattern::SPPattern() : SPPaintServer() { this->y.unset(); this->width.unset(); this->height.unset(); - - this->viewBox_set = FALSE; } SPPattern::~SPPattern() { @@ -90,6 +88,7 @@ void SPPattern::build(SPDocument* doc, Inkscape::XML::Node* repr) { this->readAttr( "width" ); this->readAttr( "height" ); this->readAttr( "viewBox" ); + this->readAttr( "preserveAspectRatio" ); this->readAttr( "xlink:href" ); /* Register ourselves */ @@ -180,50 +179,16 @@ void SPPattern::set(unsigned int key, const gchar* value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_VIEWBOX: { - /* fixme: Think (Lauris) */ - double x, y, width, height; - char *eptr; - - if (value) { - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + case SP_ATTR_VIEWBOX: + set_viewBox( value ); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - if ((width > 0) && (height > 0)) { - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } - } else { - this->viewBox_set = FALSE; - } + case SP_ATTR_PRESERVEASPECTRATIO: + set_preserveAspectRatio( value ); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; - } case SP_ATTR_XLINK_HREF: if ( value && this->href && ( strcmp(value, this->href) == 0 ) ) { /* Href unchanged, do nothing. */ |
