mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Improved display management of voice record controls.
This commit is contained in:
parent
b3925a3bec
commit
cb84e70bdc
5 changed files with 68 additions and 52 deletions
|
@ -776,6 +776,8 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
updateHistoryDownVisibility();
|
||||
updateUnreadMentionsVisibility();
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
|
||||
void HistoryWidget::initTabbedSelector() {
|
||||
|
@ -2063,13 +2065,7 @@ void HistoryWidget::updateControlsVisibility() {
|
|||
updateHistoryDownVisibility();
|
||||
updateUnreadMentionsVisibility();
|
||||
if (!_history || _a_show.animating()) {
|
||||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hideFast();
|
||||
}
|
||||
if (_pinnedBar) {
|
||||
_pinnedBar->hide();
|
||||
}
|
||||
hideChildren();
|
||||
hideChildWidgets();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2140,6 +2136,9 @@ void HistoryWidget::updateControlsVisibility() {
|
|||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hide();
|
||||
}
|
||||
if (_voiceRecordBar) {
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
if (_inlineResults) {
|
||||
_inlineResults->hide();
|
||||
}
|
||||
|
@ -2231,6 +2230,9 @@ void HistoryWidget::updateControlsVisibility() {
|
|||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hide();
|
||||
}
|
||||
if (_voiceRecordBar) {
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
if (_inlineResults) {
|
||||
_inlineResults->hide();
|
||||
}
|
||||
|
@ -3005,6 +3007,19 @@ void HistoryWidget::saveEditMsg() {
|
|||
fail);
|
||||
}
|
||||
|
||||
void HistoryWidget::hideChildWidgets() {
|
||||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hideFast();
|
||||
}
|
||||
if (_pinnedBar) {
|
||||
_pinnedBar->hide();
|
||||
}
|
||||
if (_voiceRecordBar) {
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
hideChildren();
|
||||
}
|
||||
|
||||
void HistoryWidget::hideSelectorControlsAnimated() {
|
||||
_fieldAutocomplete->hideAnimated();
|
||||
if (_supportAutocomplete) {
|
||||
|
@ -3212,13 +3227,7 @@ void HistoryWidget::showAnimated(
|
|||
|
||||
_cacheOver = controller()->content()->grabForShowAnimation(params);
|
||||
|
||||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hideFast();
|
||||
}
|
||||
if (_pinnedBar) {
|
||||
_pinnedBar->hide();
|
||||
}
|
||||
hideChildren();
|
||||
hideChildWidgets();
|
||||
if (params.withTopBarShadow) _topShadow->show();
|
||||
|
||||
if (_showDirection == Window::SlideDirection::FromLeft) {
|
||||
|
|
|
@ -456,6 +456,7 @@ private:
|
|||
bool replyToNextMessage();
|
||||
[[nodiscard]] bool showSlowmodeError();
|
||||
|
||||
void hideChildWidgets();
|
||||
void hideSelectorControlsAnimated();
|
||||
int countMembersDropdownHeightMax() const;
|
||||
|
||||
|
|
|
@ -660,6 +660,9 @@ void ComposeControls::showStarted() {
|
|||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hideFast();
|
||||
}
|
||||
if (_voiceRecordBar) {
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
_wrap->hide();
|
||||
_writeRestricted->hide();
|
||||
}
|
||||
|
@ -671,6 +674,9 @@ void ComposeControls::showFinished() {
|
|||
if (_tabbedPanel) {
|
||||
_tabbedPanel->hideFast();
|
||||
}
|
||||
if (_voiceRecordBar) {
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
updateWrappingVisibility();
|
||||
_voiceRecordBar->orderControls();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ public:
|
|||
void requestPaintColor(float64 progress);
|
||||
void requestPaintProgress(float64 progress);
|
||||
void requestPaintLevel(quint16 level);
|
||||
void reset();
|
||||
|
||||
[[nodiscard]] rpl::producer<bool> actives() const;
|
||||
|
||||
|
@ -101,7 +100,6 @@ public:
|
|||
RecordLock(not_null<Ui::RpWidget*> parent);
|
||||
|
||||
void requestPaintProgress(float64 progress);
|
||||
void reset();
|
||||
|
||||
[[nodiscard]] rpl::producer<> locks() const;
|
||||
[[nodiscard]] bool isLocked() const;
|
||||
|
@ -161,26 +159,19 @@ bool RecordLevel::recordingAnimationCallback(crl::time now) {
|
|||
void RecordLevel::init() {
|
||||
const auto hasProgress = [](auto value) { return value != 0.; };
|
||||
|
||||
// Do not allow the widget to be shown from the outside.
|
||||
shownValue(
|
||||
) | rpl::start_with_next([=](bool shown) {
|
||||
const auto shouldShown = hasProgress(_showProgress.current());
|
||||
if (shown != shouldShown) {
|
||||
setVisible(shouldShown);
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
paintRequest(
|
||||
) | rpl::start_with_next([=](const QRect &clip) {
|
||||
Painter p(this);
|
||||
|
||||
drawProgress(p);
|
||||
|
||||
p.setOpacity(_showProgress.current());
|
||||
st::historyRecordVoiceActive.paintInCenter(p, rect());
|
||||
}, lifetime());
|
||||
|
||||
_showProgress.changes(
|
||||
) | rpl::map(hasProgress) | rpl::distinct_until_changed(
|
||||
rpl::merge(
|
||||
shownValue(),
|
||||
_showProgress.value() | rpl::map(hasProgress)
|
||||
) | rpl::start_with_next([=](bool show) {
|
||||
setVisible(show);
|
||||
setMouseTracking(show);
|
||||
|
@ -188,6 +179,7 @@ void RecordLevel::init() {
|
|||
_recordingLevel = anim::value();
|
||||
_recordingAnimation.stop();
|
||||
_showingLifetime.destroy();
|
||||
_showProgress = 0.;
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
|
@ -281,6 +273,7 @@ void RecordLock::init() {
|
|||
) | rpl::start_with_next([=](bool shown) {
|
||||
if (!shown) {
|
||||
_lockAnimation.stop();
|
||||
_lockEnderAnimation.stop();
|
||||
_progress = 0.;
|
||||
}
|
||||
}, lifetime());
|
||||
|
@ -433,6 +426,7 @@ VoiceRecordBar::VoiceRecordBar(
|
|||
, _cancelFont(st::historyRecordFont) {
|
||||
resize(QSize(parent->width(), recorderHeight));
|
||||
init();
|
||||
hideFast();
|
||||
}
|
||||
|
||||
VoiceRecordBar::VoiceRecordBar(
|
||||
|
@ -478,7 +472,6 @@ void VoiceRecordBar::updateLockGeometry() {
|
|||
}
|
||||
|
||||
void VoiceRecordBar::init() {
|
||||
hide();
|
||||
// Keep VoiceRecordBar behind SendButton.
|
||||
rpl::single(
|
||||
) | rpl::then(
|
||||
|
@ -490,6 +483,13 @@ void VoiceRecordBar::init() {
|
|||
orderControls();
|
||||
}, lifetime());
|
||||
|
||||
shownValue(
|
||||
) | rpl::start_with_next([=](bool show) {
|
||||
if (!show) {
|
||||
finish();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
_centerY = size.height() / 2;
|
||||
|
@ -556,7 +556,6 @@ void VoiceRecordBar::init() {
|
|||
_showLockAnimation.start(std::move(callback), from, to, duration);
|
||||
}, lifetime());
|
||||
|
||||
_lock->hide();
|
||||
_lock->locks(
|
||||
) | rpl::start_with_next([=] {
|
||||
installClickOutsideFilter();
|
||||
|
@ -746,27 +745,35 @@ void VoiceRecordBar::recordUpdated(quint16 level, int samples) {
|
|||
|
||||
void VoiceRecordBar::stop(bool send) {
|
||||
auto disappearanceCallback = [=] {
|
||||
_showAnimation.stop();
|
||||
|
||||
hide();
|
||||
_recording = false;
|
||||
|
||||
stopRecording(send);
|
||||
|
||||
_redCircleProgress = 0.;
|
||||
|
||||
_inField = false;
|
||||
|
||||
_recordingLifetime.destroy();
|
||||
_recordingSamples = 0;
|
||||
_sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 });
|
||||
|
||||
_controller->widget()->setInnerFocus();
|
||||
};
|
||||
_lockShowing = false;
|
||||
visibilityAnimate(false, std::move(disappearanceCallback));
|
||||
}
|
||||
|
||||
void VoiceRecordBar::finish() {
|
||||
_recordingLifetime.destroy();
|
||||
_lockShowing = false;
|
||||
_recording = false;
|
||||
_inField = false;
|
||||
_redCircleProgress = 0.;
|
||||
_recordingSamples = 0;
|
||||
|
||||
_showAnimation.stop();
|
||||
|
||||
_sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 });
|
||||
_controller->widget()->setInnerFocus();
|
||||
}
|
||||
|
||||
void VoiceRecordBar::hideFast() {
|
||||
hide();
|
||||
_lock->hide();
|
||||
_level->hide();
|
||||
stopRecording(false);
|
||||
}
|
||||
|
||||
void VoiceRecordBar::stopRecording(bool send) {
|
||||
using namespace ::Media::Capture;
|
||||
if (!send) {
|
||||
|
@ -880,12 +887,6 @@ float64 VoiceRecordBar::showAnimationRatio() const {
|
|||
return _showAnimation.value(1.);
|
||||
}
|
||||
|
||||
QString VoiceRecordBar::cancelMessage() const {
|
||||
return _lock->isLocked()
|
||||
? tr::lng_record_lock_cancel(tr::now)
|
||||
: tr::lng_record_cancel(tr::now);
|
||||
}
|
||||
|
||||
void VoiceRecordBar::computeAndSetLockProgress(QPoint globalPos) {
|
||||
const auto localPos = mapFromGlobal(globalPos);
|
||||
const auto lower = _lock->height();
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
|
||||
void startRecording();
|
||||
void finishAnimating();
|
||||
void hideFast();
|
||||
|
||||
void orderControls();
|
||||
|
||||
|
@ -68,7 +69,6 @@ private:
|
|||
void updateMessageGeometry();
|
||||
void updateLockGeometry();
|
||||
|
||||
void recordError();
|
||||
void recordUpdated(quint16 level, int samples);
|
||||
|
||||
bool recordingAnimationCallback(crl::time now);
|
||||
|
@ -81,7 +81,6 @@ private:
|
|||
void drawDuration(Painter &p);
|
||||
void drawRedCircle(Painter &p);
|
||||
void drawMessage(Painter &p, float64 recordActive);
|
||||
void updateOverStates(QPoint pos);
|
||||
|
||||
void startRedCircleAnimation();
|
||||
void installClickOutsideFilter();
|
||||
|
@ -89,14 +88,14 @@ private:
|
|||
bool isTypeRecord() const;
|
||||
bool hasDuration() const;
|
||||
|
||||
void finish();
|
||||
|
||||
void activeAnimate(bool active);
|
||||
float64 showAnimationRatio() const;
|
||||
float64 activeAnimationRatio() const;
|
||||
|
||||
void computeAndSetLockProgress(QPoint globalPos);
|
||||
|
||||
QString cancelMessage() const;
|
||||
|
||||
const not_null<Ui::RpWidget*> _sectionWidget;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
const std::shared_ptr<Ui::SendButton> _send;
|
||||
|
|
Loading…
Add table
Reference in a new issue