mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added red coloring of record button.
This commit is contained in:
parent
326342420d
commit
914e40fb62
4 changed files with 53 additions and 3 deletions
|
@ -340,6 +340,24 @@ void VoiceRecordBar::init() {
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
stop(true);
|
stop(true);
|
||||||
}, _recordingLifetime);
|
}, _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());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,6 +500,9 @@ void VoiceRecordBar::stop(bool send) {
|
||||||
_recordingSamples = 0;
|
_recordingSamples = 0;
|
||||||
_sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 });
|
_sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 });
|
||||||
|
|
||||||
|
_send->setForceRippled(false);
|
||||||
|
_send->clearRecordState();
|
||||||
|
|
||||||
_controller->widget()->setInnerFocus();
|
_controller->widget()->setInnerFocus();
|
||||||
};
|
};
|
||||||
_lockShowing = false;
|
_lockShowing = false;
|
||||||
|
|
|
@ -333,7 +333,9 @@ historyRecordVoiceDuration: 120;
|
||||||
historyRecordVoice: icon {{ "send_control_record", historyRecordVoiceFg }};
|
historyRecordVoice: icon {{ "send_control_record", historyRecordVoiceFg }};
|
||||||
historyRecordVoiceOver: icon {{ "send_control_record", historyRecordVoiceFgOver }};
|
historyRecordVoiceOver: icon {{ "send_control_record", historyRecordVoiceFgOver }};
|
||||||
historyRecordVoiceActive: icon {{ "send_control_record", historyRecordVoiceFgActive }};
|
historyRecordVoiceActive: icon {{ "send_control_record", historyRecordVoiceFgActive }};
|
||||||
|
historyRecordVoiceCancel: icon {{ "send_control_record", attentionButtonFg }};
|
||||||
historyRecordVoiceRippleBgActive: lightButtonBgOver;
|
historyRecordVoiceRippleBgActive: lightButtonBgOver;
|
||||||
|
historyRecordVoiceRippleBgCancel: attentionButtonBgRipple;
|
||||||
historyRecordSignalColor: attentionButtonFg;
|
historyRecordSignalColor: attentionButtonFg;
|
||||||
historyRecordSignalMin: 5px;
|
historyRecordSignalMin: 5px;
|
||||||
historyRecordSignalMax: 12px;
|
historyRecordSignalMax: 12px;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void SendButton::setType(Type type) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
if (_type != Type::Record) {
|
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) {
|
void SendButton::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
|
@ -104,8 +117,17 @@ void SendButton::paintEvent(QPaintEvent *e) {
|
||||||
void SendButton::paintRecord(Painter &p, bool over) {
|
void SendButton::paintRecord(Painter &p, bool over) {
|
||||||
const auto recordActive = _recordProgress;
|
const auto recordActive = _recordProgress;
|
||||||
if (!isDisabled()) {
|
if (!isDisabled()) {
|
||||||
auto rippleColor = anim::color(st::historyAttachEmoji.ripple.color, st::historyRecordVoiceRippleBgActive, recordActive);
|
auto rippleColor = anim::color(
|
||||||
paintRipple(p, (width() - st::historyAttachEmoji.rippleAreaSize) / 2, st::historyAttachEmoji.rippleAreaPosition.y(), &rippleColor);
|
_recordLocked
|
||||||
|
? st::historyRecordVoiceRippleBgCancel
|
||||||
|
: st::historyAttachEmoji.ripple.color,
|
||||||
|
st::historyRecordVoiceRippleBgActive,
|
||||||
|
recordActive);
|
||||||
|
paintRipple(
|
||||||
|
p,
|
||||||
|
(width() - st::historyAttachEmoji.rippleAreaSize) / 2,
|
||||||
|
st::historyAttachEmoji.rippleAreaPosition.y(),
|
||||||
|
&rippleColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fastIcon = [&] {
|
auto fastIcon = [&] {
|
||||||
|
@ -113,6 +135,8 @@ void SendButton::paintRecord(Painter &p, bool over) {
|
||||||
return &st::historyRecordVoice;
|
return &st::historyRecordVoice;
|
||||||
} else if (recordActive == 1.) {
|
} else if (recordActive == 1.) {
|
||||||
return &st::historyRecordVoiceActive;
|
return &st::historyRecordVoiceActive;
|
||||||
|
} else if (_recordLocked) {
|
||||||
|
return &st::historyRecordVoiceCancel;
|
||||||
} else if (over) {
|
} else if (over) {
|
||||||
return &st::historyRecordVoiceOver;
|
return &st::historyRecordVoiceOver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ public:
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
void setType(Type state);
|
void setType(Type state);
|
||||||
|
void setLockRecord(bool lock);
|
||||||
|
void clearRecordState();
|
||||||
void setSlowmodeDelay(int seconds);
|
void setSlowmodeDelay(int seconds);
|
||||||
void finishAnimating();
|
void finishAnimating();
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ private:
|
||||||
|
|
||||||
Ui::Animations::Simple _a_typeChanged;
|
Ui::Animations::Simple _a_typeChanged;
|
||||||
|
|
||||||
|
bool _recordLocked = false;
|
||||||
float64 _recordProgress = 0.;
|
float64 _recordProgress = 0.;
|
||||||
|
|
||||||
int _slowmodeDelay = 0;
|
int _slowmodeDelay = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue