From 4cc7eb64107fc32a7c364545acc635e504736cf6 Mon Sep 17 00:00:00 2001
From: buliabyak <>
Date: Mon, 21 Dec 2009 01:23:37 -0400
Subject: utilities and UI support for identifying truncated flowtext and
text-on-path
(bzr r8898)
---
src/sp-flowtext.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'src/sp-flowtext.cpp')
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 6af2f7169..e4259e52c 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -372,10 +372,16 @@ 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]");
+ }
+
if (SP_FLOWTEXT(item)->has_internal_frame())
- return g_strdup_printf(ngettext("Flowed text (%d character)", "Flowed text (%d characters)", nChars), nChars);
+ return g_strdup_printf(ngettext("Flowed text (%d character%s)", "Flowed text (%d characters%s)", nChars), nChars, trunc);
else
- return g_strdup_printf(ngettext("Linked flowed text (%d character)", "Linked flowed text (%d characters)", nChars), nChars);
+ return g_strdup_printf(ngettext("Linked flowed text (%d character%s)", "Linked flowed text (%d characters%s)", nChars), nChars, trunc);
}
static NRArenaItem *
--
cgit v1.2.3
From 760e1d9dca7bff3c00758d8efc38f8ba22766e08 Mon Sep 17 00:00:00 2001
From: Diederik van Lierop
Date: Wed, 30 Dec 2009 15:34:51 +0100
Subject: Small snap bug has been eliminated, flowed text snapping now uses
baseline, replacing tabs by spaces, removing some commented lines
(bzr r8925)
---
src/sp-flowtext.cpp | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
(limited to 'src/sp-flowtext.cpp')
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("Linked flowed text (%d character%s)", "Linked flowed text (%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 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*/)
{
--
cgit v1.2.3
From 4783d8c0eb412679dad7eef0ee3732e68a2d1dd8 Mon Sep 17 00:00:00 2001
From: "Jon A. Cruz"
Date: Wed, 30 Dec 2009 23:28:06 -0800
Subject: Warning cleanup for char const*
(bzr r8929)
---
src/sp-flowtext.cpp | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
(limited to 'src/sp-flowtext.cpp')
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index feb79cd9a..53bcd425d 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -375,15 +375,13 @@ 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("Flowed text (%d character%s)", "Flowed text (%d characters%s)", nChars), nChars, trunc);
- else
+ } else {
return g_strdup_printf(ngettext("Linked flowed text (%d character%s)", "Linked flowed text (%d characters%s)", nChars), nChars, trunc);
+ }
}
static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/)
--
cgit v1.2.3
From e8f4c644181a8a68e2c33e1783f77a400dc1a29f Mon Sep 17 00:00:00 2001
From: Diederik van Lierop
Date: Sat, 9 Jan 2010 22:14:38 +0100
Subject: Refactoring the snapping API (making it easier to maintain and
understand for the devs)
(bzr r8960)
---
src/sp-flowtext.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
(limited to 'src/sp-flowtext.cpp')
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 53bcd425d..b01146d60 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -49,7 +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 void sp_flowtext_snappoints(SPItem const *item, std::vector &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);
@@ -384,7 +384,7 @@ 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 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)
@@ -392,8 +392,7 @@ static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPo
if (layout != NULL && layout->outputExists()) {
boost::optional 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));
+ p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
}
}
}
--
cgit v1.2.3