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,
|
const style::font &font,
|
||||||
Fn<void()> animationCallback)
|
Fn<void()> animationCallback)
|
||||||
: _font(font)
|
: _font(font)
|
||||||
|
, _duration(st::slideWrapDuration)
|
||||||
, _animationCallback(std::move(animationCallback)) {
|
, _animationCallback(std::move(animationCallback)) {
|
||||||
for (auto ch = '0'; ch != '9'; ++ch) {
|
for (auto ch = '0'; ch != '9'; ++ch) {
|
||||||
accumulate_max(_digitWidth, _font->m.horizontalAdvance(ch));
|
accumulate_max(_digitWidth, _font->m.horizontalAdvance(ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NumbersAnimation::setDuration(int duration) {
|
||||||
|
_duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
void NumbersAnimation::setText(const QString &text, int value) {
|
void NumbersAnimation::setText(const QString &text, int value) {
|
||||||
if (_a_ready.animating()) {
|
if (_a_ready.animating()) {
|
||||||
_delayedText = text;
|
_delayedText = text;
|
||||||
|
|
@ -82,7 +87,7 @@ void NumbersAnimation::realSetText(QString text, int value) {
|
||||||
[this] { animationCallback(); },
|
[this] { animationCallback(); },
|
||||||
0.,
|
0.,
|
||||||
1.,
|
1.,
|
||||||
st::slideWrapDuration);
|
_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ public:
|
||||||
_widthChangedCallback = std::move(callback);
|
_widthChangedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
void setText(const QString &text, int value);
|
void setText(const QString &text, int value);
|
||||||
|
void setDuration(int duration);
|
||||||
void finishAnimating();
|
void finishAnimating();
|
||||||
|
|
||||||
void paint(QPainter &p, int x, int y, int outerWidth);
|
void paint(QPainter &p, int x, int y, int outerWidth);
|
||||||
|
|
@ -44,6 +45,8 @@ private:
|
||||||
|
|
||||||
const style::font &_font;
|
const style::font &_font;
|
||||||
|
|
||||||
|
int _duration;
|
||||||
|
|
||||||
QList<Digit> _digits;
|
QList<Digit> _digits;
|
||||||
int _digitWidth = 0;
|
int _digitWidth = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue