Skip to content

fix: make reply-cancel button less coarse-grained - #6106

Merged
pajlada merged 4 commits into
Chatterino:masterfrom
leungbk:reply-cancel
Apr 5, 2025
Merged

pajlada merged 4 commits into
Chatterino:masterfrom
leungbk:reply-cancel

Conversation

@leungbk

@leungbk leungbk commented Mar 23, 2025

Copy link
Copy Markdown
Contributor

Fixes #6099.

@leungbk
leungbk force-pushed the reply-cancel branch 2 times, most recently from e8f184a to a2ebc7c Compare March 23, 2025 04:51

@pajlada pajlada left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just a nit about the size of the button - try my suggestion & see if that looks as expected for you

As a reference:
Current main branch:
image

Your PR
image

Your PR with my suggestion
image

Might be prudent to try a few more levels of scaling

Comment thread src/widgets/splits/SplitInput.cpp Outdated
Comment on lines +313 to +314
this->ui_.cancelReplyButton->setFixedHeight(int(24 * scale));
this->ui_.cancelReplyButton->setFixedWidth(int(24 * scale));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can retain the old size by disabling the margin for now

Suggested change
this->ui_.cancelReplyButton->setFixedHeight(int(24 * scale));
this->ui_.cancelReplyButton->setFixedWidth(int(24 * scale));
this->ui_.cancelReplyButton->setEnableMargin(false);
this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale));
this->ui_.cancelReplyButton->setFixedWidth(int(12 * scale));

@Nerixyz Nerixyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 100% scaling, the button had 4 pixels padding horizontally and no padding vertically:

diff --git a/src/widgets/helper/Button.cpp b/src/widgets/helper/Button.cpp
index cf941f49c..19c7ec37c 100644
--- a/src/widgets/helper/Button.cpp
+++ b/src/widgets/helper/Button.cpp
@@ -84,7 +84,12 @@ void Button::setSvgResource(const QString &resourcePath)
         return;
     }
 
+    if (this->svgRenderer)
+    {
+        this->svgRenderer->deleteLater();
+    }
     this->svgRenderer = new QSvgRenderer(resourcePath, this);
+    this->svgRenderer->setAspectRatioMode(Qt::KeepAspectRatio);
     this->svgResourcePath = resourcePath;
 
     this->update();
@@ -199,15 +204,7 @@ void Button::paintButton(QPainter &painter)
         if (this->enableMargin_)
         {
             auto s = this->getMargin();
-            auto outSize = rect.size() - QSize{2 * s, 2 * s};
-            outSize = this->svgRenderer->defaultSize().scaled(
-                outSize, Qt::KeepAspectRatio);
-            auto margin = rect.size() - outSize;
-
-            rect = QRect{
-                QPoint{margin.width() / 2, margin.height() / 2},
-                outSize,
-            };
+            rect = {{s, s}, rect.size() - QSize{2 * s, 2 * s}};
         }
 
         this->svgRenderer->render(&painter, rect);
diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp
index a8af1c7c7..c2013b44a 100644
--- a/src/widgets/splits/SplitInput.cpp
+++ b/src/widgets/splits/SplitInput.cpp
@@ -310,8 +310,9 @@ void SplitInput::updateCancelReplyButton()
     {
         this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancel.svg");
     }
-    this->ui_.cancelReplyButton->setFixedHeight(int(24 * scale));
-    this->ui_.cancelReplyButton->setFixedWidth(int(24 * scale));
+    this->ui_.cancelReplyButton->setEnableMargin(false);
+    this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale));
+    this->ui_.cancelReplyButton->setFixedWidth(int(20 * scale));
 }
 
 void SplitInput::openEmotePopup()

Co-authored-by: nerix <nerixdev@outlook.de>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
some devil has injected this error
@pajlada
pajlada merged commit c5b6f21 into Chatterino:master Apr 5, 2025
@pajlada

pajlada commented Apr 5, 2025

Copy link
Copy Markdown
Member

Thank you! As a first-time contributor, you are now eligible to be listed in the About page in Chatterino.

If you want this, you can open a new PR where you modify the resources/contributors.txt file and add yourself to the list. Read the comments at the top for instructions.

babicekmarek pushed a commit to babicekmarek/streamally-chatterino that referenced this pull request Sep 14, 2026
Co-authored-by: nerix <nerixdev@outlook.de>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crunchy reply cancel button

3 participants