mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 "ui/painter.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_message.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/history_view_service_message.h"
|
||||||
#include "history/view/media/history_view_document.h"
|
#include "history/view/media/history_view_document.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -45,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
||||||
|
constexpr auto kReplyBarAlpha = 230. / 255.;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -292,8 +294,16 @@ bool HistoryMessageReply::updateData(
|
||||||
peerToUser(bot->id));
|
peerToUser(bot->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto peerId = replyToMsg->fullId().peer;
|
||||||
|
replyToColorKey = (peerIsChannel(peerId) || peerIsChat(peerId))
|
||||||
|
? replyToMsg->from()->id
|
||||||
|
: PeerId(0);
|
||||||
|
}
|
||||||
} else if (force) {
|
} else if (force) {
|
||||||
replyToMsgId = 0;
|
replyToMsgId = 0;
|
||||||
|
replyToColorKey = PeerId(0);
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
holder->history()->owner().requestItemResize(holder);
|
holder->history()->owner().requestItemResize(holder);
|
||||||
|
@ -422,11 +432,23 @@ void HistoryMessageReply::paint(
|
||||||
const auto st = context.st;
|
const auto st = context.st;
|
||||||
const auto stm = context.messageStyle();
|
const auto stm = context.messageStyle();
|
||||||
|
|
||||||
const auto &bar = inBubble
|
{
|
||||||
? stm->msgReplyBarColor
|
const auto &bar = !inBubble
|
||||||
: st->msgImgReplyBarColor();
|
? 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));
|
: replyToColorKey
|
||||||
p.fillRect(rbar, bar);
|
? 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 (w > st::msgReplyBarSkip) {
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
|
@ -452,9 +474,11 @@ void HistoryMessageReply::paint(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (w > st::msgReplyBarSkip + previewSkip) {
|
if (w > st::msgReplyBarSkip + previewSkip) {
|
||||||
p.setPen(inBubble
|
p.setPen(!inBubble
|
||||||
? stm->msgServiceFg
|
? st->msgImgReplyBarColor()
|
||||||
: 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);
|
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) {
|
if (replyToVia && w > st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew) {
|
||||||
p.setFont(st::msgServiceFont);
|
p.setFont(st::msgServiceFont);
|
||||||
|
|
|
@ -240,6 +240,8 @@ struct HistoryMessageReply
|
||||||
PeerId replyToPeerId = 0;
|
PeerId replyToPeerId = 0;
|
||||||
MsgId replyToMsgId = 0;
|
MsgId replyToMsgId = 0;
|
||||||
MsgId replyToMsgTop = 0;
|
MsgId replyToMsgTop = 0;
|
||||||
|
using ColorKey = PeerId;
|
||||||
|
ColorKey replyToColorKey = 0;
|
||||||
DocumentId replyToDocumentId = 0;
|
DocumentId replyToDocumentId = 0;
|
||||||
WebPageId replyToWebPageId = 0;
|
WebPageId replyToWebPageId = 0;
|
||||||
ReplyToMessagePointer replyToMsg;
|
ReplyToMessagePointer replyToMsg;
|
||||||
|
|
|
@ -225,6 +225,8 @@ QString FastReplyText() {
|
||||||
return tr::lng_fast_reply(tr::now);
|
return tr::lng_fast_reply(tr::now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
style::color FromNameFg(
|
style::color FromNameFg(
|
||||||
const Ui::ChatPaintContext &context,
|
const Ui::ChatPaintContext &context,
|
||||||
PeerId peerId) {
|
PeerId peerId) {
|
||||||
|
@ -256,8 +258,6 @@ style::color FromNameFg(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
struct Message::CommentsButton {
|
struct Message::CommentsButton {
|
||||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||||
int rippleShift = 0;
|
int rippleShift = 0;
|
||||||
|
|
|
@ -56,6 +56,10 @@ struct BottomRippleMask {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] style::color FromNameFg(
|
||||||
|
const Ui::ChatPaintContext &context,
|
||||||
|
PeerId peerId);
|
||||||
|
|
||||||
class Message final : public Element {
|
class Message final : public Element {
|
||||||
public:
|
public:
|
||||||
Message(
|
Message(
|
||||||
|
|
Loading…
Add table
Reference in a new issue