selections now render over all images

This commit is contained in:
fourtf 2018-04-10 03:29:00 +02:00
parent eb26b1fbb3
commit 3ba55ee511
3 changed files with 17 additions and 17 deletions

View file

@ -166,6 +166,11 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
painter.fillRect(0, y, pixmap->width(), pixmap->height(), themeManager.messages.disabled);
}
// draw selection
if (!selection.isEmpty()) {
this->container.paintSelection(painter, messageIndex, selection, y);
}
// draw last read message line
if (isLastReadMessage) {
QColor color = isWindowFocused ? themeManager.tabs.selected.backgrounds.regular.color()
@ -193,11 +198,6 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &s
? themeManager.messages.backgrounds.highlighted
: themeManager.messages.backgrounds.regular);
// draw selection
if (!selection.isEmpty()) {
this->container.paintSelection(painter, messageIndex, selection);
}
// draw message
this->container.paintElements(painter);

View file

@ -196,7 +196,7 @@ void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffse
}
void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
Selection &selection)
Selection &selection, int yOffset)
{
singletons::ThemeManager &themeManager = singletons::ThemeManager::getInstance();
QColor selectionColor = themeManager.messages.selection;
@ -211,8 +211,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
for (Line &line : this->lines) {
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
@ -270,8 +270,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
Line &line = this->lines[lineIndex2];
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
@ -290,8 +290,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
rect.setLeft(x);
rect.setRight(r);
@ -316,8 +316,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
if (line.endCharIndex < /*=*/selection.max.charIndex) {
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
@ -340,8 +340,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(r);

View file

@ -68,7 +68,7 @@ struct MessageLayoutContainer {
// painting
void paintElements(QPainter &painter);
void paintAnimatedElements(QPainter &painter, int yOffset);
void paintSelection(QPainter &painter, int messageIndex, Selection &selection);
void paintSelection(QPainter &painter, int messageIndex, Selection &selection, int yOffset);
// selection
int getSelectionIndex(QPoint point);