Fixed size and position of lock/stop button at end of animation.

This commit is contained in:
23rd 2020-11-11 23:13:57 +03:00 committed by John Preston
parent 7dac42b523
commit fb2924f2d6

View file

@ -623,16 +623,15 @@ RecordLock::RecordLock(not_null<Ui::RpWidget*> parent)
Qt::SolidLine, Qt::SolidLine,
Qt::SquareCap, Qt::SquareCap,
Qt::RoundJoin) { Qt::RoundJoin) {
resize(
st::historyRecordLockTopShadow.width(),
st::historyRecordLockSize.height());
// resize(st::historyRecordLockSize);
init(); init();
} }
void RecordLock::init() { void RecordLock::init() {
shownValue( shownValue(
) | rpl::start_with_next([=](bool shown) { ) | rpl::start_with_next([=](bool shown) {
resize(
st::historyRecordLockTopShadow.width(),
st::historyRecordLockSize.height());
if (!shown) { if (!shown) {
setCursor(style::cur_default); setCursor(style::cur_default);
setAttribute(Qt::WA_TransparentForMouseEvents, true); setAttribute(Qt::WA_TransparentForMouseEvents, true);
@ -667,6 +666,10 @@ void RecordLock::init() {
if (value == to) { if (value == to) {
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
setAttribute(Qt::WA_TransparentForMouseEvents, false); setAttribute(Qt::WA_TransparentForMouseEvents, false);
resize(
st::historyRecordLockTopShadow.width(),
st::historyRecordLockTopShadow.width());
} }
}; };
_lockAnimation.start(std::move(callback), from, to, duration); _lockAnimation.start(std::move(callback), from, to, duration);
@ -1115,9 +1118,10 @@ void VoiceRecordBar::setStartRecordingFilter(Fn<bool()> &&callback) {
} }
void VoiceRecordBar::setLockBottom(rpl::producer<int> &&bottom) { void VoiceRecordBar::setLockBottom(rpl::producer<int> &&bottom) {
std::move( rpl::combine(
bottom std::move(bottom),
) | rpl::start_with_next([=](int value) { _lock->sizeValue() | rpl::map_to(true) // Dummy value.
) | rpl::start_with_next([=](int value, bool dummy) {
_lock->moveToLeft(_lock->x(), value - _lock->height()); _lock->moveToLeft(_lock->x(), value - _lock->height());
}, lifetime()); }, lifetime());
} }