Add an icon to who read context menu item.

This commit is contained in:
John Preston 2021-09-09 16:16:19 +03:00
parent b4bff83266
commit 79b0bbf6cf
9 changed files with 45 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -324,6 +324,20 @@ rpl::producer<Ui::WhoReadContent> WhoRead(
auto lifetime = rpl::lifetime();
const auto state = lifetime.make_state<State>();
state->current.type = [&] {
if (const auto media = item->media()) {
if (!media->webpage()) {
if (const auto document = media->document()) {
if (document->isVoiceMessage()) {
return Ui::WhoReadType::Listened;
} else if (document->isVideoMessage()) {
return Ui::WhoReadType::Watched;
}
}
}
}
return Ui::WhoReadType::Seen;
}();
const auto pushNext = [=] {
consumer.put_next_copy(state->current);
};
@ -334,7 +348,10 @@ rpl::producer<Ui::WhoReadContent> WhoRead(
) | rpl::start_with_next([=](const std::vector<PeerId> &peers) {
if (ListUnknown(peers, item)) {
state->userpics.clear();
consumer.put_next(Ui::WhoReadContent{ .unknown = true });
consumer.put_next(Ui::WhoReadContent{
.type = state->current.type,
.unknown = true,
});
return;
} else if (UpdateUserpics(state, item, peers)) {
RegenerateParticipants(state, small, large);

View file

@ -869,6 +869,7 @@ WhoRead {
photoSize: pixels;
photoSkip: pixels;
nameLeft: pixels;
iconPosition: point;
itemPadding: margins;
}
defaultWhoRead: WhoRead {
@ -882,7 +883,8 @@ defaultWhoRead: WhoRead {
photoSize: 30px;
photoSkip: 5px;
nameLeft: 57px;
itemPadding: margins(17px, 8px, 17px, 6px);
iconPosition: point(14px, 9px);
itemPadding: margins(38px, 8px, 17px, 6px);
}
whoReadMenu: PopupMenu(defaultPopupMenu) {
scrollPadding: margins(0px, 6px, 0px, 6px);
@ -891,3 +893,9 @@ whoReadMenu: PopupMenu(defaultPopupMenu) {
separatorPadding: margins(0px, 6px, 0px, 8px);
}
}
whoReadChecks: icon{{ "chat/seen_checks", windowFg }};
whoReadChecksOver: icon{{ "chat/seen_checks", windowFgOver }};
whoReadChecksDisabled: icon{{ "chat/seen_checks", menuFgDisabled }};
whoReadPlayed: icon{{ "chat/seen_played", windowFg }};
whoReadPlayedOver: icon{{ "chat/seen_played", windowFgOver }};
whoReadPlayedDisabled: icon {{ "chat/seen_played", menuFgDisabled }};

View file

@ -251,11 +251,11 @@ void Action::resolveMinWidth() {
width(tr::lng_context_seen_text(tr::now, lt_count, 999)),
width(tr::lng_context_seen_listened(tr::now, lt_count, 999)),
width(tr::lng_context_seen_watched(tr::now, lt_count, 999)) });
const auto maxWidth = _st.itemPadding.left()
const auto maxWidth = st::defaultWhoRead.itemPadding.left()
+ maxIconWidth
+ maxTextWidth
+ _userpics->maxWidth()
+ _st.itemPadding.right();
+ st::defaultWhoRead.itemPadding.right();
setMinWidth(maxWidth);
}
@ -330,6 +330,18 @@ void Action::paint(Painter &p) {
if (enabled) {
paintRipple(p, 0, 0);
}
const auto &icon = (_content.type == WhoReadType::Seen)
? (!enabled
? st::whoReadChecksDisabled
: selected
? st::whoReadChecksOver
: st::whoReadChecks)
: (!enabled
? st::whoReadPlayedDisabled
: selected
? st::whoReadPlayedOver
: st::whoReadPlayed);
icon.paint(p, st::defaultWhoRead.iconPosition, width());
p.setPen(!enabled
? _st.itemFgDisabled
: selected
@ -337,13 +349,13 @@ void Action::paint(Painter &p) {
: _st.itemFg);
_text.drawLeftElided(
p,
_st.itemPadding.left(),
_st.itemPadding.top(),
st::defaultWhoRead.itemPadding.left(),
st::defaultWhoRead.itemPadding.top(),
_textWidth,
width());
_userpics->paint(
p,
width() - _st.itemPadding.right(),
width() - st::defaultWhoRead.itemPadding.right(),
(height() - st::defaultWhoRead.userpics.size) / 2,
st::defaultWhoRead.userpics.size);
}
@ -372,7 +384,7 @@ void Action::refreshText() {
void Action::refreshDimensions() {
const auto textWidth = _text.maxWidth();
const auto &padding = _st.itemPadding;
const auto &padding = st::defaultWhoRead.itemPadding;
const auto goodWidth = padding.left()
+ textWidth