Added ability to set custom duration of numbers animation.
This commit is contained in:
parent
f62e5ce5f6
commit
7133ccd2f9
2 changed files with 9 additions and 1 deletions
|
|
@ -17,12 +17,17 @@ NumbersAnimation::NumbersAnimation(
|
|||
const style::font &font,
|
||||
Fn<void()> animationCallback)
|
||||
: _font(font)
|
||||
, _duration(st::slideWrapDuration)
|
||||
, _animationCallback(std::move(animationCallback)) {
|
||||
for (auto ch = '0'; ch != '9'; ++ch) {
|
||||
accumulate_max(_digitWidth, _font->m.horizontalAdvance(ch));
|
||||
}
|
||||
}
|
||||
|
||||
void NumbersAnimation::setDuration(int duration) {
|
||||
_duration = duration;
|
||||
}
|
||||
|
||||
void NumbersAnimation::setText(const QString &text, int value) {
|
||||
if (_a_ready.animating()) {
|
||||
_delayedText = text;
|
||||
|
|
@ -82,7 +87,7 @@ void NumbersAnimation::realSetText(QString text, int value) {
|
|||
[this] { animationCallback(); },
|
||||
0.,
|
||||
1.,
|
||||
st::slideWrapDuration);
|
||||
_duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public:
|
|||
_widthChangedCallback = std::move(callback);
|
||||
}
|
||||
void setText(const QString &text, int value);
|
||||
void setDuration(int duration);
|
||||
void finishAnimating();
|
||||
|
||||
void paint(QPainter &p, int x, int y, int outerWidth);
|
||||
|
|
@ -44,6 +45,8 @@ private:
|
|||
|
||||
const style::font &_font;
|
||||
|
||||
int _duration;
|
||||
|
||||
QList<Digit> _digits;
|
||||
int _digitWidth = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue