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); void setCounter(int counter);
QString _text; QString _text;
Dialogs::Layout::UnreadBadgeStyle _st; Dialogs::Ui::UnreadBadgeStyle _st;
}; };
@ -303,7 +303,7 @@ StickersBox::CounterWidget::CounterWidget(
: RpWidget(parent) { : RpWidget(parent) {
setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_TransparentForMouseEvents);
_st.sizeId = Dialogs::Layout::UnreadBadgeInStickersBox; _st.sizeId = Dialogs::Ui::UnreadBadgeInStickersBox;
_st.textTop = st::stickersFeaturedBadgeTextTop; _st.textTop = st::stickersFeaturedBadgeTextTop;
_st.size = st::stickersFeaturedBadgeSize; _st.size = st::stickersFeaturedBadgeSize;
_st.padding = st::stickersFeaturedBadgePadding; _st.padding = st::stickersFeaturedBadgePadding;
@ -323,7 +323,7 @@ void StickersBox::CounterWidget::setCounter(int counter) {
Painter p(&dummy); Painter p(&dummy);
auto newWidth = 0; 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); resize(newWidth, st::stickersFeaturedBadgeSize);
} }
@ -334,7 +334,7 @@ void StickersBox::CounterWidget::paintEvent(QPaintEvent *e) {
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
auto unreadRight = rtl() ? 0 : width(); auto unreadRight = rtl() ? 0 : width();
auto unreadTop = 0; 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( session().data().sendActionManager().animationUpdated(
) | rpl::start_with_next([=]( ) | rpl::start_with_next([=](
const Data::SendActionManager::AnimationUpdate &update) { const Data::SendActionManager::AnimationUpdate &update) {
using RowPainter = Layout::RowPainter; const auto updateRect = Ui::RowPainter::sendActionAnimationRect(
const auto updateRect = RowPainter::sendActionAnimationRect(
update.left, update.left,
update.width, update.width,
update.height, update.height,
@ -440,7 +439,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
} }
const auto isActive = (row->key() == active); const auto isActive = (row->key() == active);
const auto isSelected = (row->key() == selected); const auto isSelected = (row->key() == selected);
Layout::RowPainter::paint( Ui::RowPainter::paint(
p, p,
row, row,
_filterId, _filterId,
@ -558,7 +557,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
: (from == (isPressed() : (from == (isPressed()
? _filteredPressed ? _filteredPressed
: _filteredSelected)); : _filteredSelected));
Layout::RowPainter::paint( Ui::RowPainter::paint(
p, p,
_filterResults[from], _filterResults[from],
_filterId, _filterId,
@ -650,7 +649,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
: (from == (isPressed() : (from == (isPressed()
? _searchedPressed ? _searchedPressed
: _searchedSelected)); : _searchedSelected));
Layout::RowPainter::paint( Ui::RowPainter::paint(
p, p,
result.get(), result.get(),
fullWidth, fullWidth,
@ -692,7 +691,7 @@ void InnerWidget::paintCollapsedRow(
const auto text = row->folder->chatListName(); const auto text = row->folder->chatListName();
const auto unread = row->folder->chatListUnreadCount(); const auto unread = row->folder->chatListUnreadCount();
Layout::PaintCollapsedRow( Ui::PaintCollapsedRow(
p, p,
row->row, row->row,
row->folder, row->folder,
@ -735,7 +734,7 @@ void InnerWidget::paintPeerSearchResult(
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height); QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
// draw chat icon // 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); chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} }
@ -866,7 +865,7 @@ void InnerWidget::paintSearchInPeer(
const auto paintUserpic = [&](Painter &p, int x, int y, int size) { const auto paintUserpic = [&](Painter &p, int x, int y, int size) {
peer->paintUserpicLeft(p, userpic, x, y, width(), 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); paintSearchInFilter(p, paintUserpic, top, icon, text);
} }

View file

@ -22,10 +22,12 @@ namespace Ui {
class RippleAnimation; class RippleAnimation;
} // namespace Ui } // namespace Ui
namespace Dialogs { namespace Dialogs::Ui {
namespace Layout { using namespace ::Ui;
class RowPainter; class RowPainter;
} // namespace Layout } // namespace Dialogs::Ui
namespace Dialogs {
enum class SortMode; enum class SortMode;
@ -91,25 +93,25 @@ public:
} }
Row(Key key, int pos); Row(Key key, int pos);
Key key() const { [[nodiscard]] Key key() const {
return _id; return _id;
} }
History *history() const { [[nodiscard]] History *history() const {
return _id.history(); return _id.history();
} }
Data::Folder *folder() const { [[nodiscard]] Data::Folder *folder() const {
return _id.folder(); return _id.folder();
} }
not_null<Entry*> entry() const { [[nodiscard]] not_null<Entry*> entry() const {
return _id.entry(); return _id.entry();
} }
int pos() const { [[nodiscard]] int pos() const {
return _pos; return _pos;
} }
uint64 sortKey(FilterId filterId) const; [[nodiscard]] uint64 sortKey(FilterId filterId) const;
void validateListEntryCache() const; void validateListEntryCache() const;
const Ui::Text::String &listEntryCache() const { [[nodiscard]] const Ui::Text::String &listEntryCache() const {
return _listEntryCache; return _listEntryCache;
} }
@ -130,10 +132,10 @@ class FakeRow : public BasicRow {
public: public:
FakeRow(Key searchInChat, not_null<HistoryItem*> item); FakeRow(Key searchInChat, not_null<HistoryItem*> item);
Key searchInChat() const { [[nodiscard]] Key searchInChat() const {
return _searchInChat; return _searchInChat;
} }
not_null<HistoryItem*> item() const { [[nodiscard]] not_null<HistoryItem*> item() const {
return _item; return _item;
} }
@ -143,7 +145,7 @@ public:
} }
private: private:
friend class Layout::RowPainter; friend class Ui::RowPainter;
Key _searchInChat; Key _searchInChat;
not_null<HistoryItem*> _item; 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_folder.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
namespace Dialogs { namespace Dialogs::Ui {
namespace Layout {
namespace { namespace {
// Show all dates that are in the last 20 hours in time format. // Show all dates that are in the last 20 hours in time format.
@ -260,14 +259,14 @@ void paintRow(
const auto history = chat.history(); const auto history = chat.history();
if (flags & Flag::SavedMessages) { if (flags & Flag::SavedMessages) {
Ui::EmptyUserpic::PaintSavedMessages( EmptyUserpic::PaintSavedMessages(
p, p,
st::dialogsPadding.x(), st::dialogsPadding.x(),
st::dialogsPadding.y(), st::dialogsPadding.y(),
fullWidth, fullWidth,
st::dialogsPhotoSize); st::dialogsPhotoSize);
} else if (flags & Flag::RepliesMessages) { } else if (flags & Flag::RepliesMessages) {
Ui::EmptyUserpic::PaintRepliesMessages( EmptyUserpic::PaintRepliesMessages(
p, p,
st::dialogsPadding.x(), st::dialogsPadding.x(),
st::dialogsPadding.y(), st::dialogsPadding.y(),
@ -344,7 +343,7 @@ void paintRow(
history->cloudDraftTextCache.setText( history->cloudDraftTextCache.setText(
st::dialogsTextStyle, st::dialogsTextStyle,
history->topPromotionMessage(), history->topPromotionMessage(),
Ui::DialogTextOptions()); DialogTextOptions());
} }
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg)); p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1); history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1);
@ -371,7 +370,7 @@ void paintRow(
auto draftText = supportMode auto draftText = supportMode
? textcmdLink(1, Support::ChatOccupiedString(history)) ? textcmdLink(1, Support::ChatOccupiedString(history))
: tr::lng_dialogs_text_with_from(tr::now, lt_from_part, draftWrapped, lt_message, TextUtilities::Clean(draft->textWithTags.text)); : 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)); p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
if (supportMode) { if (supportMode) {
@ -462,7 +461,7 @@ void paintRow(
p.drawTextLeft(rectForName.left(), rectForName.top(), fullWidth, text); p.drawTextLeft(rectForName.left(), rectForName.top(), fullWidth, text);
} else if (from) { } else if (from) {
if (!(flags & Flag::SearchResult)) { if (!(flags & Flag::SearchResult)) {
const auto badgeStyle = Ui::PeerBadgeStyle{ const auto badgeStyle = PeerBadgeStyle{
(active (active
? &st::dialogsVerifiedIconActive ? &st::dialogsVerifiedIconActive
: selected : selected
@ -473,7 +472,7 @@ void paintRow(
: selected : selected
? &st::dialogsScamFgOver ? &st::dialogsScamFgOver
: &st::dialogsScamFg) }; : &st::dialogsScamFg) };
const auto badgeWidth = Ui::DrawPeerBadgeGetWidth( const auto badgeWidth = DrawPeerBadgeGetWidth(
from, from,
p, p,
rectForName, rectForName,
@ -601,9 +600,9 @@ void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st)
if (badgeData->left[index].isNull()) { if (badgeData->left[index].isNull()) {
int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor(); int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor();
createCircleMask(badgeData, size); createCircleMask(badgeData, size);
badgeData->left[index] = Ui::PixmapFromImage( badgeData->left[index] = PixmapFromImage(
colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg)); colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = Ui::PixmapFromImage(colorizeCircleHalf( badgeData->right[index] = PixmapFromImage(colorizeCircleHalf(
badgeData, badgeData,
imgsize, imgsize,
imgsizehalf, imgsizehalf,
@ -1015,5 +1014,4 @@ void PaintCollapsedRow(
} }
} }
} // namespace Layout } // namespace Dialogs::Ui
} // namespace Dialogs

View file

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

View file

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

View file

@ -97,12 +97,12 @@ void HistoryDownButton::paintEvent(QPaintEvent *e) {
if (_unreadCount > 0) { if (_unreadCount > 0) {
auto unreadString = QString::number(_unreadCount); auto unreadString = QString::number(_unreadCount);
Dialogs::Layout::UnreadBadgeStyle st; Dialogs::Ui::UnreadBadgeStyle st;
st.align = style::al_center; st.align = style::al_center;
st.font = st::historyToDownBadgeFont; st.font = st::historyToDownBadgeFont;
st.size = st::historyToDownBadgeSize; st.size = st::historyToDownBadgeSize;
st.sizeId = Dialogs::Layout::UnreadBadgeInHistoryToDown; st.sizeId = Dialogs::Ui::UnreadBadgeInHistoryToDown;
Dialogs::Layout::paintUnreadCount(p, unreadString, width(), 0, st, nullptr, 4); 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) { void UnreadBadge::setText(const QString &text, bool active) {
_text = text; _text = text;
_active = active; _active = active;
const auto st = Dialogs::Layout::UnreadBadgeStyle(); const auto st = Dialogs::Ui::UnreadBadgeStyle();
resize( resize(
std::max(st.font->width(text) + 2 * st.padding, st.size), std::max(st.font->width(text) + 2 * st.padding, st.size),
st.size); st.size);
@ -25,7 +25,7 @@ void UnreadBadge::setText(const QString &text, bool active) {
} }
int UnreadBadge::textBaseline() const { 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; return ((st.size - st.font->height) / 2) + st.font->ascent;
} }
@ -36,11 +36,11 @@ void UnreadBadge::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
Dialogs::Layout::UnreadBadgeStyle unreadSt; Dialogs::Ui::UnreadBadgeStyle unreadSt;
unreadSt.muted = !_active; unreadSt.muted = !_active;
auto unreadRight = width(); auto unreadRight = width();
auto unreadTop = 0; auto unreadTop = 0;
Dialogs::Layout::paintUnreadCount( Dialogs::Ui::paintUnreadCount(
p, p,
_text, _text,
unreadRight, unreadRight,

View file

@ -788,7 +788,7 @@ void Notification::updateNotifyDisplay() {
Ui::Emoji::Draw(p, emoji, Ui::Emoji::GetSizeNormal(), rectForName.left(), top); Ui::Emoji::Draw(p, emoji, Ui::Emoji::GetSizeNormal(), rectForName.left(), top);
rectForName.setLeft(rectForName.left() + size + st::msgNameFont->spacew); 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); chatTypeIcon->paint(p, rectForName.topLeft(), w);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} }

View file

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