Don't force LTR direction on texts.

This commit is contained in:
John Preston 2024-08-22 10:41:47 +02:00
parent 24b0b33f1d
commit c131d6637d
10 changed files with 47 additions and 28 deletions

View File

@ -100,9 +100,9 @@ struct AlbumCounts {
if (caption.text.isEmpty()) {
return Ui::Text::Colorized(attachType);
}
auto wrapped = st::wrap_rtl(caption);
return hasMiniImages
? caption
? wrapped
: tr::lng_dialogs_text_media(
tr::now,
lt_media_part,
@ -112,7 +112,7 @@ struct AlbumCounts {
Ui::Text::Colorized(attachType),
Ui::Text::WithEntities),
lt_caption,
caption,
wrapped,
Ui::Text::WithEntities);
}

View File

@ -663,14 +663,22 @@ void PaintRow(
: context.selected
? st::dialogsNameFgOver
: st::dialogsNameFg);
rowName.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
rowName.draw(p, {
.position = rectForName.topLeft(),
.availableWidth = rectForName.width(),
.elisionLines = 1,
});
} else if (hiddenSenderInfo) {
p.setPen(context.active
? st::dialogsNameFgActive
: context.selected
? st::dialogsNameFgOver
: st::dialogsNameFg);
hiddenSenderInfo->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
hiddenSenderInfo->nameText().draw(p, {
.position = rectForName.topLeft(),
.availableWidth = rectForName.width(),
.elisionLines = 1,
});
} else {
p.setPen(context.active
? st::dialogsNameFgActive
@ -681,7 +689,11 @@ void PaintRow(
: (context.selected
? st::dialogsNameFgOver
: st::dialogsNameFg));
rowName.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
rowName.draw(p, {
.position = rectForName.topLeft(),
.availableWidth = rectForName.width(),
.elisionLines = 1,
});
}
}

View File

@ -3453,7 +3453,11 @@ ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {
if (_media) {
return _media->toPreview(options);
} else if (!emptyText()) {
return { .text = options.translated ? translatedText() : _text };
return {
.text = st::wrap_rtl(options.translated
? translatedText()
: _text)
};
}
return {};
}();
@ -5509,7 +5513,7 @@ PreparedServiceText HistoryItem::preparePinnedText() {
lt_from,
fromLinkText(), // Link 1.
lt_text,
std::move(original), // Link 2.
st::wrap_rtl(original), // Link 2.
Ui::Text::WithEntities);
} else {
result.text = tr::lng_action_pinned_media(
@ -5756,7 +5760,7 @@ PreparedServiceText HistoryItem::prepareCallScheduledText(
}
TextWithEntities HistoryItem::fromLinkText() const {
return Ui::Text::Link(_from->name(), 1);
return Ui::Text::Link(st::wrap_rtl(_from->name()), 1);
}
ClickHandlerPtr HistoryItem::fromLink() const {

View File

@ -442,8 +442,8 @@ void ServicePreMessage::paint(
.align = style::al_top,
.palette = &context.st->serviceTextPalette(),
.now = context.now,
//.selection = context.selection,
.fullWidthSelection = false,
//.selection = context.selection,
});
p.translate(0, -top);

View File

@ -1687,7 +1687,11 @@ void Message::paintFromName(
}
p.setFont(st::msgNameFont);
p.setPen(nameFg);
nameText->drawElided(p, availableLeft, trect.top(), availableWidth);
nameText->draw(p, {
.position = { availableLeft, trect.top() },
.availableWidth = availableWidth,
.elisionLines = 1,
});
const auto skipWidth = nameText->maxWidth()
+ (_fromNameStatus
? (st::dialogsPremiumIcon.icon.width()

View File

@ -570,8 +570,8 @@ void Service::draw(Painter &p, const PaintContext &context) const {
.now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.selection = context.selection,
.fullWidthSelection = false,
.selection = context.selection,
});
}
if (mediaDisplayed) {

View File

@ -600,11 +600,11 @@ void TopBarWidget::paintTopBar(Painter &p) {
const auto namewidth = availableWidth - badgeWidth;
p.setPen(st::dialogsNameFg);
_title.drawElided(
p,
nameleft,
nametop,
namewidth);
_title.draw(p, {
.position = { nameleft, nametop },
.availableWidth = namewidth,
.elisionLines = 1,
});
p.setFont(st::dialogsTextFont);
if (!paintConnectingState(p, nameleft, statustop, width())

View File

@ -438,12 +438,15 @@ void MessageBar::paint(Painter &p) {
if (_title.isEmpty()) {
// "Loading..." state.
p.setPen(st::historyComposeAreaFgService);
_text.drawLeftElided(
p,
body.x(),
body.y() + (body.height() - st::normalFont->height) / 2,
body.width(),
width);
_text.draw(p, {
.position = {
body.x(),
body.y() + (body.height() - st::normalFont->height) / 2,
},
.outerWidth = width,
.availableWidth = body.width(),
.elisionLines = 1,
});
} else {
p.setPen(_st.textFg);
_text.draw(p, {

View File

@ -103,10 +103,6 @@ TextParseOptions WebpageDescriptionOptions = {
} // namespace
void InitTextOptions() {
HistoryServiceOptions.dir
= TextNameOptions.dir
= TextDialogOptions.dir
= Qt::LeftToRight;
TextDialogOptions.maxw = st::columnMaximalWidthLeft * 2;
WebpageTitleOptions.maxh = st::webPageTitleFont->height * 2;
WebpageTitleOptions.maxw

@ -1 +1 @@
Subproject commit 91fa96fb946a672bfa47361f96af5a675fc9693d
Subproject commit 9028e288afcb9aaa31bfad98a283f30dd30cdca3