Move some chat styles from basic.style to chat.style.

This commit is contained in:
John Preston 2022-09-30 11:25:02 +04:00
parent ba2f92906b
commit b13471672d
25 changed files with 196 additions and 37 deletions

View File

@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_boxes.h"
#include "styles/style_layers.h"
#include "styles/style_window.h"
#include "styles/style_chat.h"
namespace {

View File

@ -673,7 +673,7 @@ int PeerListRow::paintNameIconGetWidth(
nameLeft,
nameTop,
availableWidth,
st::msgNameStyle.font->height),
st::semiboldFont->height),
nameWidth,
outerWidth,
{

View File

@ -588,7 +588,7 @@ void Row::elementsPaint(
: st::sessionTerminate.icon;
icon.paint(p, position.x(), position.y(), outerWidth);
}
p.setFont(st::msgFont);
p.setFont(st::normalFont);
p.setPen(st::sessionInfoFg);
const auto locationLeft = st::sessionListItem.namePosition.x();
const auto available = outerWidth - locationLeft;

View File

@ -299,7 +299,7 @@ mentionTop: 11px;
mentionFont: linkFont;
mentionNameFg: windowFg;
mentionNameFgOver: windowFgOver;
mentionPhotoSize: msgPhotoSize;
mentionPhotoSize: 33px;
mentionBg: windowBg;
mentionBgOver: windowBgOver;
mentionFg: windowSubTextFg;

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h"
#include "data/data_photo_media.h"
#include "ui/image/image.h"
#include "styles/style_chat.h"
namespace Data {

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h"
#include "apiwrap.h"
#include "lang/lang_keys.h"
#include "styles/style_chat.h"
namespace {
@ -26,6 +27,9 @@ using UpdateFlag = Data::PeerUpdate::Flag;
} // namespace
BotInfo::BotInfo() : text(st::msgMinWidth) {
}
UserData::UserData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id)
, _flags((id == owner->session().userPeerId()) ? Flag::Self : Flag(0)) {

View File

@ -16,6 +16,8 @@ struct BotCommand;
} // namespace Data
struct BotInfo {
BotInfo();
bool inited = false;
bool readsAllHistory = false;
bool cantJoinGroups = false;
@ -23,7 +25,7 @@ struct BotInfo {
int version = 0;
QString description, inlinePlaceholder;
std::vector<Data::BotCommand> commands;
Ui::Text::String text = { int(st::msgMinWidth) }; // description
Ui::Text::String text;
QString botMenuButtonText;
QString botMenuButtonUrl;

View File

@ -178,7 +178,7 @@ const Ui::Text::String &Entry::chatListNameText() const {
if (_chatListNameVersion < version) {
_chatListNameVersion = version;
_chatListNameText.setText(
st::msgNameStyle,
st::semiboldTextStyle,
chatListName(),
Ui::NameTextOptions());
}

View File

@ -842,11 +842,11 @@ void InnerWidget::paintPeerSearchResult(
auto nameleft = context.st->nameLeft;
auto namewidth = context.width - nameleft - context.st->padding.right();
QRect rectForName(nameleft, context.st->nameTop, namewidth, st::msgNameFont->height);
QRect rectForName(nameleft, context.st->nameTop, namewidth, st::semiboldFont->height);
if (result->name.isEmpty()) {
result->name.setText(
st::msgNameStyle,
st::semiboldTextStyle,
peer->name(),
Ui::NameTextOptions());
}
@ -977,9 +977,9 @@ void InnerWidget::paintSearchInFilter(
- st::dialogsCancelSearch.width;
auto rectForName = QRect(
nameleft,
top + (st::dialogsSearchInHeight - st::msgNameFont->height) / 2,
top + (st::dialogsSearchInHeight - st::semiboldFont->height) / 2,
namewidth,
st::msgNameFont->height);
st::semiboldFont->height);
if (icon) {
icon->paint(p, rectForName.topLeft(), width());
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
@ -2540,7 +2540,7 @@ void InnerWidget::refreshSearchInChatLabel() {
}();
if (!dialog.isEmpty()) {
_searchInChatText.setText(
st::msgNameStyle,
st::semiboldTextStyle,
dialog,
Ui::DialogTextOptions());
}

View File

@ -352,7 +352,10 @@ const Ui::Text::String &FakeRow::name() const {
? _item->displayFrom()
: nullptr;
const auto peer = from ? from : _item->history()->peer.get();
_name.setText(st::msgNameStyle, peer->name(), Ui::NameTextOptions());
_name.setText(
st::semiboldTextStyle,
peer->name(),
Ui::NameTextOptions());
}
return _name;
}

View File

@ -70,7 +70,7 @@ void PaintRowTopRight(
: st::dialogsDateFg);
p.drawText(
rectForName.left() + rectForName.width() + st::dialogsDateSkip,
rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent,
rectForName.top() + st::semiboldFont->height - st::normalFont->descent,
text);
}
@ -392,7 +392,7 @@ void PaintRow(
nameleft,
context.st->nameTop,
namewidth,
st::msgNameFont->height);
st::semiboldFont->height);
const auto promoted = (history && history->useTopPromotion())
&& !context.search;
@ -612,14 +612,14 @@ void PaintRow(
sendStateIcon->paint(p, rectForName.topLeft() + QPoint(rectForName.width(), 0), context.width);
}
p.setFont(st::msgNameFont);
p.setFont(st::semiboldFont);
if (flags & (Flag::SavedMessages | Flag::RepliesMessages)) {
auto text = (flags & Flag::SavedMessages)
? tr::lng_saved_messages(tr::now)
: tr::lng_replies_messages(tr::now);
const auto textWidth = st::msgNameFont->width(text);
const auto textWidth = st::semiboldFont->width(text);
if (textWidth > rectForName.width()) {
text = st::msgNameFont->elided(text, rectForName.width());
text = st::semiboldFont->elided(text, rectForName.width());
}
p.setPen(context.active
? st::dialogsNameFgActive
@ -687,9 +687,9 @@ void PaintRow(
? st::dialogsArchiveFgOver
: st::dialogsArchiveFg);
auto text = entry->chatListName(); // TODO feed name with emoji
auto textWidth = st::msgNameFont->width(text);
auto textWidth = st::semiboldFont->width(text);
if (textWidth > rectForName.width()) {
text = st::msgNameFont->elided(text, rectForName.width());
text = st::semiboldFont->elided(text, rectForName.width());
}
p.drawTextLeft(rectForName.left(), rectForName.top(), context.width, text);
}

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_chat.h"
namespace Data {
class CloudImageView;

View File

@ -516,7 +516,7 @@ private:
mutable ClickHandlerPtr _fromLink;
const QDateTime _dateTime;
mutable Ui::Text::String _text = { st::msgMinWidth };
mutable Ui::Text::String _text;
mutable int _textWidth = -1;
mutable int _textHeight = 0;

View File

@ -648,7 +648,10 @@ TextSelection Service::adjustSelection(
return text().adjustSelection(selection, type);
}
EmptyPainter::EmptyPainter(not_null<History*> history) : _history(history) {
EmptyPainter::EmptyPainter(not_null<History*> history)
: _history(history)
, _header(st::msgMinWidth)
, _text(st::msgMinWidth) {
if (NeedAboutGroup(_history)) {
fillAboutGroup();
}

View File

@ -127,8 +127,8 @@ private:
void fillAboutGroup();
not_null<History*> _history;
Ui::Text::String _header = { st::msgMinWidth };
Ui::Text::String _text = { st::msgMinWidth };
Ui::Text::String _header;
Ui::Text::String _text;
std::vector<Ui::Text::String> _phrases;
};

View File

@ -55,6 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_info.h"
#include "styles/style_layers.h"
#include "styles/style_menu_icons.h"
#include "styles/style_chat.h"
#include <QtWidgets/QApplication>
#include <QtGui/QClipboard>

View File

@ -1482,7 +1482,8 @@ Link::Link(
not_null<Delegate*> delegate,
not_null<HistoryItem*> parent,
Data::Media *media)
: ItemBase(delegate, parent) {
: ItemBase(delegate, parent)
, _text(st::msgMinWidth) {
AddComponents(Info::Bit());
auto textWithEntities = parent->originalText();

View File

@ -433,7 +433,7 @@ private:
std::shared_ptr<Data::DocumentMedia> _documentMedia;
int _pixw = 0;
int _pixh = 0;
Ui::Text::String _text = { st::msgMinWidth };
Ui::Text::String _text;
QPixmap _thumbnail;
bool _thumbnailBlurred = true;

View File

@ -99,7 +99,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
if (item->name.isEmpty()) {
item->name.setText(
st::msgNameStyle,
st::semiboldTextStyle,
item->peer->name(),
Ui::NameTextOptions());
}

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/cached_round_corners.h"
#include "lang/lang_keys.h"
#include "styles/style_boxes.h"
#include "styles/style_chat.h"
namespace Ui {
namespace {

View File

@ -26,6 +26,147 @@ GroupCallUserpics {
align: align;
}
msgMaxWidth: 430px;
msgFont: font(fsize);
msgNameFont: semiboldFont;
msgNameStyle: semiboldTextStyle;
msgServiceFont: semiboldFont;
msgServiceNameFont: semiboldFont;
msgServicePhotoWidth: 100px;
msgDateFont: font(13px);
msgMinWidth: 160px;
msgPhotoSize: 33px;
msgPhotoSkip: 40px;
msgPadding: margins(13px, 7px, 13px, 8px);
msgMargin: margins(16px, 6px, 56px, 2px);
msgMarginTopAttached: 0px;
msgLnkPadding: 2px; // for media open / save links
msgShadow: 2px;
msgReplyPadding: margins(6px, 6px, 11px, 6px);
msgReplyBarPos: point(1px, 0px);
msgReplyBarSize: size(2px, 36px);
msgReplyBarSkip: 10px;
msgServicePadding: margins(12px, 3px, 12px, 4px);
msgServiceMargin: margins(10px, 10px, 10px, 2px);
msgDateSpace: 12px;
msgDateDelta: point(2px, 5px);
msgDateImgDelta: 4px;
msgDateImgPadding: point(8px, 2px);
msgDateImgCheckSpace: 4px;
messageTextStyle: defaultTextStyle;
msgDateTextStyle: defaultTextStyle;
serviceTextPalette: TextPalette(defaultTextPalette) {
linkFg: msgServiceFg;
monoFg: msgServiceFg;
spoilerFg: msgServiceFg;
selectBg: msgServiceBgSelected;
selectFg: msgServiceFg;
selectLinkFg: msgServiceFg;
selectMonoFg: msgServiceFg;
selectSpoilerFg: msgServiceFg;
selectOverlay: msgServiceBgSelected;
}
serviceTextStyle: TextStyle(defaultTextStyle) {
font: msgServiceFont;
linkFont: msgServiceFont;
linkFontOver: font(fsize semibold underline);
}
inTextPalette: TextPalette(defaultTextPalette) {
linkFg: historyLinkInFg;
monoFg: msgInMonoFg;
spoilerFg: msgInDateFg;
selectBg: msgInBgSelected;
selectFg: historyTextInFgSelected;
selectLinkFg: historyLinkInFgSelected;
selectMonoFg: msgInMonoFgSelected;
selectSpoilerFg: msgInDateFgSelected;
selectOverlay: msgSelectOverlay;
}
inTextPaletteSelected: TextPalette(inTextPalette) {
linkFg: historyLinkInFgSelected;
monoFg: msgInMonoFgSelected;
spoilerFg: msgInDateFgSelected;
}
outTextPalette: TextPalette(defaultTextPalette) {
linkFg: historyLinkOutFg;
monoFg: msgOutMonoFg;
spoilerFg: msgOutDateFg;
selectBg: msgOutBgSelected;
selectFg: historyTextOutFgSelected;
selectLinkFg: historyLinkOutFgSelected;
selectMonoFg: msgOutMonoFgSelected;
selectSpoilerFg: msgOutDateFgSelected;
selectOverlay: msgSelectOverlay;
}
outTextPaletteSelected: TextPalette(outTextPalette) {
linkFg: historyLinkOutFgSelected;
monoFg: msgOutMonoFgSelected;
spoilerFg: msgOutDateFgSelected;
}
fwdTextStyle: TextStyle(semiboldTextStyle) {
linkFontOver: semiboldFont;
}
inFwdTextPalette: TextPalette(defaultTextPalette) {
linkFg: msgInServiceFg;
}
outFwdTextPalette: TextPalette(defaultTextPalette) {
linkFg: msgOutServiceFg;
}
inFwdTextPaletteSelected: TextPalette(defaultTextPalette) {
linkFg: msgInServiceFgSelected;
}
outFwdTextPaletteSelected: TextPalette(defaultTextPalette) {
linkFg: msgOutServiceFgSelected;
}
inReplyTextPalette: TextPalette(inTextPalette) {
linkFg: msgInDateFg;
}
inReplyTextPaletteSelected: TextPalette(inTextPaletteSelected) {
linkFg: msgInDateFgSelected;
}
outReplyTextPalette: TextPalette(outTextPalette) {
linkFg: msgOutDateFg;
}
outReplyTextPaletteSelected: TextPalette(outTextPaletteSelected) {
linkFg: msgOutDateFgSelected;
}
imgReplyTextPalette: TextPalette(defaultTextPalette) {
linkFg: msgImgReplyBarColor;
}
inSemiboldPalette: TextPalette(inTextPalette) {
linkFg: msgInServiceFg;
selectFg: msgInServiceFgSelected;
selectLinkFg: msgInServiceFgSelected;
}
outSemiboldPalette: TextPalette(outTextPalette) {
linkFg: msgOutServiceFg;
selectFg: msgOutServiceFgSelected;
selectLinkFg: msgOutServiceFgSelected;
}
historyComposeAreaPalette: TextPalette(defaultTextPalette) {
linkFg: historyComposeAreaFgService;
}
mediaCaptionSkip: 5px;
mediaInBubbleSkip: 5px;
mediaThumbSize: 48px;
mediaNameTop: 3px;
mediaDetailsShift: 3px;
mediaUnreadSize: 7px;
mediaUnreadSkip: 5px;
mediaUnreadTop: 6px;
mediaInPalette: TextPalette(defaultTextPalette) {
linkFg: mediaInFg;
}
mediaInPaletteSelected: TextPalette(defaultTextPalette) {
linkFg: mediaInFgSelected;
}
defaultMessageBar: MessageBar {
title: semiboldTextStyle;
titleFg: windowActiveTextFg;

View File

@ -678,7 +678,7 @@ void Notification::refreshLang() {
void Notification::prepareActionsCache() {
auto replyCache = Ui::GrabWidget(_reply);
auto fadeWidth = st::notifyFadeRight.width();
auto actionsTop = st::notifyTextTop + st::msgNameFont->height;
auto actionsTop = st::notifyTextTop + st::semiboldFont->height;
auto replyRight = _replyPadding - st::notifyBorderWidth;
auto actionsCacheWidth = _reply->width() + replyRight + fadeWidth;
auto actionsCacheHeight = height() - actionsTop - st::notifyBorderWidth;
@ -739,7 +739,7 @@ void Notification::paintEvent(QPaintEvent *e) {
p.setClipRect(e->rect());
p.drawImage(0, 0, _cache);
auto buttonsTop = st::notifyTextTop + st::msgNameFont->height;
auto buttonsTop = st::notifyTextTop + st::semiboldFont->height;
if (a_actionsOpacity.animating()) {
p.setOpacity(a_actionsOpacity.value(1.));
p.drawPixmapRight(st::notifyBorderWidth, buttonsTop, width(), _buttonsCache);
@ -835,15 +835,15 @@ void Notification::updateNotifyDisplay() {
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height);
QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::semiboldFont->height);
const auto reminder = _fromScheduled && _history->peer->isSelf();
if (!options.hideNameAndPhoto) {
if (_fromScheduled) {
static const auto emoji = Ui::Emoji::Find(QString::fromUtf8("\xF0\x9F\x93\x85"));
const auto size = Ui::Emoji::GetSizeNormal() / cIntRetinaFactor();
const auto top = rectForName.top() + (st::msgNameFont->height - size) / 2;
const auto top = rectForName.top() + (st::semiboldFont->height - size) / 2;
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::semiboldFont->spacew);
}
if (const auto chatTypeIcon = Dialogs::Ui::ChatTypeIcon(_history->peer)) {
chatTypeIcon->paint(p, rectForName.topLeft(), w);
@ -858,7 +858,7 @@ void Notification::updateNotifyDisplay() {
_textCache = Ui::Text::String(itemWidth);
auto r = QRect(
st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft,
st::notifyItemTop + st::msgNameFont->height,
st::notifyItemTop + st::semiboldFont->height,
itemWidth,
2 * st::dialogsTextFont->height);
const auto text = !_reaction.empty()
@ -910,7 +910,7 @@ void Notification::updateNotifyDisplay() {
p.setPen(st::dialogsTextFgService);
p.drawText(
st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft,
st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent,
st::notifyItemTop + st::semiboldFont->height + st::dialogsTextFont->ascent,
st::dialogsTextFont->elided(
tr::lng_notification_preview(tr::now),
itemWidth));
@ -926,7 +926,7 @@ void Notification::updateNotifyDisplay() {
const auto fullTitle = manager()->addTargetAccountName(
title,
&_history->session());
titleText.setText(st::msgNameStyle, fullTitle, Ui::NameTextOptions());
titleText.setText(st::semiboldTextStyle, fullTitle, Ui::NameTextOptions());
titleText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
}

View File

@ -488,7 +488,7 @@ void MainMenu::moveBadge() {
_badge->move(
left,
st::mainMenuCoverNameTop,
st::mainMenuCoverNameTop + st::msgNameStyle.font->height);
st::mainMenuCoverNameTop + st::semiboldFont->height);
}
void MainMenu::setupArchive() {
@ -830,7 +830,7 @@ void MainMenu::paintEvent(QPaintEvent *e) {
if (_nameVersion < user->nameVersion()) {
_nameVersion = user->nameVersion();
_name.setText(
st::msgNameStyle,
st::semiboldTextStyle,
user->name(),
Ui::NameTextOptions());
moveBadge();

@ -1 +1 @@
Subproject commit 8815d7aec9b901191d08445f29e2edd0aeba7b2c
Subproject commit 6e923872a4b66767da93f7e388f9fcedf266e1aa

@ -1 +1 @@
Subproject commit d5ec7cc296a074e8e2247ffc825c6d5c8647ed48
Subproject commit 80445f2bd3ebb377b990d2a471021e906e611240