From 8911d9a8ca0c7f4ef1476b2f056adf2afa4e99cd Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 30 Jun 2011 22:46:15 +0200 Subject: Implement decent snapping to text (baseline & anchor), and provide a toggle button for this (as requested in LP bug #727281 ) (bzr r10392) --- src/sp-flowtext.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/sp-flowtext.cpp') diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index d7bc0053f..3413999a9 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -388,15 +388,17 @@ static gchar *sp_flowtext_description(SPItem *item) } } -static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - // Choose a point on the baseline for snapping from or to, with the horizontal position - // of this point depending on the text alignment (left vs. right) - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); - if (layout != NULL && layout->outputExists()) { - boost::optional pt = layout->baselineAnchorPoint(); - if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + if (snapprefs->getSnapTextBaseline()) { + // Choose a point on the baseline for snapping from or to, with the horizontal position + // of this point depending on the text alignment (left vs. right) + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + if (layout != NULL && layout->outputExists()) { + boost::optional pt = layout->baselineAnchorPoint(); + if (pt) { + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + } } } } -- cgit v1.2.3