Skip to content

Commit

Permalink
Improve cursor visibility in text tool #184
Browse files Browse the repository at this point in the history
  • Loading branch information
DamirPorobic committed Dec 23, 2020
1 parent 176b4f6 commit 0eeec6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## Release 0.4.1
* Fixed: Brazilian Portuguese translation not loaded. ([#176](https://github.com/ksnip/kImageAnnotator/issues/176))
* Fixed: error: control reaches end of non-void function. ([#177](https://github.com/ksnip/kImageAnnotator/issues/177))
* Fixed: Cursor in Text tool have too bad visibility. ([#184](https://github.com/ksnip/kImageAnnotator/issues/184))

## Release 0.4.0
* New: Add Pixelate image area tool. ([#140](https://github.com/ksnip/kImageAnnotator/issues/140))
Expand Down
6 changes: 3 additions & 3 deletions src/annotations/items/text/AnnotationTextHandler.cpp
Expand Up @@ -103,7 +103,7 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo

// Workaround for issue #70 -> Cursor not drawn with with Qt 5.9
if (mIsInEditMode) {
painter->setBrush(QColor(255,255,255,10));
painter->setBrush(QColor(255,255,255,50));
painter->drawRect(*rect);
}

Expand Down Expand Up @@ -142,7 +142,7 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo
textLayout.draw(painter, QPoint(0, boxHeight));

if (mTextCursor.isVisible() && isCursorInBlock(blockPosition, blockLength)) {
textLayout.drawCursor(painter, QPointF(1, boxHeight), mTextCursor.position() - blockPosition, 2);
textLayout.drawCursor(painter, QPointF(0, boxHeight), mTextCursor.position() - blockPosition, 1);
}
boxHeight += blockHeight;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ QRect AnnotationTextHandler::getTextRect(QRectF *rect, const QFont& font, int ma
{
QFontMetrics fontMetrics(font);
auto newRect = fontMetrics.boundingRect(rect->toRect().normalized(), Qt::AlignLeft, mText);
newRect.adjust(0, 0, margin * 2, margin * 2);
newRect.adjust(0, 2, (margin * 2) + 2, margin * 2);
return newRect;
}

Expand Down

0 comments on commit 0eeec6c

Please sign in to comment.