Added red coloring of record button.

This commit is contained in:
23rd 2020-10-09 17:07:58 +03:00 committed by John Preston
parent 326342420d
commit 914e40fb62
4 changed files with 53 additions and 3 deletions

View file

@ -340,6 +340,24 @@ void VoiceRecordBar::init() {
}) | rpl::start_with_next([=] {
stop(true);
}, _recordingLifetime);
auto hover = _send->events(
) | rpl::filter([=](not_null<QEvent*> e) {
return e->type() == QEvent::Enter
|| e->type() == QEvent::Leave;
}) | rpl::map([=](not_null<QEvent*> 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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;