Skip to content

Commit

Permalink
Restore compact emotes logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge committed Oct 22, 2022
1 parent 38df74c commit 5f61cec
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/messages/layouts/MessageLayoutContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,20 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element,
this->currentY_ = int(this->margin.top * this->scale_);
}

int elementLineHeight = element->getRect().height();

// compact emote offset
bool isCompactEmote =
!this->flags_.has(MessageFlag::DisableCompactEmotes) &&
element->getCreator().getFlags().has(MessageElementFlag::EmoteImages);

if (isCompactEmote)
{
elementLineHeight -= COMPACT_EMOTES_OFFSET * this->scale_;
}

// update line height
this->lineHeight_ =
std::max(this->lineHeight_, element->getRect().height());
this->lineHeight_ = std::max(this->lineHeight_, elementLineHeight);

auto xOffset = 0;
bool isZeroWidthEmote = element->getCreator().getFlags().has(
Expand Down Expand Up @@ -207,6 +218,14 @@ void MessageLayoutContainer::breakLine()
{
MessageLayoutElement *element = this->elements_.at(i).get();

bool isCompactEmote =
!this->flags_.has(MessageFlag::DisableCompactEmotes) &&
element->getCreator().getFlags().has(
MessageElementFlag::EmoteImages);

int yExtra =
isCompactEmote ? (COMPACT_EMOTES_OFFSET / 2) * this->scale_ : 0;

int newX = element->getRect().x() + xOffset +
int(this->margin.left * this->scale_);

Expand All @@ -228,7 +247,8 @@ void MessageLayoutContainer::breakLine()
break;
}

element->setPosition(QPoint(newX, element->getRect().top() + yShift));
element->setPosition(
QPoint(newX, element->getRect().top() + yShift + yExtra));
}

if (this->lines_.size() != 0)
Expand Down

0 comments on commit 5f61cec

Please sign in to comment.