diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index 716c45eec0caf0..828f79827d22de 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -197,8 +197,11 @@ void BasicRow::PaintCornerBadgeFrame( q.setBrush(data->active ? st::dialogsOnlineBadgeFgActive : st::dialogsOnlineBadgeFg); + //paints corner online or calling badge next to userpic in dialogs q.drawEllipse(QRectF( - st::dialogsPhotoSize - skip.x() - size, + (rtl() + ? skip.x() + : (st::dialogsPhotoSize - skip.x() - size)), st::dialogsPhotoSize - skip.y() - size, size, size @@ -247,7 +250,10 @@ void BasicRow::paintUserpic( _cornerBadgeUserpic->active = active; PaintCornerBadgeFrame(_cornerBadgeUserpic.get(), peer, _userpic); } - p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame); + //when a corner badge exists this function is called to paint userpic + rtl() + ? p.drawImage(fullWidth - st::dialogsPadding.x() - st::dialogsPhotoSize, st::dialogsPadding.y(), _cornerBadgeUserpic->frame) + : p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame); if (historyForCornerBadge->peer->isUser()) { return; } diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp index b688d56d17856b..f74e4e33d34ed7 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp @@ -51,15 +51,19 @@ const auto kPsaBadgePrefix = "cloud_lng_badge_psa_"; || history->peer->asUser()->onlineTill > 0); } -void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected) { +void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected, int outerw = -1) { const auto width = st::dialogsDateFont->width(text); rectForName.setWidth(rectForName.width() - width - st::dialogsDateSkip); p.setFont(st::dialogsDateFont); p.setPen(active ? st::dialogsDateFgActive : (selected ? st::dialogsDateFgOver : st::dialogsDateFg)); - p.drawText(rectForName.left() + rectForName.width() + st::dialogsDateSkip, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, text); + auto left = rectForName.left() + rectForName.width() + st::dialogsDateSkip; + if (rtl() && outerw > 0){ + left = outerw - left - width; + } + p.drawText(left, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, text); } -void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, bool selected) { +void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, bool selected, int outerw) { const auto now = QDateTime::currentDateTime(); const auto &lastTime = date; const auto nowDate = now.date(); @@ -77,7 +81,8 @@ void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, b return lastDate.toString(cDateFormat()); } }(); - PaintRowTopRight(p, dt, rectForName, active, selected); + //paints dialogs last message date on each row + PaintRowTopRight(p, dt, rectForName, active, selected, outerw); } void PaintNarrowCounter( @@ -102,6 +107,7 @@ void PaintNarrowCounter( : 3; const auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize; + const auto unreadLeft = st::dialogsPadding.x(); const auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight; @@ -110,10 +116,14 @@ void PaintNarrowCounter( st.active = active; st.selected = selected; st.muted = unreadMuted; + st.align = rtl() ? style::al_left : style::al_right; + //paints unread counter or mark badge in narrow dialogs const auto badge = PaintUnreadBadge( p, counter, - unreadRight, + (rtl() + ? unreadLeft + : unreadRight), unreadTop, st, allowDigits); @@ -178,8 +188,10 @@ int PaintWideCounter( const auto counter = (unreadCount > 0) ? QString::number(unreadCount) : QString(); + //sets unread counter or unread mark badge coordination const auto unreadRight = fullWidth - st::dialogsPadding.x(); + const auto unreadLeft = st::dialogsPadding.x(); const auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent @@ -189,10 +201,14 @@ int PaintWideCounter( st.active = active; st.selected = selected; st.muted = unreadMuted; + st.align = rtl() ? style::al_left : style::al_right; + //paints unread counter or unread mark badge const auto badge = PaintUnreadBadge( p, counter, - unreadRight, + (rtl() + ? unreadLeft + : unreadRight), unreadTop, st); availableWidth -= badge.width() + st.padding; @@ -204,6 +220,7 @@ int PaintWideCounter( : selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon; + //paints pinned icon on dialogs if unread counter or unread mark doesn't exist icon.paint( p, fullWidth - st::dialogsPadding.x() - icon.width(), @@ -215,9 +232,11 @@ int PaintWideCounter( } if (displayMentionBadge || displayReactionBadge) { const auto counter = QString(); + //mention or reaction badge coordination const auto unreadRight = fullWidth - st::dialogsPadding.x() - (initial - availableWidth); + const auto unreadLeft = st::dialogsPadding.x() + (initial - availableWidth); const auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent @@ -232,12 +251,13 @@ int PaintWideCounter( st.muted = mentionOrReactionMuted; st.padding = 0; st.textTop = 0; + st.align = rtl() ? style::al_left : style::al_right; const auto badge = PaintUnreadBadge( p, counter, - unreadRight, + rtl() ? unreadLeft : unreadRight, unreadTop, - st); + st); /**paints mention or reaction badge*/ (displayMentionBadge ? (st.active ? st::dialogsUnreadMentionActive @@ -248,7 +268,7 @@ int PaintWideCounter( ? st::dialogsUnreadReactionActive : st.selected ? st::dialogsUnreadReactionOver - : st::dialogsUnreadReaction)).paintInCenter(p, badge); + : st::dialogsUnreadReaction)).paintInCenter(p, badge); /**paints mention or reaction inner icon at the center*/ availableWidth -= badge.width() + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0); @@ -372,6 +392,7 @@ void paintRow( fullWidth, st::dialogsPhotoSize); } else { + //Archived Chats folder goes here entry->paintUserpicLeft( p, row->userpicView(), @@ -410,9 +431,11 @@ void paintRow( : custom.isEmpty() ? tr::lng_badge_psa_default(tr::now) : custom; - PaintRowTopRight(p, text, rectForName, active, selected); + //paints promoted chat's type for example "proxy sponsor" + PaintRowTopRight(p, text, rectForName, active, selected, fullWidth); } else if (from) { if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) { + //paints chat type icon(it's rtl compatible due to lib_ui function usage) chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); } @@ -435,7 +458,8 @@ void paintRow( || (supportMode && entry->session().supportHelper().isOccupiedBySomeone(history))) { if (!promoted) { - PaintRowDate(p, date, rectForName, active, selected); + //paints date when drafts exists + PaintRowDate(p , date, rectForName, active, selected, fullWidth); } auto availableWidth = namewidth; @@ -495,7 +519,8 @@ void paintRow( } } else if (!item->isEmpty()) { if (history && !promoted) { - PaintRowDate(p, date, rectForName, active, selected); + //paints date + PaintRowDate(p, date, rectForName, active, selected, fullWidth); } paintItemCallback(nameleft, namewidth); @@ -582,14 +607,16 @@ void paintRow( : selected ? st::dialogsNameFgOver : st::dialogsNameFg); - from->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); + //draw chat's name + from->nameText().drawLeftElided(p, rectForName.left(), rectForName.top(), rectForName.width(), fullWidth, 1); } else if (hiddenSenderInfo) { p.setPen(active ? st::dialogsNameFgActive : selected ? st::dialogsNameFgOver : st::dialogsNameFg); - hiddenSenderInfo->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); + //draw chat's name when hidden sender info exists + hiddenSenderInfo->nameText.drawLeftElided(p, rectForName.left(), rectForName.top(), rectForName.width(), fullWidth); } else { p.setPen(active ? st::dialogsNameFgActive @@ -889,8 +916,11 @@ void RowPainter::paint( : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); + //creates rect for last message in each dialog const auto itemRect = QRect( - nameleft, + (rtl() + ? fullWidth - nameleft - availableWidth + : nameleft), texttop, availableWidth, st::dialogsTextFont->height); @@ -1128,7 +1158,11 @@ void PaintCollapsedRow( const auto left = narrow ? ((fullWidth - st::semiboldFont->width(text)) / 2) : st::dialogsPadding.x(); - p.drawText(left, textBaseline, text); + const auto right = (narrow + ? (fullWidth - st::semiboldFont->width(text)) / 2 + : (fullWidth - st::semiboldFont->width(text) - st::dialogsPadding.x())); + //draws achived chats title when collapsed + p.drawText(rtl() ? right : left, textBaseline, text); } else { folder->paintUserpicLeft( p, @@ -1140,12 +1174,17 @@ void PaintCollapsedRow( } if (!narrow && unread) { const auto unreadRight = fullWidth - st::dialogsPadding.x(); + const auto unreadLeft = st::dialogsPadding.x(); UnreadBadgeStyle st; st.muted = true; + st.align = rtl() ? style::al_left : style::al_right; + //paints unread counter badge in collapsed archived folder in wide mode PaintUnreadBadge( p, QString::number(unread), - unreadRight, + (rtl() + ? unreadLeft + : unreadRight), unreadTop, st); } diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_message_view.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_message_view.cpp index 0f814de793fa2b..5a9830a289051b 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_message_view.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_message_view.cpp @@ -164,7 +164,9 @@ void MessageView::paint( if (!_senderCache.isEmpty()) { _senderCache.drawElided( p, - rect.left(), + (rtl() + ? (geometry.left() + geometry.right() - rect.left() - _senderCache.maxWidth()) + : rect.left()), rect.top(), rect.width(), rect.height() / st::dialogsTextFont->height); @@ -177,7 +179,9 @@ void MessageView::paint( break; } p.drawImage( - rect.x(), + (rtl() + ? (geometry.left() + geometry.right() - rect.left() - st::dialogsMiniPreview) + : rect.x()), rect.y() + st::dialogsMiniPreviewTop, image.data); rect.setLeft(rect.x() @@ -192,7 +196,9 @@ void MessageView::paint( } _textCache.drawElided( p, - rect.left(), + (rtl() + ? geometry.left() + : rect.left()), rect.top(), rect.width(), rect.height() / st::dialogsTextFont->height); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index f96f51456e4b58..dab8602507a5b9 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2193,7 +2193,9 @@ void MainWidget::updateControlsGeometry() { if (_thirdSection) { auto thirdSectionTop = getThirdSectionTop(); _thirdSection->setGeometry( - width() - thirdSectionWidth, + (rtl() + ? 0 + : width() - thirdSectionWidth), thirdSectionTop, thirdSectionWidth, height() - thirdSectionTop); @@ -2238,7 +2240,9 @@ void MainWidget::updateControlsGeometry() { _callTopBarHeight + _exportTopBarHeight); } _history->setGeometryWithTopMoved(QRect( - dialogsWidth, + (rtl() + ? thirdSectionWidth + : dialogsWidth), mainSectionTop, mainSectionWidth, height() - mainSectionTop @@ -2275,7 +2279,9 @@ void MainWidget::refreshResizeAreas() { if (!isOneColumn()) { ensureFirstColumnResizeAreaCreated(); _firstColumnResizeArea->setGeometryToLeft( - _history->x(), + (rtl() + ? _dialogsWidth + : _history->x()), 0, st::historyResizeWidth, height()); @@ -2286,7 +2292,9 @@ void MainWidget::refreshResizeAreas() { if (isThreeColumn() && _thirdSection) { ensureThirdColumnResizeAreaCreated(); _thirdColumnResizeArea->setGeometryToLeft( - _thirdSection->x(), + (rtl() + ? (width() - _thirdSection->width()) + : _thirdSection->x()), 0, st::historyResizeWidth, height()); @@ -2315,6 +2323,9 @@ void MainWidget::ensureFirstColumnResizeAreaCreated() { } auto moveLeftCallback = [=](int globalLeft) { auto newWidth = globalLeft - mapToGlobal(QPoint(0, 0)).x(); + newWidth = rtl() + ? width() - newWidth + : newWidth; auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2) ? 0. : float64(newWidth) / width(); @@ -2342,6 +2353,9 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() { } auto moveLeftCallback = [=](int globalLeft) { auto newWidth = mapToGlobal(QPoint(width(), 0)).x() - globalLeft; + newWidth = rtl() + ? (width() - newWidth) + : newWidth; Core::App().settings().setThirdColumnWidth(newWidth); }; auto moveFinishedCallback = [=] { diff --git a/Telegram/SourceFiles/ui/unread_badge.cpp b/Telegram/SourceFiles/ui/unread_badge.cpp index bc82d4a502643d..c1a57ffdab4314 100644 --- a/Telegram/SourceFiles/ui/unread_badge.cpp +++ b/Telegram/SourceFiles/ui/unread_badge.cpp @@ -76,12 +76,21 @@ void DrawScamFakeBadge( p.setBrush(Qt::NoBrush); p.drawRoundedRect(rect, st::dialogsScamRadius, st::dialogsScamRadius); p.setFont(st::dialogsScamFont); - p.drawTextLeft( - rect.x() + st::dialogsScamPadding.left(), - rect.y() + st::dialogsScamPadding.top(), - outerWidth, - phrase, - phraseWidth); + if (rtl()) { + p.drawTextRight( + rect.x() + st::dialogsScamPadding.left(), + rect.y() + st::dialogsScamPadding.top(), + outerWidth, + phrase, + phraseWidth); + } else { + p.drawTextLeft( + rect.x() + st::dialogsScamPadding.left(), + rect.y() + st::dialogsScamPadding.top(), + outerWidth, + phrase, + phraseWidth); + } } void DrawScamBadge( @@ -128,11 +137,11 @@ int DrawPeerBadgeGetWidth( const auto height = st::dialogsScamPadding.top() + st::dialogsScamFont->height + st::dialogsScamPadding.bottom(); + auto x = (rtl() + ? rectForName.right() - qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width) - width + : rectForName.x() + qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width)); const auto rect = QRect( - (rectForName.x() - + qMin( - nameWidth + st::dialogsScamSkip, - rectForName.width() - width)), + x, rectForName.y() + (rectForName.height() - height) / 2, width, height); diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index b9525eb0d81903..89c55b24e877bd 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -512,10 +512,17 @@ void ConnectionState::Widget::paintEvent(QPaintEvent *e) { const auto text = textRect(); const auto left = inner.topLeft(); const auto right = content.topLeft() + QPoint(content.width(), 0); - st::connectingLeftShadow.paint(p, left, width()); - st::connectingLeft.paint(p, left, width()); - st::connectingRightShadow.paint(p, right, width()); - st::connectingRight.paint(p, right, width()); + if (rtl()) { + st::connectingLeftShadow.paint(p, right, width()); + st::connectingLeft.paint(p, right, width()); + st::connectingRightShadow.paint(p, left, width()); + st::connectingRight.paint(p, left, width()); + } else { + st::connectingLeftShadow.paint(p, left, width()); + st::connectingLeft.paint(p, left, width()); + st::connectingRightShadow.paint(p, right, width()); + st::connectingRight.paint(p, right, width()); + } st::connectingBodyShadow.fill(p, content); st::connectingBody.fill(p, content);