From 0fa6b5bc908746a3c7577bdcfc98a9ee332af20d Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 13 Jun 2016 13:42:55 +0300 Subject: [PATCH] Unread bar in a service message display fixed. Elided text with a skip block in the end display fixed. --- Telegram/SourceFiles/history.cpp | 9 ++++++--- Telegram/SourceFiles/ui/text/text.cpp | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 67f99df64..0ae57b2db 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -7972,25 +7972,28 @@ void HistoryService::setServiceText(const QString &text) { void HistoryService::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { int height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); + QRect clip(r); int dateh = 0, unreadbarh = 0; if (auto date = Get()) { dateh = date->height(); - //if (r.intersects(QRect(0, 0, _history->width, dateh))) { + //if (clip.intersects(QRect(0, 0, _history->width, dateh))) { // date->paint(p, 0, _history->width); //} p.translate(0, dateh); + clip.translate(0, -dateh); height -= dateh; } if (auto unreadbar = Get()) { unreadbarh = unreadbar->height(); - if (r.intersects(QRect(0, 0, _history->width, unreadbarh))) { + if (clip.intersects(QRect(0, 0, _history->width, unreadbarh))) { unreadbar->paint(p, 0, _history->width); } p.translate(0, unreadbarh); + clip.translate(0, -unreadbarh); height -= unreadbarh; } - HistoryLayout::PaintContext context(ms, r, selection); + HistoryLayout::PaintContext context(ms, clip, selection); HistoryLayout::ServiceMessagePainter::paint(p, this, context, height); if (int skiph = dateh + unreadbarh) { diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index e91aaecec..4cba8e371 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -1188,7 +1188,7 @@ public: bool drawLine(uint16 _lineEnd, const Text::TextBlocks::const_iterator &_endBlockIter, const Text::TextBlocks::const_iterator &_end) { _yDelta = (_lineHeight - _fontHeight) / 2; - if (_yTo >= 0 && _y + _yDelta >= _yTo) return false; + if (_yTo >= 0 && (_y + _yDelta >= _yTo || _y >= _yTo)) return false; if (_y + _yDelta + _fontHeight <= _yFrom) { if (_lookupSymbol) { _lookupResult.symbol = (_lineEnd > _lineStart) ? (_lineEnd - 1) : _lineStart; @@ -1205,8 +1205,19 @@ public: } } - ITextBlock *_endBlock = (_endBlockIter == _end) ? 0 : (*_endBlockIter); - bool elidedLine = _elideLast && _endBlock && (_y + _lineHeight >= _yToElide); + ITextBlock *_endBlock = (_endBlockIter == _end) ? nullptr : (*_endBlockIter); + bool elidedLine = _elideLast && (_y + _lineHeight >= _yToElide); + if (elidedLine) { + // If we decided to draw the last line elided only because of the skip block + // that did not fit on this line, we just draw the line till the very end. + // Skip block is ignored in the elided lines, instead "removeFromEnd" is used. + if (_endBlock && _endBlock->type() == TextBlockTSkip) { + _endBlock = nullptr; + } + if (!_endBlock) { + elidedLine = false; + } + } int blockIndex = _lineStartBlock; ITextBlock *currentBlock = _t->_blocks[blockIndex];