From 632414c7cdd5f8992c6d6439d25128b82e93d499 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 2 Sep 2013 15:51:04 -0400 Subject: Fix bug that added transforms to new objects. (bzr r12475.1.11) --- src/sp-star.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/sp-star.cpp') diff --git a/src/sp-star.cpp b/src/sp-star.cpp index af2420340..afc0b84d6 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -39,6 +39,7 @@ static void sp_star_update (SPObject *object, SPCtx *ctx, guint flags); static gchar * sp_star_description (SPItem * item); static void sp_star_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); +static Geom::Affine sp_star_set_transform(SPItem *item, Geom::Affine const &xform); static void sp_star_set_shape (SPShape *shape); static void sp_star_update_patheffect (SPLPEItem *lpeitem, bool write); @@ -59,6 +60,7 @@ static void sp_star_class_init(SPStarClass *klass) item_class->description = sp_star_description; item_class->snappoints = sp_star_snappoints; + item_class->set_transform = sp_star_set_transform; lpe_item_class->update_patheffect = sp_star_update_patheffect; @@ -528,6 +530,60 @@ static void sp_star_snappoints(SPItem const *item, std::vectorcenter * xform ); + + /* This function takes care of translation and scaling, we return whatever parts we can't + handle. */ + Geom::Affine ret(Geom::Affine(xform).withoutTranslation()); + gdouble const s = hypot(ret[0], ret[1]); + if (s > 1e-9) { + ret[0] /= s; + ret[1] /= s; + ret[2] /= s; + ret[3] /= s; + } else { + ret[0] = 1.0; + ret[1] = 0.0; + ret[2] = 0.0; + ret[3] = 1.0; + } + + star->r[0] *= s; + star->r[1] *= s; + + /* Find start in item coords */ + pos = pos * ret.inverse(); + star->center = pos; + + sp_star_set_shape(star); + + // Adjust stroke width + item->adjust_stroke(s); + + // Adjust pattern fill + item->adjust_pattern(xform * ret.inverse()); + + // Adjust gradient fill + item->adjust_gradient(xform * ret.inverse()); + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + + return ret; +} + /** * sp_star_get_xy: Get X-Y value as item coordinate system * @star: star item -- cgit v1.2.3 From eb3598e7e27619c759ef33bb9ec4ffb8898523de Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 20 Sep 2013 00:45:16 -0400 Subject: Refactor status-bar text for multiple items, was very broken Fixed bugs: - https://launchpad.net/bugs/1199192 (bzr r12550) --- src/sp-star.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/sp-star.cpp') diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 4a3a8cbe3..e5c5c7c25 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -251,19 +251,18 @@ void SPStar::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +const char* SPStar::display_name() { + if (this->flatsided == false) + return _("Star"); + return _("Polygon"); +} + gchar* SPStar::description() { // while there will never be less than 3 vertices, we still need to // make calls to ngettext because the pluralization may be different // for various numbers >=3. The singular form is used as the index. - if (this->flatsided == false) { - return g_strdup_printf (ngettext("Star with %d vertex", - "Star with %d vertices", - this->sides), this->sides); - } else { - return g_strdup_printf (ngettext("Polygon with %d vertex", - "Polygon with %d vertices", - this->sides), this->sides); - } + return g_strdup_printf (ngettext(_("with %d vertex"), _("with %d vertices"), + this->sides), this->sides); } /** -- cgit v1.2.3