Adapt share voice chat link box styles.

This commit is contained in:
John Preston 2021-03-10 21:36:21 +04:00
parent 16e1c740ce
commit c587335ae1
5 changed files with 97 additions and 58 deletions

View file

@ -215,17 +215,23 @@ localStorageLimitMargin: margins(22px, 5px, 20px, 10px);
shareRowsTop: 12px; shareRowsTop: 12px;
shareRowHeight: 108px; shareRowHeight: 108px;
sharePhotoTop: 6px; sharePhotoTop: 6px;
sharePhotoCheckbox: RoundImageCheckbox(defaultPeerListCheckbox) { shareBoxListItem: PeerListItem(defaultPeerListItem) {
imageRadius: 28px; nameStyle: TextStyle(defaultTextStyle) {
imageSmallRadius: 24px; font: font(11px);
linkFont: font(11px);
linkFontOver: font(11px);
}
nameFg: windowFg;
nameFgChecked: windowActiveTextFg;
checkbox: RoundImageCheckbox(defaultPeerListCheckbox) {
imageRadius: 28px;
imageSmallRadius: 24px;
}
} }
shareNameStyle: TextStyle(defaultTextStyle) { shareBoxList: PeerList(defaultPeerList) {
font: font(11px); bg: boxBg;
linkFont: font(11px); item: shareBoxListItem;
linkFontOver: font(11px);
} }
shareNameFg: windowFg;
shareNameActiveFg: windowActiveTextFg;
shareNameTop: 6px; shareNameTop: 6px;
shareColumnSkip: 6px; shareColumnSkip: 6px;
shareActivateDuration: 150; shareActivateDuration: 150;

View file

