minor improvements

This commit is contained in:
fourtf
2018-12-02 17:49:15 +01:00
parent 52dcc2130e
commit 0e242202a4
8 changed files with 35 additions and 24 deletions
+11 -9
View File
@@ -234,20 +234,17 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
auto app = getApp();
QFontMetrics metrics =
app->fonts->getFontMetrics(this->style_, this->scale_);
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_);
auto x = this->getRect().left();
int x = this->getRect().left();
for (int i = 0; i < this->getText().size(); i++)
for (auto i = 0; i < this->getText().size(); i++)
{
auto &text = this->getText();
auto &&text = this->getText();
auto width = metrics.width(this->getText()[i]);
if (x + width > abs.x())
{
if (text.size() > i + 1 &&
QChar::isLowSurrogate(text[i].unicode())) //
if (text.size() > i + 1 && QChar::isLowSurrogate(text[i].unicode()))
{
i++;
}
@@ -258,7 +255,12 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
x += width;
}
return this->getSelectionIndexCount();
// if (this->hasTrailingSpace() && abs.x() < this->getRect().right())
// {
// return this->getSelectionIndexCount() - 1;
// }
return this->getSelectionIndexCount() - (this->hasTrailingSpace() ? 1 : 0);
}
int TextLayoutElement::getXFromIndex(int index)