2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 07:25:46 +00:00

Introduced new struct to dialogs style for icons.

This commit is contained in:
23rd
2023-08-30 05:25:34 +03:00
parent 089432be5e
commit 9d4b8bb9b0
10 changed files with 203 additions and 144 deletions

View File

@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_forum_topic.h"
#include "data/data_session.h"
#include "dialogs/dialogs_list.h"
#include "dialogs/dialogs_three_state_icon.h"
#include "dialogs/ui/dialogs_video_userpic.h"
#include "styles/style_dialogs.h"
#include "styles/style_window.h"
@@ -147,11 +148,10 @@ int PaintBadges(
const auto badge = PaintUnreadBadge(p, counter, right, top, st);
right -= badge.width() + st.padding;
} else if (displayPinnedIcon) {
const auto &icon = context.active
? st::dialogsPinnedIconActive
: context.selected
? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon;
const auto &icon = ThreeStateIcon(
st::dialogsPinnedIcon,
context.active,
context.selected);
icon.paint(p, right - icon.width(), pinnedIconTop, context.width);
right -= icon.width() + st::dialogsUnreadPadding;
}
@@ -169,17 +169,12 @@ int PaintBadges(
st.textTop = 0;
const auto counter = QString();
const auto badge = PaintUnreadBadge(p, counter, right, top, st);
(badgesState.mention
? (st.active
? st::dialogsUnreadMentionActive
: st.selected
? st::dialogsUnreadMentionOver
: st::dialogsUnreadMention)
: (st.active
? st::dialogsUnreadReactionActive
: st.selected
? st::dialogsUnreadReactionOver
: st::dialogsUnreadReaction)).paintInCenter(p, badge);
ThreeStateIcon(
badgesState.mention
? st::dialogsUnreadMention
: st::dialogsUnreadReaction,
st.active,
st.selected).paintInCenter(p, badge);
right -= badge.width() + st.padding + st::dialogsUnreadPadding;
}
return (initial - right);
@@ -437,11 +432,10 @@ void PaintRow(
auto availableWidth = namewidth;
if (entry->isPinnedDialog(context.filter)
&& (context.filter || !entry->fixedOnTopIndex())) {
auto &icon = context.active
? st::dialogsPinnedIconActive
: context.selected
? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon;
auto &icon = ThreeStateIcon(
st::dialogsPinnedIcon,
context.active,
context.selected);
icon.paint(
p,
context.width - context.st->padding.right() - icon.width(),
@@ -527,11 +521,10 @@ void PaintRow(
auto availableWidth = namewidth;
if (entry->isPinnedDialog(context.filter)
&& (context.filter || !entry->fixedOnTopIndex())) {
auto &icon = context.active
? st::dialogsPinnedIconActive
: context.selected
? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon;
auto &icon = ThreeStateIcon(
st::dialogsPinnedIcon,
context.active,
context.selected);
icon.paint(p, context.width - context.st->padding.right() - icon.width(), texttop, context.width);
availableWidth -= icon.width() + st::dialogsUnreadPadding;
}
@@ -561,51 +554,49 @@ void PaintRow(
paintItemCallback(nameleft, namewidth);
} else if (entry->isPinnedDialog(context.filter)
&& (context.filter || !entry->fixedOnTopIndex())) {
auto &icon = context.active
? st::dialogsPinnedIconActive
: context.selected
? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon;
icon.paint(p, context.width - context.st->padding.right() - icon.width(), texttop, context.width);
auto &icon = ThreeStateIcon(
st::dialogsPinnedIcon,
context.active,
context.selected);
icon.paint(
p,
context.width - context.st->padding.right() - icon.width(),
texttop,
context.width);
}
const auto sendStateIcon = [&]() -> const style::icon* {
if (!thread) {
return nullptr;
} else if (const auto topic = thread->asTopic()
; !context.search && topic && topic->closed()) {
return &(context.active
? st::dialogsLockIconActive
: context.selected
? st::dialogsLockIconOver
: st::dialogsLockIcon);
return &ThreeStateIcon(
st::dialogsLockIcon,
context.active,
context.selected);
} else if (draft) {
if (draft->saveRequestId) {
return &(context.active
? st::dialogsSendingIconActive
: context.selected
? st::dialogsSendingIconOver
: st::dialogsSendingIcon);
return &ThreeStateIcon(
st::dialogsSendingIcon,
context.active,
context.selected);
}
} else if (item && !item->isEmpty() && item->needCheck()) {
if (!item->isSending() && !item->hasFailed()) {
if (item->unread(thread)) {
return &(context.active
? st::dialogsSentIconActive
: context.selected
? st::dialogsSentIconOver
: st::dialogsSentIcon);
return &ThreeStateIcon(
st::dialogsSentIcon,
context.active,
context.selected);
}
return &(context.active
? st::dialogsReceivedIconActive
: context.selected
? st::dialogsReceivedIconOver
: st::dialogsReceivedIcon);
return &ThreeStateIcon(
st::dialogsReceivedIcon,
context.active,
context.selected);
}
return &(context.active
? st::dialogsSendingIconActive
: context.selected
? st::dialogsSendingIconOver
: st::dialogsSendingIcon);
return &ThreeStateIcon(
st::dialogsSendingIcon,
context.active,
context.selected);
}
return nullptr;
}();
@@ -643,11 +634,10 @@ void PaintRow(
: context.selected
? &st::dialogsVerifiedIconOver
: &st::dialogsVerifiedIcon),
.premium = (context.active
? &st::dialogsPremiumIconActive
: context.selected
? &st::dialogsPremiumIconOver
: &st::dialogsPremiumIcon),
.premium = &ThreeStateIcon(
st::dialogsPremiumIcon,
context.active,
context.selected),
.scam = (context.active
? &st::dialogsScamFgActive
: context.selected
@@ -710,30 +700,26 @@ const style::icon *ChatTypeIcon(
const PaintContext &context) {
if (const auto user = peer->asUser()) {
if (ShowUserBotIcon(user)) {
return &(context.active
? st::dialogsBotIconActive
: context.selected
? st::dialogsBotIconOver
: st::dialogsBotIcon);
return &ThreeStateIcon(
st::dialogsBotIcon,
context.active,
context.selected);
}
} else if (peer->isBroadcast()) {
return &(context.active
? st::dialogsChannelIconActive
: context.selected
? st::dialogsChannelIconOver
: st::dialogsChannelIcon);
return &ThreeStateIcon(
st::dialogsChannelIcon,
context.active,
context.selected);
} else if (peer->isForum()) {
return &(context.active
? st::dialogsForumIconActive
: context.selected
? st::dialogsForumIconOver
: st::dialogsForumIcon);
return &ThreeStateIcon(
st::dialogsForumIcon,
context.active,
context.selected);
} else {
return &(context.active
? st::dialogsChatIconActive
: context.selected
? st::dialogsChatIconOver
: st::dialogsChatIcon);
return &ThreeStateIcon(
st::dialogsChatIcon,
context.active,
context.selected);
}
return nullptr;
}