Rename Dialogs::Layout to Dialogs::Ui.

This commit is contained in:
John Preston 2021-10-01 14:57:24 +04:00
parent b78b27f517
commit 5136cc3c9c
10 changed files with 59 additions and 56 deletions

View file

@ -64,7 +64,7 @@ private:
void setCounter(int counter);
QString _text;
Dialogs::Layout::UnreadBadgeStyle _st;
Dialogs::Ui::UnreadBadgeStyle _st;
};
@ -303,7 +303,7 @@ StickersBox::CounterWidget::CounterWidget(
: RpWidget(parent) {
setAttribute(Qt::WA_TransparentForMouseEvents);
_st.sizeId = Dialogs::Layout::UnreadBadgeInStickersBox;
_st.sizeId = Dialogs::Ui::UnreadBadgeInStickersBox;
_st.textTop = st::stickersFeaturedBadgeTextTop;
_st.size = st::stickersFeaturedBadgeSize;
_st.padding = st::stickersFeaturedBadgePadding;
@ -323,7 +323,7 @@ void StickersBox::CounterWidget::setCounter(int counter) {
Painter p(&dummy);
auto newWidth = 0;
Dialogs::Layout::paintUnreadCount(p, _text, 0, 0, _st, &newWidth);
Dialogs::Ui::paintUnreadCount(p, _text, 0, 0, _st, &newWidth);
resize(newWidth, st::stickersFeaturedBadgeSize);
}
@ -334,7 +334,7 @@ void StickersBox::CounterWidget::paintEvent(QPaintEvent *e) {
if (!_text.isEmpty()) {
auto unreadRight = rtl() ? 0 : width();
auto unreadTop = 0;
Dialogs::Layout::paintUnreadCount(p, _text, unreadRight, unreadTop, _st);
Dialogs::Ui::paintUnreadCount(p, _text, unreadRight, unreadTop, _st);
}
}

View file

@ -165,8 +165,7 @@ InnerWidget::InnerWidget(
session().data().sendActionManager().animationUpdated(
) | rpl::start_with_next([=](
const Data::SendActionManager::AnimationUpdate &update) {
using RowPainter = Layout::RowPainter;
const auto updateRect = RowPainter::sendActionAnimationRect(
const auto updateRect = Ui::RowPainter::sendActionAnimationRect(
update.left,
update.width,
update.height,
@ -440,7 +439,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
}
const auto isActive = (row->key() == active);
const auto isSelected = (row->key() == selected);
Layout::RowPainter::paint(
Ui::RowPainter::paint(
p,
row,
_filterId,
@ -558,7 +557,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
: (from == (isPressed()
? _filteredPressed
: _filteredSelected));
Layout::RowPainter::paint(
Ui::RowPainter::paint(
p,
_filterResults[from],
_filterId,
@ -650,7 +649,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
: (from == (isPressed()
? _searchedPressed
: _searchedSelected));
Layout::RowPainter::paint(
Ui::RowPainter::paint(
p,
result.get(),
fullWidth,
@ -692,7 +691,7 @@ void InnerWidget::paintCollapsedRow(
const auto text = row->folder->chatListName();
const auto unread = row->folder->chatListUnreadCount();
Layout::PaintCollapsedRow(
Ui::PaintCollapsedRow(
p,
row->row,
row->folder,
@ -735,7 +734,7 @@ void InnerWidget::paintPeerSearchResult(
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
// draw chat icon
if (auto chatTypeIcon = Layout::ChatTypeIcon(peer, active, selected)) {
if (auto chatTypeIcon = Ui::ChatTypeIcon(peer, active, selected)) {
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
}
@ -866,7 +865,7 @@ void InnerWidget::paintSearchInPeer(
const auto paintUserpic = [&](Painter &p, int x, int y, int size) {
peer->paintUserpicLeft(p, userpic, x, y, width(), size);
};
const auto icon = Layout::ChatTypeIcon(peer, false, false);
const auto icon = Ui::ChatTypeIcon(peer, false, false);
paintSearchInFilter(p, paintUserpic, top, icon, text);
}

View file

@ -22,10 +22,12 @@ namespace Ui {
class RippleAnimation;
} // namespace Ui
namespace Dialogs {
namespace Layout {
namespace Dialogs::Ui {
using namespace ::Ui;
class RowPainter;
} // namespace Layout
} // namespace Dialogs::Ui
namespace Dialogs {
enum class SortMode;
@ -91,25 +93,25 @@ public:
}
Row(Key key, int pos);
Key key() const {
[[nodiscard]] Key key() const {
return _id;
}
History *history() const {
[[nodiscard]] History *history() const {
return _id.history();
}
Data::Folder *folder() const {
[[nodiscard]] Data::Folder *folder() const {
return _id.folder();
}
not_null<Entry*> entry() const {
[[nodiscard]] not_null<Entry*> entry() const {
return _id.entry();
}
int pos() const {
[[nodiscard]] int pos() const {
return _pos;
}
uint64 sortKey(FilterId filterId) const;
[[nodiscard]] uint64 sortKey(FilterId filterId) const;
void validateListEntryCache() const;
const Ui::Text::String &listEntryCache() const {
[[nodiscard]] const Ui::Text::String &listEntryCache() const {
return _listEntryCache;
}
@ -130,10 +132,10 @@ class FakeRow : public BasicRow {
public:
FakeRow(Key searchInChat, not_null<HistoryItem*> item);
Key searchInChat() const {
[[nodiscard]] Key searchInChat() const {
return _searchInChat;
}
not_null<HistoryItem*> item() const {
[[nodiscard]] not_null<HistoryItem*> item() const {
return _item;
}
@ -143,7 +145,7 @@ public:
}
private:
friend class Layout::RowPainter;
friend class Ui::RowPainter;
Key _searchInChat;
not_null<HistoryItem*> _item;

View file

@ -31,8 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h"
#include "data/data_peer_values.h"
namespace Dialogs {
namespace Layout {
namespace Dialogs::Ui {
namespace {
// Show all dates that are in the last 20 hours in time format.
@ -260,14 +259,14 @@ void paintRow(
const auto history = chat.history();
if (flags & Flag::SavedMessages) {
Ui::EmptyUserpic::PaintSavedMessages(
EmptyUserpic::PaintSavedMessages(
p,
st::dialogsPadding.x(),
st::dialogsPadding.y(),
fullWidth,
st::dialogsPhotoSize);
} else if (flags & Flag::RepliesMessages) {
Ui::EmptyUserpic::PaintRepliesMessages(
EmptyUserpic::PaintRepliesMessages(
p,
st::dialogsPadding.x(),
st::dialogsPadding.y(),
@ -344,7 +343,7 @@ void paintRow(
history->cloudDraftTextCache.setText(
st::dialogsTextStyle,
history->topPromotionMessage(),
Ui::DialogTextOptions());
DialogTextOptions());
}
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1);
@ -371,7 +370,7 @@ void paintRow(
auto draftText = supportMode
? textcmdLink(1, Support::ChatOccupiedString(history))
: tr::lng_dialogs_text_with_from(tr::now, lt_from_part, draftWrapped, lt_message, TextUtilities::Clean(draft->textWithTags.text));
history->cloudDraftTextCache.setText(st::dialogsTextStyle, draftText, Ui::DialogTextOptions());
history->cloudDraftTextCache.setText(st::dialogsTextStyle, draftText, DialogTextOptions());
}
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
if (supportMode) {
@ -462,7 +461,7 @@ void paintRow(
p.drawTextLeft(rectForName.left(), rectForName.top(), fullWidth, text);
} else if (from) {
if (!(flags & Flag::SearchResult)) {
const auto badgeStyle = Ui::PeerBadgeStyle{
const auto badgeStyle = PeerBadgeStyle{
(active
? &st::dialogsVerifiedIconActive
: selected
@ -473,7 +472,7 @@ void paintRow(
: selected
? &st::dialogsScamFgOver
: &st::dialogsScamFg) };
const auto badgeWidth = Ui::DrawPeerBadgeGetWidth(
const auto badgeWidth = DrawPeerBadgeGetWidth(
from,
p,
rectForName,
@ -601,9 +600,9 @@ void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st)
if (badgeData->left[index].isNull()) {
int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor();
createCircleMask(badgeData, size);
badgeData->left[index] = Ui::PixmapFromImage(
badgeData->left[index] = PixmapFromImage(
colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = Ui::PixmapFromImage(colorizeCircleHalf(
badgeData->right[index] = PixmapFromImage(colorizeCircleHalf(
badgeData,
imgsize,
imgsizehalf,
@ -1015,5 +1014,4 @@ void PaintCollapsedRow(
}
}
} // namespace Layout
} // namespace Dialogs
} // namespace Dialogs::Ui

View file

@ -7,13 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Dialogs {
namespace Ui {
} // namespace Ui
namespace Dialogs {
class Row;
class FakeRow;
class BasicRow;
} // namespace Dialogs
namespace Layout {
namespace Dialogs::Ui {
using namespace ::Ui;
const style::icon *ChatTypeIcon(
not_null<PeerData*> peer,
@ -89,5 +94,4 @@ void paintUnreadCount(
void clearUnreadBadgesCache();
} // namespace Layout
} // namespace Dialogs
} // namespace Dialogs::Ui

View file

@ -97,8 +97,8 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
const auto unread = history->unreadMark()
? QString()
: QString::number(count);
Dialogs::Layout::UnreadBadgeStyle unreadSt;
unreadSt.sizeId = Dialogs::Layout::UnreadBadgeInTouchBar;
Dialogs::Ui::UnreadBadgeStyle unreadSt;
unreadSt.sizeId = Dialogs::Ui::UnreadBadgeInTouchBar;
unreadSt.muted = history->mute();
// Use constant values to draw badge regardless of cConfigScale().
unreadSt.size = kUnreadBadgeSize * cRetinaFactor();
@ -114,7 +114,7 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
result.fill(Qt::transparent);
Painter p(&result);
Dialogs::Layout::paintUnreadCount(
Dialogs::Ui::paintUnreadCount(
p,
unread,
result.width(),

View file

@ -97,12 +97,12 @@ void HistoryDownButton::paintEvent(QPaintEvent *e) {
if (_unreadCount > 0) {
auto unreadString = QString::number(_unreadCount);
Dialogs::Layout::UnreadBadgeStyle st;
Dialogs::Ui::UnreadBadgeStyle st;
st.align = style::al_center;
st.font = st::historyToDownBadgeFont;
st.size = st::historyToDownBadgeSize;
st.sizeId = Dialogs::Layout::UnreadBadgeInHistoryToDown;
Dialogs::Layout::paintUnreadCount(p, unreadString, width(), 0, st, nullptr, 4);
st.sizeId = Dialogs::Ui::UnreadBadgeInHistoryToDown;
Dialogs::Ui::paintUnreadCount(p, unreadString, width(), 0, st, nullptr, 4);
}
}

View file

@ -17,7 +17,7 @@ namespace Ui {
void UnreadBadge::setText(const QString &text, bool active) {
_text = text;
_active = active;
const auto st = Dialogs::Layout::UnreadBadgeStyle();
const auto st = Dialogs::Ui::UnreadBadgeStyle();
resize(
std::max(st.font->width(text) + 2 * st.padding, st.size),
st.size);
@ -25,7 +25,7 @@ void UnreadBadge::setText(const QString &text, bool active) {
}
int UnreadBadge::textBaseline() const {
const auto st = Dialogs::Layout::UnreadBadgeStyle();
const auto st = Dialogs::Ui::UnreadBadgeStyle();
return ((st.size - st.font->height) / 2) + st.font->ascent;
}
@ -36,11 +36,11 @@ void UnreadBadge::paintEvent(QPaintEvent *e) {
Painter p(this);
Dialogs::Layout::UnreadBadgeStyle unreadSt;
Dialogs::Ui::UnreadBadgeStyle unreadSt;
unreadSt.muted = !_active;
auto unreadRight = width();
auto unreadTop = 0;
Dialogs::Layout::paintUnreadCount(
Dialogs::Ui::paintUnreadCount(
p,
_text,
unreadRight,

View file

@ -788,7 +788,7 @@ void Notification::updateNotifyDisplay() {
Ui::Emoji::Draw(p, emoji, Ui::Emoji::GetSizeNormal(), rectForName.left(), top);
rectForName.setLeft(rectForName.left() + size + st::msgNameFont->spacew);
}
if (const auto chatTypeIcon = Dialogs::Layout::ChatTypeIcon(_history->peer, false, false)) {
if (const auto chatTypeIcon = Dialogs::Ui::ChatTypeIcon(_history->peer, false, false)) {
chatTypeIcon->paint(p, rectForName.topLeft(), w);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
}

View file

@ -156,7 +156,7 @@ private:
QImage _userpicCache;
base::unique_qptr<Ui::PopupMenu> _menu;
Dialogs::Layout::UnreadBadgeStyle _unreadSt;
Dialogs::Ui::UnreadBadgeStyle _unreadSt;
int _unreadBadge = 0;
bool _unreadBadgeMuted = true;
@ -294,7 +294,7 @@ void MainMenu::AccountButton::paintEvent(QPaintEvent *e) {
- st::mainMenu.itemToggleShift;
const auto unreadRight = width() - skip;
const auto unreadTop = (height() - _unreadSt.size) / 2;
Dialogs::Layout::paintUnreadCount(
Dialogs::Ui::paintUnreadCount(
p,
string,
unreadRight,
@ -435,7 +435,7 @@ void MainMenu::ToggleAccountsButton::paintUnreadBadge(QPainter &p) {
if (_unreadBadge.isEmpty()) {
return;
}
Dialogs::Layout::UnreadBadgeStyle st;
Dialogs::Ui::UnreadBadgeStyle st;
const auto right = width() - st::mainMenuTogglePosition.x() - st::mainMenuToggleSize * 2;
const auto top = height() - st::mainMenuTogglePosition.y() - st::mainMenuToggleSize;
@ -473,7 +473,7 @@ void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
}
_unreadBadge = computeUnreadBadge();
Dialogs::Layout::UnreadBadgeStyle st;
Dialogs::Ui::UnreadBadgeStyle st;
_unreadBadgeWidth = st.font->width(_unreadBadge);
const auto rectHeight = st.size;
const auto rectWidth = std::max(