mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Differentiated replies in groups by color.
This commit is contained in:
parent
551bf4f9a7
commit
294432ceed
4 changed files with 40 additions and 10 deletions
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/painter.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/view/history_view_message.h" // FromNameFg.
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/media/history_view_document.h"
|
||||
#include "core/click_handler_types.h"
|
||||
|
@ -45,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace {
|
||||
|
||||
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
||||
constexpr auto kReplyBarAlpha = 230. / 255.;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -292,8 +294,16 @@ bool HistoryMessageReply::updateData(
|
|||
peerToUser(bot->id));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const auto peerId = replyToMsg->fullId().peer;
|
||||
replyToColorKey = (peerIsChannel(peerId) || peerIsChat(peerId))
|
||||
? replyToMsg->from()->id
|
||||
: PeerId(0);
|
||||
}
|
||||
} else if (force) {
|
||||
replyToMsgId = 0;
|
||||
replyToColorKey = PeerId(0);
|
||||
}
|
||||
if (force) {
|
||||
holder->history()->owner().requestItemResize(holder);
|
||||
|
@ -422,11 +432,23 @@ void HistoryMessageReply::paint(
|
|||
const auto st = context.st;
|
||||
const auto stm = context.messageStyle();
|
||||
|
||||
const auto &bar = inBubble
|
||||
? stm->msgReplyBarColor
|
||||
: st->msgImgReplyBarColor();
|
||||
QRect rbar(style::rtlrect(x + st::msgReplyBarPos.x(), y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.width(), st::msgReplyBarSize.height(), w + 2 * x));
|
||||
p.fillRect(rbar, bar);
|
||||
{
|
||||
const auto &bar = !inBubble
|
||||
? st->msgImgReplyBarColor()
|
||||
: replyToColorKey
|
||||
? HistoryView::FromNameFg(context, replyToColorKey)
|
||||
: stm->msgReplyBarColor;
|
||||
const auto rbar = style::rtlrect(
|
||||
x + st::msgReplyBarPos.x(),
|
||||
y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(),
|
||||
st::msgReplyBarSize.width(),
|
||||
st::msgReplyBarSize.height(),
|
||||
w + 2 * x);
|
||||
const auto opacity = p.opacity();
|
||||
p.setOpacity(opacity * kReplyBarAlpha);
|
||||
p.fillRect(rbar, bar);
|
||||
p.setOpacity(opacity);
|
||||
}
|
||||
|
||||
if (w > st::msgReplyBarSkip) {
|
||||
if (replyToMsg) {
|
||||
|
@ -452,9 +474,11 @@ void HistoryMessageReply::paint(
|
|||
}
|
||||
}
|
||||
if (w > st::msgReplyBarSkip + previewSkip) {
|
||||
p.setPen(inBubble
|
||||
? stm->msgServiceFg
|
||||
: st->msgImgReplyBarColor());
|
||||
p.setPen(!inBubble
|
||||
? st->msgImgReplyBarColor()
|
||||
: replyToColorKey
|
||||
? HistoryView::FromNameFg(context, replyToColorKey)
|
||||
: stm->msgServiceFg);
|
||||
replyToName.drawLeftElided(p, x + st::msgReplyBarSkip + previewSkip, y + st::msgReplyPadding.top(), w - st::msgReplyBarSkip - previewSkip, w + 2 * x);
|
||||
if (replyToVia && w > st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew) {
|
||||
p.setFont(st::msgServiceFont);
|
||||
|
|
|
@ -240,6 +240,8 @@ struct HistoryMessageReply
|
|||
PeerId replyToPeerId = 0;
|
||||
MsgId replyToMsgId = 0;
|
||||
MsgId replyToMsgTop = 0;
|
||||
using ColorKey = PeerId;
|
||||
ColorKey replyToColorKey = 0;
|
||||
DocumentId replyToDocumentId = 0;
|
||||
WebPageId replyToWebPageId = 0;
|
||||
ReplyToMessagePointer replyToMsg;
|
||||
|
|
|
@ -225,6 +225,8 @@ QString FastReplyText() {
|
|||
return tr::lng_fast_reply(tr::now);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
style::color FromNameFg(
|
||||
const Ui::ChatPaintContext &context,
|
||||
PeerId peerId) {
|
||||
|
@ -256,8 +258,6 @@ style::color FromNameFg(
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
struct Message::CommentsButton {
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
int rippleShift = 0;
|
||||
|
|
|
@ -56,6 +56,10 @@ struct BottomRippleMask {
|
|||
int shift = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] style::color FromNameFg(
|
||||
const Ui::ChatPaintContext &context,
|
||||
PeerId peerId);
|
||||
|
||||
class Message final : public Element {
|
||||
public:
|
||||
Message(
|
||||
|
|
Loading…
Add table
Reference in a new issue