mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Added send icon to VoiceRecordButton.
This commit is contained in:
parent
e29ee439cf
commit
1758f0fd8f
5 changed files with 57 additions and 5 deletions
|
@ -1342,7 +1342,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_broadcast_silent_ph" = "Silent broadcast...";
|
"lng_broadcast_silent_ph" = "Silent broadcast...";
|
||||||
"lng_send_anonymous_ph" = "Send anonymously...";
|
"lng_send_anonymous_ph" = "Send anonymously...";
|
||||||
"lng_record_cancel" = "Release outside this field to cancel";
|
"lng_record_cancel" = "Release outside this field to cancel";
|
||||||
"lng_record_lock_cancel" = "Click outside of microphone button to cancel";
|
"lng_record_lock_cancel" = "Click outside of circle to cancel";
|
||||||
"lng_record_lock_cancel_sure" = "Are you sure you want to stop recording and discard your voice message?";
|
"lng_record_lock_cancel_sure" = "Are you sure you want to stop recording and discard your voice message?";
|
||||||
"lng_record_lock_discard" = "Discard";
|
"lng_record_lock_discard" = "Discard";
|
||||||
"lng_will_be_notified" = "Members will be notified when you post";
|
"lng_will_be_notified" = "Members will be notified when you post";
|
||||||
|
|
|
@ -1074,6 +1074,7 @@ void VoiceRecordBar::init() {
|
||||||
_lock->locks(
|
_lock->locks(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
installClickOutsideFilter();
|
installClickOutsideFilter();
|
||||||
|
_level->setType(VoiceRecordButton::Type::Send);
|
||||||
|
|
||||||
_level->clicks(
|
_level->clicks(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
@ -1102,7 +1103,8 @@ void VoiceRecordBar::init() {
|
||||||
TextParseOptions{ TextParseMultiline, 0, 0, direction });
|
TextParseOptions{ TextParseMultiline, 0, 0, direction });
|
||||||
|
|
||||||
updateMessageGeometry();
|
updateMessageGeometry();
|
||||||
update(_messageRect);
|
// Update a whole widget to clear a previous text.
|
||||||
|
update();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_send->events(
|
_send->events(
|
||||||
|
|
|
@ -213,8 +213,6 @@ private:
|
||||||
void initEnterIdleAnimation(rpl::producer<crl::time> animationTicked);
|
void initEnterIdleAnimation(rpl::producer<crl::time> animationTicked);
|
||||||
void initFlingAnimation(rpl::producer<crl::time> animationTicked);
|
void initFlingAnimation(rpl::producer<crl::time> animationTicked);
|
||||||
|
|
||||||
Ui::Animations::Simple _flingAnimation;
|
|
||||||
|
|
||||||
const std::unique_ptr<CircleBezier> _circleBezier;
|
const std::unique_ptr<CircleBezier> _circleBezier;
|
||||||
|
|
||||||
const float _rotationOffset;
|
const float _rotationOffset;
|
||||||
|
@ -652,6 +650,10 @@ void VoiceRecordButton::requestPaintLevel(quint16 level) {
|
||||||
void VoiceRecordButton::init() {
|
void VoiceRecordButton::init() {
|
||||||
const auto hasProgress = [](auto value) { return value != 0.; };
|
const auto hasProgress = [](auto value) { return value != 0.; };
|
||||||
|
|
||||||
|
const auto stateChangedAnimation =
|
||||||
|
lifetime().make_state<Ui::Animations::Simple>();
|
||||||
|
const auto currentState = lifetime().make_state<Type>(_state.current());
|
||||||
|
|
||||||
paintRequest(
|
paintRequest(
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
) | rpl::start_with_next([=](const QRect &clip) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
@ -674,8 +676,29 @@ void VoiceRecordButton::init() {
|
||||||
if (!complete) {
|
if (!complete) {
|
||||||
p.setOpacity(progress);
|
p.setOpacity(progress);
|
||||||
}
|
}
|
||||||
st::historyRecordVoiceActive.paintInCenter(p, rect());
|
|
||||||
|
|
||||||
|
// Paint icon.
|
||||||
|
{
|
||||||
|
const auto stateProgress = stateChangedAnimation->value(0.);
|
||||||
|
const auto scale = (std::cos(M_PI * 2 * stateProgress) + 1.) * .5;
|
||||||
|
p.translate(_center, _center);
|
||||||
|
if (scale < 1.) {
|
||||||
|
p.scale(scale, scale);
|
||||||
|
}
|
||||||
|
const auto state = *currentState;
|
||||||
|
const auto icon = (state == Type::Send)
|
||||||
|
? st::historySendIcon
|
||||||
|
: st::historyRecordVoiceActive;
|
||||||
|
const auto position = (state == Type::Send)
|
||||||
|
? st::historyRecordSendIconPosition
|
||||||
|
: QPoint(0, 0);
|
||||||
|
icon.paint(
|
||||||
|
p,
|
||||||
|
-icon.width() / 2 + position.x(),
|
||||||
|
-icon.height() / 2 + position.y(),
|
||||||
|
0,
|
||||||
|
st::historyRecordVoiceFgActiveIcon->c);
|
||||||
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
|
@ -689,6 +712,7 @@ void VoiceRecordButton::init() {
|
||||||
_recordingAnimation.stop();
|
_recordingAnimation.stop();
|
||||||
_showProgress = 0.;
|
_showProgress = 0.;
|
||||||
_recordCircle->reset();
|
_recordCircle->reset();
|
||||||
|
_state = Type::Record;
|
||||||
} else {
|
} else {
|
||||||
if (!_recordingAnimation.animating()) {
|
if (!_recordingAnimation.animating()) {
|
||||||
_recordingAnimation.start();
|
_recordingAnimation.start();
|
||||||
|
@ -701,6 +725,19 @@ void VoiceRecordButton::init() {
|
||||||
) | rpl::start_with_next([=](bool active) {
|
) | rpl::start_with_next([=](bool active) {
|
||||||
setPointerCursor(active);
|
setPointerCursor(active);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
_state.changes(
|
||||||
|
) | rpl::start_with_next([=](Type newState) {
|
||||||
|
const auto to = 1.;
|
||||||
|
auto callback = [=](float64 value) {
|
||||||
|
if (value >= (to * .5)) {
|
||||||
|
*currentState = newState;
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
};
|
||||||
|
const auto duration = st::historyRecordVoiceDuration * 2;
|
||||||
|
stateChangedAnimation->start(std::move(callback), 0., to, duration);
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> VoiceRecordButton::actives() const {
|
rpl::producer<bool> VoiceRecordButton::actives() const {
|
||||||
|
@ -745,4 +782,8 @@ void VoiceRecordButton::requestPaintColor(float64 progress) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoiceRecordButton::setType(Type state) {
|
||||||
|
_state = state;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace HistoryView::Controls
|
} // namespace HistoryView::Controls
|
||||||
|
|
|
@ -22,6 +22,13 @@ public:
|
||||||
rpl::producer<> leaveWindowEventProducer);
|
rpl::producer<> leaveWindowEventProducer);
|
||||||
~VoiceRecordButton();
|
~VoiceRecordButton();
|
||||||
|
|
||||||
|
enum class Type {
|
||||||
|
Send,
|
||||||
|
Record,
|
||||||
|
};
|
||||||
|
|
||||||
|
void setType(Type state);
|
||||||
|
|
||||||
void requestPaintColor(float64 progress);
|
void requestPaintColor(float64 progress);
|
||||||
void requestPaintProgress(float64 progress);
|
void requestPaintProgress(float64 progress);
|
||||||
void requestPaintLevel(quint16 level);
|
void requestPaintLevel(quint16 level);
|
||||||
|
@ -41,6 +48,7 @@ private:
|
||||||
rpl::variable<float64> _showProgress = 0.;
|
rpl::variable<float64> _showProgress = 0.;
|
||||||
rpl::variable<float64> _colorProgress = 0.;
|
rpl::variable<float64> _colorProgress = 0.;
|
||||||
rpl::variable<bool> _inCircle = false;
|
rpl::variable<bool> _inCircle = false;
|
||||||
|
rpl::variable<Type> _state = Type::Record;
|
||||||
|
|
||||||
// This can animate for a very long time (like in music playing),
|
// This can animate for a very long time (like in music playing),
|
||||||
// so it should be a Basic, not a Simple animation.
|
// so it should be a Basic, not a Simple animation.
|
||||||
|
|
|
@ -336,6 +336,7 @@ 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_active", historyRecordVoiceFgActiveIcon }};
|
historyRecordVoiceActive: icon {{ "send_control_record_active", historyRecordVoiceFgActiveIcon }};
|
||||||
|
historyRecordSendIconPosition: point(2px, 0px);
|
||||||
historyRecordVoiceRippleBgActive: lightButtonBgOver;
|
historyRecordVoiceRippleBgActive: lightButtonBgOver;
|
||||||
historyRecordSignalRadius: 5px;
|
historyRecordSignalRadius: 5px;
|
||||||
historyRecordCancel: windowSubTextFg;
|
historyRecordCancel: windowSubTextFg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue