From f1b28615cb0ce50d3e0d9ba841d700a2905fdbec Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 14 May 2010 22:13:53 +0200 Subject: Add dx (kerning), dy (vertical shifting), and rotate widgets to text toolbar along with routines needed by them. (bzr r9417) --- src/text-editing.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index e93ebdffa..372f5026d 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -928,7 +928,7 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str) /** Returns the attributes block and the character index within that block which represents the iterator \a position. */ -static TextTagAttributes* +TextTagAttributes* text_tag_attributes_at_position(SPItem *item, Inkscape::Text::Layout::iterator const &position, unsigned *char_index) { if (item == NULL || char_index == NULL || !SP_IS_TEXT(item)) @@ -972,6 +972,36 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +void +sp_te_adjust_dx (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta) +{ + unsigned char_index; + TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index); + if (attributes) attributes->addToDx(char_index, delta); + if (start != end) { + attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index); + if (attributes) attributes->addToDx(char_index, -delta); + } + + item->updateRepr(); + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +sp_te_adjust_dy (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta) +{ + unsigned char_index; + TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index); + if (attributes) attributes->addToDy(char_index, delta); + if (start != end) { + attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index); + if (attributes) attributes->addToDy(char_index, -delta); + } + + item->updateRepr(); + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + void sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble pixels) { @@ -1011,6 +1041,25 @@ sp_te_adjust_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &star text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +void +sp_te_set_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees) +{ + unsigned char_index; + TextTagAttributes *attributes = text_tag_attributes_at_position(text, std::min(start, end), &char_index); + if (attributes == NULL) return; + + if (start != end) { + for (Inkscape::Text::Layout::iterator it = std::min(start, end) ; it != std::max(start, end) ; it.nextCharacter()) { + attributes = text_tag_attributes_at_position(text, it, &char_index); + if (attributes) attributes->setRotate(char_index, degrees); + } + } else + attributes->setRotate(char_index, degrees); + + text->updateRepr(); + text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + void sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble by) { -- cgit v1.2.3