Allow to change some styles in CallButton.
This commit is contained in:
parent
14c67cf724
commit
3c1866f52d
2 changed files with 21 additions and 0 deletions
|
|
@ -26,6 +26,10 @@ CallButton::CallButton(
|
||||||
: RippleButton(parent, stFrom.button.ripple)
|
: RippleButton(parent, stFrom.button.ripple)
|
||||||
, _stFrom(&stFrom)
|
, _stFrom(&stFrom)
|
||||||
, _stTo(stTo) {
|
, _stTo(stTo) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallButton::init() {
|
||||||
resize(_stFrom->button.width, _stFrom->button.height);
|
resize(_stFrom->button.width, _stFrom->button.height);
|
||||||
|
|
||||||
_bgMask = RippleAnimation::ellipseMask(QSize(_stFrom->bgSize, _stFrom->bgSize));
|
_bgMask = RippleAnimation::ellipseMask(QSize(_stFrom->bgSize, _stFrom->bgSize));
|
||||||
|
|
@ -221,6 +225,18 @@ void CallButton::setColorOverrides(rpl::producer<CallButtonColors> &&colors) {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallButton::setStyle(
|
||||||
|
const style::CallButton &stFrom,
|
||||||
|
const style::CallButton *stTo) {
|
||||||
|
if (_stFrom == &stFrom && _stTo == stTo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_stFrom = &stFrom;
|
||||||
|
_stTo = stTo;
|
||||||
|
init();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
QPoint CallButton::prepareRippleStartPosition() const {
|
QPoint CallButton::prepareRippleStartPosition() const {
|
||||||
return mapFromGlobal(QCursor::pos()) - _stFrom->button.rippleAreaPosition;
|
return mapFromGlobal(QCursor::pos()) - _stFrom->button.rippleAreaPosition;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ public:
|
||||||
void setText(rpl::producer<QString> text);
|
void setText(rpl::producer<QString> text);
|
||||||
void setColorOverrides(rpl::producer<CallButtonColors> &&colors);
|
void setColorOverrides(rpl::producer<CallButtonColors> &&colors);
|
||||||
|
|
||||||
|
void setStyle(
|
||||||
|
const style::CallButton &stFrom,
|
||||||
|
const style::CallButton *stTo = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
|
@ -40,6 +44,7 @@ protected:
|
||||||
QPoint prepareRippleStartPosition() const override;
|
QPoint prepareRippleStartPosition() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void init();
|
||||||
QPoint iconPosition(not_null<const style::CallButton*> st) const;
|
QPoint iconPosition(not_null<const style::CallButton*> st) const;
|
||||||
void mixIconMasks();
|
void mixIconMasks();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue