From 7224c6a191e3203bcdc9ae92fdade3575cac4137 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 24 Mar 2020 17:51:14 +0400 Subject: [PATCH] Move too wide badge to the left. --- ui/widgets/side_bar_button.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/widgets/side_bar_button.cpp b/ui/widgets/side_bar_button.cpp index 3f8dc61..193d23a 100644 --- a/ui/widgets/side_bar_button.cpp +++ b/ui/widgets/side_bar_button.cpp @@ -106,7 +106,10 @@ void SideBarButton::paintEvent(QPaintEvent *e) { style::al_top); if (_iconCacheBadgeWidth) { - const auto x = width() / 2 + _st.badgePosition.x(); + const auto desiredLeft = width() / 2 + _st.badgePosition.x(); + const auto x = std::min( + desiredLeft, + width() - _iconCacheBadgeWidth - st::defaultScrollArea.width); const auto y = _st.badgePosition.y(); auto hq = PainterHighQualityEnabler(p); @@ -162,7 +165,14 @@ void SideBarButton::validateIconCache() { pen.setWidth(2 * _st.badgeStroke); p.setPen(pen); auto hq = PainterHighQualityEnabler(p); - const auto x = (icon.width() / 2) + _st.badgePosition.x(); + const auto desiredLeft = (icon.width() / 2) + _st.badgePosition.x(); + const auto x = std::min( + desiredLeft, + (width() + - _iconCacheBadgeWidth + - st::defaultScrollArea.width + - (width() / 2) + + (icon.width() / 2))); const auto y = _st.badgePosition.y() - _st.iconPosition.y(); const auto r = _st.badgeHeight / 2.; p.drawRoundedRect(x, y, _iconCacheBadgeWidth, _st.badgeHeight, r, r);