mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed previous values resetting in VoiceRecordButton.
This commit is contained in:
parent
2035392564
commit
1d120092cf
1 changed files with 29 additions and 2 deletions
|
@ -126,6 +126,9 @@ public:
|
||||||
void start(float64 to) {
|
void start(float64 to) {
|
||||||
start(to, _duration);
|
start(to, _duration);
|
||||||
}
|
}
|
||||||
|
void reset() {
|
||||||
|
_to = _cur = _delta = 0.;
|
||||||
|
}
|
||||||
|
|
||||||
float64 current() const {
|
float64 current() const {
|
||||||
return _cur;
|
return _cur;
|
||||||
|
@ -201,6 +204,7 @@ public:
|
||||||
|
|
||||||
void setValue(float64 to);
|
void setValue(float64 to);
|
||||||
void tick(float64 circleRadius, crl::time dt);
|
void tick(float64 circleRadius, crl::time dt);
|
||||||
|
void reset();
|
||||||
|
|
||||||
void paint(Painter &p, QColor c);
|
void paint(Painter &p, QColor c);
|
||||||
|
|
||||||
|
@ -250,6 +254,7 @@ class RecordCircle final {
|
||||||
public:
|
public:
|
||||||
RecordCircle(rpl::producer<crl::time> animationTicked);
|
RecordCircle(rpl::producer<crl::time> animationTicked);
|
||||||
|
|
||||||
|
void reset();
|
||||||
void setAmplitude(float64 value);
|
void setAmplitude(float64 value);
|
||||||
void paint(Painter &p, QColor c);
|
void paint(Painter &p, QColor c);
|
||||||
|
|
||||||
|
@ -360,6 +365,21 @@ Wave::Wave(
|
||||||
initFlingAnimation(std::move(animationTicked));
|
initFlingAnimation(std::move(animationTicked));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wave::reset() {
|
||||||
|
_incRandomAdditionals = false;
|
||||||
|
_isIdle = true;
|
||||||
|
_wasFling = false;
|
||||||
|
_flingRadius = 0.;
|
||||||
|
_idleRadius = 0.;
|
||||||
|
_idleRotation = 0.;
|
||||||
|
_lastRadius = 0.;
|
||||||
|
_rotation = 0.;
|
||||||
|
_sineAngleMax = 0.;
|
||||||
|
_waveAngle = 0.;
|
||||||
|
_waveDiff = 0.;
|
||||||
|
_levelValue.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void Wave::setValue(float64 to) {
|
void Wave::setValue(float64 to) {
|
||||||
const auto duration = (to <= _levelValue.current())
|
const auto duration = (to <= _levelValue.current())
|
||||||
? _amplitudeOutAnimationDuration
|
? _amplitudeOutAnimationDuration
|
||||||
|
@ -559,6 +579,12 @@ RecordCircle::RecordCircle(rpl::producer<crl::time> animationTicked)
|
||||||
+ kAmplitudeDiffFactorMax * kAnimationSpeedCircle) {
|
+ kAmplitudeDiffFactorMax * kAnimationSpeedCircle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecordCircle::reset() {
|
||||||
|
_majorWave->reset();
|
||||||
|
_minorWave->reset();
|
||||||
|
_levelValue.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void RecordCircle::setAmplitude(float64 value) {
|
void RecordCircle::setAmplitude(float64 value) {
|
||||||
const auto to = std::min(kMaxAmplitude, value) / kMaxAmplitude;
|
const auto to = std::min(kMaxAmplitude, value) / kMaxAmplitude;
|
||||||
_levelValue.start(to);
|
_levelValue.start(to);
|
||||||
|
@ -567,7 +593,6 @@ void RecordCircle::setAmplitude(float64 value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordCircle::paint(Painter &p, QColor c) {
|
void RecordCircle::paint(Painter &p, QColor c) {
|
||||||
|
|
||||||
const auto dt = crl::now() - _lastUpdateTime;
|
const auto dt = crl::now() - _lastUpdateTime;
|
||||||
_levelValue.update(dt);
|
_levelValue.update(dt);
|
||||||
|
|
||||||
|
@ -655,13 +680,15 @@ void VoiceRecordButton::init() {
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
shownValue(),
|
shownValue(),
|
||||||
_showProgress.value() | rpl::map(hasProgress)
|
_showProgress.value(
|
||||||
|
) | rpl::map(hasProgress) | rpl::distinct_until_changed()
|
||||||
) | rpl::start_with_next([=](bool show) {
|
) | rpl::start_with_next([=](bool show) {
|
||||||
setVisible(show);
|
setVisible(show);
|
||||||
setMouseTracking(show);
|
setMouseTracking(show);
|
||||||
if (!show) {
|
if (!show) {
|
||||||
_recordingAnimation.stop();
|
_recordingAnimation.stop();
|
||||||
_showProgress = 0.;
|
_showProgress = 0.;
|
||||||
|
_recordCircle->reset();
|
||||||
} else {
|
} else {
|
||||||
if (!_recordingAnimation.animating()) {
|
if (!_recordingAnimation.animating()) {
|
||||||
_recordingAnimation.start();
|
_recordingAnimation.start();
|
||||||
|
|
Loading…
Add table
Reference in a new issue