r21131 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Mon Mar 28 21:25:52 UTC 2016
Author: jghali
Date: Mon Mar 28 21:25:52 2016
New Revision: 21131
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21131
Log:
fix precision issue with placement of text cursor
Modified:
trunk/Scribus/scribus/sctextstruct.h
trunk/Scribus/scribus/text/boxes.cpp
Modified: trunk/Scribus/scribus/sctextstruct.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21131&path=/trunk/Scribus/scribus/sctextstruct.h
==============================================================================
--- trunk/Scribus/scribus/sctextstruct.h (original)
+++ trunk/Scribus/scribus/sctextstruct.h Mon Mar 28 21:25:52 2016
@@ -93,8 +93,8 @@
void setFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags | f); }
void clearFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags & ~f); }
- QList<GlyphLayout>& glyphs() { return m_glyphs; }
- const QList<GlyphLayout> glyphs() const { return m_glyphs; }
+ QList<GlyphLayout>& glyphs() { return m_glyphs; }
+ const QList<GlyphLayout>& glyphs() const { return m_glyphs; }
int firstChar() const { return m_firstChar; }
int lastChar() const { return m_lastChar; }
qreal width() const;
Modified: trunk/Scribus/scribus/text/boxes.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21131&path=/trunk/Scribus/scribus/text/boxes.cpp
==============================================================================
--- trunk/Scribus/scribus/text/boxes.cpp (original)
+++ trunk/Scribus/scribus/text/boxes.cpp Mon Mar 28 21:25:52 2016
@@ -621,14 +621,16 @@
double relX = coord.x() - m_x;
double xPos = 0.0;
- for (int i = 0; i < m_glyphRun.glyphs().length(); ++i)
- {
- double width = m_glyphRun.glyphs().at(i).xadvance;
- if (xPos <= relX && relX <= xPos + width)
- {
- return m_firstChar + i; // FIXME: use clusters
- }
+ const QList<GlyphLayout>& glyphs = m_glyphRun.glyphs();
+ for (int i = 0; i < glyphs.length(); ++i)
+ {
+ double width = glyphs.at(i).xadvance;
xPos += width;
+ if (xPos >= relX)
+ {
+ int index = (xPos - width / 2.0 > relX) ? i : i + 1; // FIXME: use clusters
+ return m_firstChar + index;
+ }
}
return -1;
}
More information about the scribus-commit
mailing list