@ -44,10 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class ShareBox::Inner final : public Ui::RpWidget, private base::Subscriber { class ShareBox::Inner final : public Ui::RpWidget, private base::Subscriber {
public: public:
Inner( Inner(QWidget *parent, const Descriptor &descriptor);
QWidget *parent,
not_null<Main::Session*> session,
ShareBox::FilterCallback &&filterCallback);
void setPeerSelectedChangedCallback( void setPeerSelectedChangedCallback(
Fn<void(PeerData *peer, bool selected)> callback); Fn<void(PeerData *peer, bool selected)> callback);
@ -84,7 +81,10 @@ protected:
private: private:
struct Chat { struct Chat {
Chat(PeerData *peer, Fn<void()> updateCallback); Chat(
PeerData *peer,
const style::PeerListItem &st,
Fn<void()> updateCallback);
PeerData *peer; PeerData *peer;
Ui::RoundImageCheckbox checkbox; Ui::RoundImageCheckbox checkbox;
@ -121,7 +121,8 @@ private:
void refresh(); void refresh();
const not_null<Main::Session*> _session; const Descriptor &_descriptor;
const style::PeerList &_st;
float64 _columnSkip = 0.; float64 _columnSkip = 0.;
float64 _rowWidthReal = 0.; float64 _rowWidthReal = 0.;
@ -133,7 +134,6 @@ private:
int _active = -1; int _active = -1;
int _upon = -1; int _upon = -1;
ShareBox::FilterCallback _filterCallback;
std::unique_ptr<Dialogs::IndexedList> _chatsIndexed; std::unique_ptr<Dialogs::IndexedList> _chatsIndexed;
QString _filter; QString _filter;
std::vector<not_null<Dialogs::Row*>> _filtered; std::vector<not_null<Dialogs::Row*>> _filtered;
@ -158,13 +158,17 @@ ShareBox::ShareBox(QWidget*, Descriptor &&descriptor)
, _api(&_descriptor.session->mtp()) , _api(&_descriptor.session->mtp())
, _select( , _select(
this, this,
st::defaultMultiSelect, (_descriptor.stMultiSelect
? *_descriptor.stMultiSelect
: st::defaultMultiSelect),
tr::lng_participant_filter()) tr::lng_participant_filter())
, _comment( , _comment(
this, this,
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
this, this,
st::shareComment, (_descriptor.stComment
? *_descriptor.stComment
: st::shareComment),
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_photos_comment()), tr::lng_photos_comment()),
st::shareCommentPadding) st::shareCommentPadding)
@ -235,10 +239,7 @@ void ShareBox::prepare() {
setTitle(tr::lng_share_title()); setTitle(tr::lng_share_title());
_inner = setInnerWidget( _inner = setInnerWidget(
object_ptr<Inner>( object_ptr<Inner>(this, _descriptor),
this,
_descriptor.session,
std::move(_descriptor.filterCallback)),
getTopScrollSkip(), getTopScrollSkip(),
getBottomScrollSkip()); getBottomScrollSkip());
@ -541,13 +542,10 @@ void ShareBox::scrollAnimationCallback() {
//scrollArea()->scrollToY(scrollTop); //scrollArea()->scrollToY(scrollTop);
} }
ShareBox::Inner::Inner( ShareBox::Inner::Inner(QWidget *parent, const Descriptor &descriptor)
QWidget *parent,
not_null<Main::Session*> session,
ShareBox::FilterCallback &&filterCallback)
: RpWidget(parent) : RpWidget(parent)
, _session(session) , _descriptor(descriptor)
, _filterCallback(std::move(filterCallback)) , _st(_descriptor.st ? *_descriptor.st : st::shareBoxList)
, _chatsIndexed( , _chatsIndexed(
std::make_unique<Dialogs::IndexedList>( std::make_unique<Dialogs::IndexedList>(
Dialogs::SortMode::Add)) { Dialogs::SortMode::Add)) {
@ -555,44 +553,44 @@ ShareBox::Inner::Inner(
_rowHeight = st::shareRowHeight; _rowHeight = st::shareRowHeight;
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
const auto self = session->user(); const auto self = _descriptor.session->user();
if (_filterCallback(self)) { if (_descriptor.filterCallback(self)) {
_chatsIndexed->addToEnd(self->owner().history(self)); _chatsIndexed->addToEnd(self->owner().history(self));
} }
const auto addList = [&](not_null<Dialogs::IndexedList*> list) { const auto addList = [&](not_null<Dialogs::IndexedList*> list) {
for (const auto row : list->all()) { for (const auto row : list->all()) {
if (const auto history = row->history()) { if (const auto history = row->history()) {
if (!history->peer->isSelf() if (!history->peer->isSelf()
&& _filterCallback(history->peer)) { && _descriptor.filterCallback(history->peer)) {
_chatsIndexed->addToEnd(history); _chatsIndexed->addToEnd(history);
} }
} }
} }
}; };
addList(_session->data().chatsList()->indexed()); addList(_descriptor.session->data().chatsList()->indexed());
const auto id = Data::Folder::kId; const auto id = Data::Folder::kId;
if (const auto folder = _session->data().folderLoaded(id)) { if (const auto folder = _descriptor.session->data().folderLoaded(id)) {
addList(folder->chatsList()->indexed()); addList(folder->chatsList()->indexed());
} }
addList(_session->data().contactsNoChatsList()); addList(_descriptor.session->data().contactsNoChatsList());
_filter = qsl("a"); _filter = qsl("a");
updateFilter(); updateFilter();
_session->changes().peerUpdates( _descriptor.session->changes().peerUpdates(
Data::PeerUpdate::Flag::Photo Data::PeerUpdate::Flag::Photo
) | rpl::start_with_next([=](const Data::PeerUpdate &update) { ) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
updateChat(update.peer); updateChat(update.peer);
}, lifetime()); }, lifetime());
_session->changes().realtimeNameUpdates( _descriptor.session->changes().realtimeNameUpdates(
) | rpl::start_with_next([=](const Data::NameUpdate &update) { ) | rpl::start_with_next([=](const Data::NameUpdate &update) {
_chatsIndexed->peerNameChanged( _chatsIndexed->peerNameChanged(
update.peer, update.peer,
update.oldFirstLetters); update.oldFirstLetters);
}, lifetime()); }, lifetime());
_session->downloaderTaskFinished( _descriptor.session->downloaderTaskFinished(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
update(); update();
}, lifetime()); }, lifetime());
@ -661,7 +659,7 @@ void ShareBox::Inner::updateChatName(
: peer->isRepliesChat() : peer->isRepliesChat()
? tr::lng_replies_messages(tr::now) ? tr::lng_replies_messages(tr::now)
: peer->name; : peer->name;
chat->name.setText(st::shareNameStyle, text, Ui::NameTextOptions()); chat->name.setText(_st.item.nameStyle, text, Ui::NameTextOptions());
} }
void ShareBox::Inner::repaintChatAtIndex(int index) { void ShareBox::Inner::repaintChatAtIndex(int index) {
@ -784,7 +782,7 @@ auto ShareBox::Inner::getChat(not_null<Dialogs::Row*> row)
} }
const auto [i, ok] = _dataMap.emplace( const auto [i, ok] = _dataMap.emplace(
peer, peer,
std::make_unique<Chat>(peer, [=] { repaintChat(peer); })); std::make_unique<Chat>(peer, _st.item, [=] { repaintChat(peer); }));
updateChatName(i->second.get(), peer); updateChatName(i->second.get(), peer);
row->attached = i->second.get(); row->attached = i->second.get();
return i->second.get(); return i->second.get();
@ -815,23 +813,26 @@ void ShareBox::Inner::paintChat(
auto y = _rowsTop + (index / _columnCount) * _rowHeight; auto y = _rowsTop + (index / _columnCount) * _rowHeight;
auto outerWidth = width(); auto outerWidth = width();
auto photoLeft = (_rowWidth - (st::sharePhotoCheckbox.imageRadius * 2)) / 2; auto photoLeft = (_rowWidth - (_st.item.checkbox.imageRadius * 2)) / 2;
auto photoTop = st::sharePhotoTop; auto photoTop = st::sharePhotoTop;
chat->checkbox.paint(p, x + photoLeft, y + photoTop, outerWidth); chat->checkbox.paint(p, x + photoLeft, y + photoTop, outerWidth);
auto nameActive = chat->nameActive.value((index == _active) ? 1. : 0.); auto nameActive = chat->nameActive.value((index == _active) ? 1. : 0.);
p.setPen(anim::pen(st::shareNameFg, st::shareNameActiveFg, nameActive)); p.setPen(anim::pen(_st.item.nameFg, _st.item.nameFgChecked, nameActive));
auto nameWidth = (_rowWidth - st::shareColumnSkip); auto nameWidth = (_rowWidth - st::shareColumnSkip);
auto nameLeft = st::shareColumnSkip / 2; auto nameLeft = st::shareColumnSkip / 2;
auto nameTop = photoTop + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop; auto nameTop = photoTop + _st.item.checkbox.imageRadius * 2 + st::shareNameTop;
chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true); chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true);
} }
ShareBox::Inner::Chat::Chat(PeerData *peer, Fn<void()> updateCallback) ShareBox::Inner::Chat::Chat(
PeerData *peer,
const style::PeerListItem &st,
Fn<void()> updateCallback)
: peer(peer) : peer(peer)
, checkbox(st::sharePhotoCheckbox, updateCallback, PaintUserpicCallback(peer, true)) , checkbox(st.checkbox, updateCallback, PaintUserpicCallback(peer, true))
, name(st::sharePhotoCheckbox.imageRadius * 2) { , name(st.checkbox.imageRadius * 2) {
} }
void ShareBox::Inner::paintEvent(QPaintEvent *e) { void ShareBox::Inner::paintEvent(QPaintEvent *e) {
@ -839,7 +840,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
auto r = e->rect(); auto r = e->rect();
p.setClipRect(r); p.setClipRect(r);
p.fillRect(r, st::boxBg); p.fillRect(r, _st.bg);
auto yFrom = r.y(), yTo = r.y() + r.height(); auto yFrom = r.y(), yTo = r.y() + r.height();
auto rowFrom = yFrom / _rowHeight; auto rowFrom = yFrom / _rowHeight;
auto rowTo = (yTo + _rowHeight - 1) / _rowHeight; auto rowTo = (yTo + _rowHeight - 1) / _rowHeight;
@ -857,7 +858,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
} }
} else { } else {
p.setFont(st::noContactsFont); p.setFont(st::noContactsFont);
p.setPen(st::noContactsColor); p.setPen(_st.about.textFg);
p.drawText( p.drawText(
rect().marginsRemoved(st::boxPadding), rect().marginsRemoved(st::boxPadding),
tr::lng_bot_no_chats(tr::now), tr::lng_bot_no_chats(tr::now),
@ -868,7 +869,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
&& _byUsernameFiltered.empty() && _byUsernameFiltered.empty()
&& !_searching) { && !_searching) {
p.setFont(st::noContactsFont); p.setFont(st::noContactsFont);
p.setPen(st::noContactsColor); p.setPen(_st.about.textFg);
p.drawText( p.drawText(
rect().marginsRemoved(st::boxPadding), rect().marginsRemoved(st::boxPadding),
tr::lng_bot_chats_not_found(tr::now), tr::lng_bot_chats_not_found(tr::now),
@ -924,7 +925,7 @@ void ShareBox::Inner::updateUpon(const QPoint &pos) {
auto left = _rowsLeft + qFloor(column * _rowWidthReal) + st::shareColumnSkip / 2; auto left = _rowsLeft + qFloor(column * _rowWidthReal) + st::shareColumnSkip / 2;
auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop; auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop;
auto xupon = (x >= left) && (x < left + (_rowWidth - st::shareColumnSkip)); auto xupon = (x >= left) && (x < left + (_rowWidth - st::shareColumnSkip));
auto yupon = (y >= top) && (y < top + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop + st::shareNameStyle.font->height * 2); auto yupon = (y >= top) && (y < top + _st.item.checkbox.imageRadius * 2 + st::shareNameTop + _st.item.nameStyle.font->height * 2);
auto upon = (xupon && yupon) ? (row * _columnCount + column) : -1; auto upon = (xupon && yupon) ? (row * _columnCount + column) : -1;
if (upon >= displayedChatsCount()) { if (upon >= displayedChatsCount()) {
upon = -1; upon = -1;
@ -944,8 +945,8 @@ void ShareBox::Inner::selectActive() {
} }
void ShareBox::Inner::resizeEvent(QResizeEvent *e) { void ShareBox::Inner::resizeEvent(QResizeEvent *e) {
_columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / float64(_columnCount + 1); _columnSkip = (width() - _columnCount * _st.item.checkbox.imageRadius * 2) / float64(_columnCount + 1);
_rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip; _rowWidthReal = _st.item.checkbox.imageRadius * 2 + _columnSkip;
_rowsLeft = qFloor(_columnSkip / 2); _rowsLeft = qFloor(_columnSkip / 2);
_rowWidth = qFloor(_rowWidthReal); _rowWidth = qFloor(_rowWidthReal);
update(); update();
@ -1051,9 +1052,10 @@ void ShareBox::Inner::peopleReceived(
d_byUsernameFiltered.reserve(already + my.size() + people.size()); d_byUsernameFiltered.reserve(already + my.size() + people.size());
const auto feedList = [&](const QVector<MTPPeer> &list) { const auto feedList = [&](const QVector<MTPPeer> &list) {
for (const auto &data : list) { for (const auto &data : list) {
if (const auto peer = _session->data().peerLoaded(peerFromMTP(data))) { if (const auto peer = _descriptor.session->data().peerLoaded(
const auto history = _session->data().historyLoaded(peer); peerFromMTP(data))) {
if (!_filterCallback(peer)) { const auto history = _descriptor.session->data().historyLoaded(peer);
if (!_descriptor.filterCallback(peer)) {
continue; continue;
} else if (history && _chatsIndexed->getRow(history)) { } else if (history && _chatsIndexed->getRow(history)) {
continue; continue;
@ -1063,6 +1065,7 @@ void ShareBox::Inner::peopleReceived(
_byUsernameFiltered.push_back(peer); _byUsernameFiltered.push_back(peer);
d_byUsernameFiltered.push_back(std::make_unique<Chat>( d_byUsernameFiltered.push_back(std::make_unique<Chat>(
peer, peer,
_st.item,
[=] { repaintChat(peer); })); [=] { repaintChat(peer); }));
updateChatName(d_byUsernameFiltered.back().get(), peer); updateChatName(d_byUsernameFiltered.back().get(), peer);
} }

View file

@ -14,6 +14,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/round_checkbox.h" #include "ui/effects/round_checkbox.h"
#include "mtproto/sender.h" #include "mtproto/sender.h"
namespace style {
struct MultiSelect;
struct InputField;
struct PeerList;
} // namespace style
namespace SendMenu { namespace SendMenu {
enum class Type; enum class Type;
} // namespace SendMenu } // namespace SendMenu
@ -69,6 +75,9 @@ public:
Fn<void(not_null<Ui::InputField*>)> initSpellchecker; Fn<void(not_null<Ui::InputField*>)> initSpellchecker;
Fn<void(not_null<Ui::InputField*>)> initEditLink; Fn<void(not_null<Ui::InputField*>)> initEditLink;
object_ptr<Ui::RpWidget> bottomWidget = { nullptr }; object_ptr<Ui::RpWidget> bottomWidget = { nullptr };
const style::MultiSelect *stMultiSelect = nullptr;
const style::InputField *stComment = nullptr;
const style::PeerList *st = nullptr;
}; };
ShareBox(QWidget*, Descriptor &&descriptor); ShareBox(QWidget*, Descriptor &&descriptor);

View file

@ -557,7 +557,6 @@ groupCallMultiSelect: MultiSelect(defaultMultiSelect) {
ripple: groupCallRipple; ripple: groupCallRipple;
} }
} }
groupCallField: InputField(defaultInputField) { groupCallField: InputField(defaultInputField) {
textMargins: margins(2px, 7px, 2px, 0px); textMargins: margins(2px, 7px, 2px, 0px);
@ -578,6 +577,22 @@ groupCallField: InputField(defaultInputField) {
menu: groupCallPopupMenu; menu: groupCallPopupMenu;
} }
groupCallShareBoxComment: InputField(groupCallField) {
textMargins: margins(8px, 8px, 8px, 6px);
heightMin: 36px;
heightMax: 72px;
placeholderMargins: margins(2px, 0px, 2px, 0px);
border: 0px;
borderActive: 0px;
}
groupCallShareBoxList: PeerList(groupCallMembersList) {
item: PeerListItem(groupCallMembersListItem) {
checkbox: RoundImageCheckbox(groupCallMembersListCheckbox) {
imageRadius: 28px;
imageSmallRadius: 24px;
}
}
}
groupCallMembersTop: 51px; groupCallMembersTop: 51px;
groupCallTitleTop: 8px; groupCallTitleTop: 8px;
@ -913,6 +928,8 @@ groupCallStatusSpeakerArcsAnimation: ArcsAnimation(groupCallSpeakerArcsAnimation
startHeight: 1px; startHeight: 1px;
} }
groupCallShareMutedMargin: margins(16px, 16px, 16px, 8px);
callTopBarMuteCrossLine: CrossLineAnimation { callTopBarMuteCrossLine: CrossLineAnimation {
fg: callBarFg; fg: callBarFg;
icon: icon {{ "calls/call_record_active", callBarFg }}; icon: icon {{ "calls/call_record_active", callBarFg }};

View file

@ -105,8 +105,9 @@ object_ptr<ShareBox> ShareInviteLinkBox(
object_ptr<Ui::Checkbox>( object_ptr<Ui::Checkbox>(
nullptr, nullptr,
tr::lng_group_call_share_listener(tr::now), tr::lng_group_call_share_listener(tr::now),
true), true,
style::margins(16, 16, 16, 16));// #TODO calls style st::groupCallCheckbox),
st::groupCallShareMutedMargin);
const auto listenerCheckbox = bottom->entity(); const auto listenerCheckbox = bottom->entity();
const auto currentLink = [=] { const auto currentLink = [=] {
return listenerCheckbox->checked() ? linkListener : linkSpeaker; return listenerCheckbox->checked() ? linkListener : linkSpeaker;
@ -186,7 +187,10 @@ object_ptr<ShareBox> ShareInviteLinkBox(
.copyCallback = std::move(copyCallback), .copyCallback = std::move(copyCallback),
.submitCallback = std::move(submitCallback), .submitCallback = std::move(submitCallback),
.filterCallback = std::move(filterCallback), .filterCallback = std::move(filterCallback),
.bottomWidget = std::move(bottom) }); .bottomWidget = std::move(bottom),
.stMultiSelect = &st::groupCallMultiSelect,
.stComment = &st::groupCallShareBoxComment,
.stItem = &st::groupCallShareBoxList });
*box = result.data(); *box = result.data();
return result; return result;
} }