diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index a5d1a30850..d822a0f053 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -340,6 +340,24 @@ void VoiceRecordBar::init() { }) | rpl::start_with_next([=] { stop(true); }, _recordingLifetime); + + auto hover = _send->events( + ) | rpl::filter([=](not_null e) { + return e->type() == QEvent::Enter + || e->type() == QEvent::Leave; + }) | rpl::map([=](not_null e) { + return (e->type() == QEvent::Enter); + }); + + _send->setLockRecord(true); + _send->setForceRippled(true); + rpl::single( + false + ) | rpl::then( + std::move(hover) + ) | rpl::start_with_next([=](bool enter) { + _inField = enter; + }, _recordingLifetime); }, lifetime()); } @@ -482,6 +500,9 @@ void VoiceRecordBar::stop(bool send) { _recordingSamples = 0; _sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 }); + _send->setForceRippled(false); + _send->clearRecordState(); + _controller->widget()->setInnerFocus(); }; _lockShowing = false; diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 325c6160db..46e808eb72 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -333,7 +333,9 @@ historyRecordVoiceDuration: 120; historyRecordVoice: icon {{ "send_control_record", historyRecordVoiceFg }}; historyRecordVoiceOver: icon {{ "send_control_record", historyRecordVoiceFgOver }}; historyRecordVoiceActive: icon {{ "send_control_record", historyRecordVoiceFgActive }}; +historyRecordVoiceCancel: icon {{ "send_control_record", attentionButtonFg }}; historyRecordVoiceRippleBgActive: lightButtonBgOver; +historyRecordVoiceRippleBgCancel: attentionButtonBgRipple; historyRecordSignalColor: attentionButtonFg; historyRecordSignalMin: 5px; historyRecordSignalMax: 12px; diff --git a/Telegram/SourceFiles/ui/controls/send_button.cpp b/Telegram/SourceFiles/ui/controls/send_button.cpp index f28cff456c..ec96357914 100644 --- a/Telegram/SourceFiles/ui/controls/send_button.cpp +++ b/Telegram/SourceFiles/ui/controls/send_button.cpp @@ -43,7 +43,7 @@ void SendButton::setType(Type type) { update(); } if (_type != Type::Record) { - _recordProgress = 0.; + clearRecordState(); } } @@ -73,6 +73,19 @@ void SendButton::requestPaintRecord(float64 progress) { } } +void SendButton::setLockRecord(bool lock) { + if (_type == Type::Record) { + _recordLocked = lock; + update(); + } +} + +void SendButton::clearRecordState() { + _recordLocked = false; + _recordProgress = 0.; + update(); +} + void SendButton::paintEvent(QPaintEvent *e) { Painter p(this); @@ -104,8 +117,17 @@ void SendButton::paintEvent(QPaintEvent *e) { void SendButton::paintRecord(Painter &p, bool over) { const auto recordActive = _recordProgress; if (!isDisabled()) { - auto rippleColor = anim::color(st::historyAttachEmoji.ripple.color, st::historyRecordVoiceRippleBgActive, recordActive); - paintRipple(p, (width() - st::historyAttachEmoji.rippleAreaSize) / 2, st::historyAttachEmoji.rippleAreaPosition.y(), &rippleColor); + auto rippleColor = anim::color( + _recordLocked + ? st::historyRecordVoiceRippleBgCancel + : st::historyAttachEmoji.ripple.color, + st::historyRecordVoiceRippleBgActive, + recordActive); + paintRipple( + p, + (width() - st::historyAttachEmoji.rippleAreaSize) / 2, + st::historyAttachEmoji.rippleAreaPosition.y(), + &rippleColor); } auto fastIcon = [&] { @@ -113,6 +135,8 @@ void SendButton::paintRecord(Painter &p, bool over) { return &st::historyRecordVoice; } else if (recordActive == 1.) { return &st::historyRecordVoiceActive; + } else if (_recordLocked) { + return &st::historyRecordVoiceCancel; } else if (over) { return &st::historyRecordVoiceOver; } diff --git a/Telegram/SourceFiles/ui/controls/send_button.h b/Telegram/SourceFiles/ui/controls/send_button.h index 443571d433..938a0aa0c6 100644 --- a/Telegram/SourceFiles/ui/controls/send_button.h +++ b/Telegram/SourceFiles/ui/controls/send_button.h @@ -29,6 +29,8 @@ public: return _type; } void setType(Type state); + void setLockRecord(bool lock); + void clearRecordState(); void setSlowmodeDelay(int seconds); void finishAnimating(); @@ -57,6 +59,7 @@ private: Ui::Animations::Simple _a_typeChanged; + bool _recordLocked = false; float64 _recordProgress = 0.; int _slowmodeDelay = 0;