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

View file

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