summaryrefslogtreecommitdiffstats
path: root/src/sp-flowtext.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2009-12-30 14:34:51 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2009-12-30 14:34:51 +0000
commit760e1d9dca7bff3c00758d8efc38f8ba22766e08 (patch)
tree96ed2a38abe420eb10ed234060d5595accd3101f /src/sp-flowtext.cpp
parentDummy merge to get good version history. (diff)
downloadinkscape-760e1d9dca7bff3c00758d8efc38f8ba22766e08.tar.gz
inkscape-760e1d9dca7bff3c00758d8efc38f8ba22766e08.zip
Small snap bug has been eliminated, flowed text snapping now uses baseline, replacing tabs by spaces, removing some commented lines
(bzr r8925)
Diffstat (limited to 'src/sp-flowtext.cpp')
-rw-r--r--src/sp-flowtext.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index e4259e52c..feb79cd9a 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -27,7 +27,7 @@
#include "sp-rect.h"
#include "text-tag-attributes.h"
#include "text-chemistry.h"
-
+#include "text-editing.h"
#include "livarot/Shape.h"
@@ -49,6 +49,7 @@ static void sp_flowtext_set(SPObject *object, unsigned key, gchar const *value);
static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_flowtext_description(SPItem *item);
+static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs);
static NRArenaItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags);
static void sp_flowtext_hide(SPItem *item, unsigned key);
@@ -98,6 +99,7 @@ sp_flowtext_class_init(SPFlowtextClass *klass)
item_class->bbox = sp_flowtext_bbox;
item_class->print = sp_flowtext_print;
item_class->description = sp_flowtext_description;
+ item_class->snappoints = sp_flowtext_snappoints;
item_class->show = sp_flowtext_show;
item_class->hide = sp_flowtext_hide;
}
@@ -384,6 +386,20 @@ static gchar *sp_flowtext_description(SPItem *item)
return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character%s)", "<b>Linked flowed text</b> (%d characters%s)", nChars), nChars, trunc);
}
+static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPointsWithType &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<Geom::Point> pt = layout->baselineAnchorPoint();
+ if (pt) {
+ int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE);
+ p.push_back(std::make_pair((*pt) * sp_item_i2d_affine(item), type));
+ }
+ }
+}
+
static NRArenaItem *
sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flags*/)
{