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

View file

@ -663,14 +663,22 @@ void PaintRow(
: context.selected : context.selected
? st::dialogsNameFgOver ? st::dialogsNameFgOver
: st::dialogsNameFg); : 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) { } else if (hiddenSenderInfo) {
p.setPen(context.active p.setPen(context.active
? st::dialogsNameFgActive ? st::dialogsNameFgActive
: context.selected : context.selected
? st::dialogsNameFgOver ? st::dialogsNameFgOver
: st::dialogsNameFg); : 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 { } else {
p.setPen(context.active p.setPen(context.active
? st::dialogsNameFgActive ? st::dialogsNameFgActive
@ -681,7 +689,11 @@ void PaintRow(
: (context.selected : (context.selected
? st::dialogsNameFgOver ? st::dialogsNameFgOver
: st::dialogsNameFg)); : 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) { if (_media) {
return _media->toPreview(options); return _media->toPreview(options);
} else if (!emptyText()) { } else if (!emptyText()) {
return { .text = options.translated ? translatedText() : _text }; return {
.text = st::wrap_rtl(options.translated
? translatedText()
: _text)
};
} }
return {}; return {};
}(); }();
@ -5509,7 +5513,7 @@ PreparedServiceText HistoryItem::preparePinnedText() {
lt_from, lt_from,
fromLinkText(), // Link 1. fromLinkText(), // Link 1.
lt_text, lt_text,
std::move(original), // Link 2. st::wrap_rtl(original), // Link 2.
Ui::Text::WithEntities); Ui::Text::WithEntities);
} else { } else {
result.text = tr::lng_action_pinned_media( result.text = tr::lng_action_pinned_media(
@ -5756,7 +5760,7 @@ PreparedServiceText HistoryItem::prepareCallScheduledText(
} }
TextWithEntities HistoryItem::fromLinkText() const { 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 { ClickHandlerPtr HistoryItem::fromLink() const {

View file

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

View file

@ -1687,7 +1687,11 @@ void Message::paintFromName(
} }
p.setFont(st::msgNameFont); p.setFont(st::msgNameFont);
p.setPen(nameFg); 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() const auto skipWidth = nameText->maxWidth()
+ (_fromNameStatus + (_fromNameStatus
? (st::dialogsPremiumIcon.icon.width() ? (st::dialogsPremiumIcon.icon.width()

View file

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

View file

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

View file

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

View file

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

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