Allow to specify RoundButton radius.

This commit is contained in:
John Preston 2021-05-06 19:48:43 +04:00
parent 3c1866f52d
commit b0c5d9220b
2 changed files with 10 additions and 4 deletions

View file

@ -256,8 +256,8 @@ RoundButton::RoundButton(
: RippleButton(parent, st.ripple) : RippleButton(parent, st.ripple)
, _textFull(std::move(text)) , _textFull(std::move(text))
, _st(st) , _st(st)
, _roundRect(st::buttonRadius, _st.textBg) , _roundRect(st.radius ? st.radius : st::buttonRadius, _st.textBg)
, _roundRectOver(st::buttonRadius, _st.textBgOver) { , _roundRectOver(st.radius ? st.radius : st::buttonRadius, _st.textBgOver) {
_textFull.value( _textFull.value(
) | rpl::start_with_next([=](const QString &text) { ) | rpl::start_with_next([=](const QString &text) {
resizeToText(text); resizeToText(text);
@ -377,7 +377,8 @@ void RoundButton::paintEvent(QPaintEvent *e) {
} else if (_brushOverride) { } else if (_brushOverride) {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(*_brushOverride); p.setBrush(*_brushOverride);
p.drawRoundedRect(fill, st::buttonRadius, st::buttonRadius); const auto radius = _st.radius ? _st.radius : st::buttonRadius;
p.drawRoundedRect(fill, radius, radius);
} else { } else {
rect.paint(p, fill); rect.paint(p, fill);
} }
@ -436,7 +437,11 @@ QImage RoundButton::prepareRippleMask() const {
} }
return RippleAnimation::roundRectMask( return RippleAnimation::roundRectMask(
rounded.size(), rounded.size(),
_fullRadius ? (rounded.height() / 2) : st::buttonRadius); (_fullRadius
? (rounded.height() / 2)
: _st.radius
? _st.radius
: st::buttonRadius));
} }
QPoint RoundButton::prepareRippleStartPosition() const { QPoint RoundButton::prepareRippleStartPosition() const {

View file

@ -88,6 +88,7 @@ RoundButton {
width: pixels; width: pixels;
height: pixels; height: pixels;
radius: pixels;
padding: margins; padding: margins;
textTop: pixels; textTop: pixels;