Fix styling of channel point reward message text. (#1845)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Jonas Schmitt 2020-08-09 11:50:53 +02:00 committed by GitHub
parent 73f7786522
commit 58725efbd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -42,6 +42,7 @@ enum class MessageElementFlag {
BttvEmote = BttvEmoteImage | BttvEmoteText,
ChannelPointReward = (1 << 8),
ChannelPointRewardImage = ChannelPointReward | TwitchEmoteImage,
FfzEmoteImage = (1 << 10),
FfzEmoteText = (1 << 11),

View file

@ -123,9 +123,20 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element,
xOffset -= element->getRect().width() + this->spaceWidth_;
}
auto yOffset = 0;
if (element->getCreator().getFlags().has(
MessageElementFlag::ChannelPointReward) &&
element->getCreator().getFlags().hasNone(
{MessageElementFlag::TwitchEmoteImage}))
{
yOffset -= (this->margin.top * this->scale_);
}
// set move element
element->setPosition(QPoint(this->currentX_ + xOffset,
this->currentY_ - element->getRect().height()));
element->setPosition(
QPoint(this->currentX_ + xOffset,
this->currentY_ - element->getRect().height() + yOffset));
// add element
this->elements_.push_back(std::unique_ptr<MessageLayoutElement>(element));

View file

@ -1158,7 +1158,7 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage(
reward.title, MessageElementFlag::ChannelPointReward,
MessageColor::Text, FontStyle::ChatMediumBold);
builder->emplace<ScalingImageElement>(
reward.image, MessageElementFlag::ChannelPointReward);
reward.image, MessageElementFlag::ChannelPointRewardImage);
builder->emplace<TextElement>(
QString::number(reward.cost), MessageElementFlag::ChannelPointReward,
MessageColor::Text, FontStyle::ChatMediumBold);