diff options
| author | Ted Gould <ted@gould.cx> | 2010-01-01 04:39:28 +0000 |
|---|---|---|
| committer | Ted Gould <ted@gould.cx> | 2010-01-01 04:39:28 +0000 |
| commit | c22deac174d6b12cf55640f0f5336218cb36defb (patch) | |
| tree | bcb6da5aea8703ee9ee515d6112f3f6d0f6e49f5 /src/sp-flowtext.cpp | |
| parent | Fixing some warnings/errors (diff) | |
| parent | adding 'inductiveload' to AUTHORS (diff) | |
| download | inkscape-c22deac174d6b12cf55640f0f5336218cb36defb.tar.gz inkscape-c22deac174d6b12cf55640f0f5336218cb36defb.zip | |
Keeping up with trunk
(bzr r8254.1.49)
Diffstat (limited to 'src/sp-flowtext.cpp')
| -rw-r--r-- | src/sp-flowtext.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index e4259e52c..53bcd425d 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; } @@ -373,15 +375,27 @@ static gchar *sp_flowtext_description(SPItem *item) Inkscape::Text::Layout const &layout = SP_FLOWTEXT(item)->layout; int const nChars = layout.iteratorToCharIndex(layout.end()); - char *trunc = ""; - if (layout.inputTruncated()) { - trunc = _(" [truncated]"); - } + char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : ""; - if (SP_FLOWTEXT(item)->has_internal_frame()) + if (SP_FLOWTEXT(item)->has_internal_frame()) { return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character%s)", "<b>Flowed text</b> (%d characters%s)", nChars), nChars, trunc); - else + } else { 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 * |
