Fixed voice recording lock position on resizing.
This commit is contained in:
parent
cdb77d46b1
commit
4970740739
|
@ -236,26 +236,6 @@ VoiceRecordBar::~VoiceRecordBar() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoiceRecordBar::updateControlsGeometry(QSize size) {
|
|
||||||
_centerY = size.height() / 2;
|
|
||||||
{
|
|
||||||
const auto maxD = st::historyRecordSignalMax * 2;
|
|
||||||
const auto point = _centerY - st::historyRecordSignalMax;
|
|
||||||
_redCircleRect = { point, point, maxD, maxD };
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const auto durationLeft = _redCircleRect.x()
|
|
||||||
+ _redCircleRect.width()
|
|
||||||
+ st::historyRecordDurationSkip;
|
|
||||||
_durationRect = QRect(
|
|
||||||
durationLeft,
|
|
||||||
_redCircleRect.y(),
|
|
||||||
_cancelFont->width(FormatVoiceDuration(kMaxSamples)),
|
|
||||||
_redCircleRect.height());
|
|
||||||
}
|
|
||||||
updateMessageGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void VoiceRecordBar::updateMessageGeometry() {
|
void VoiceRecordBar::updateMessageGeometry() {
|
||||||
const auto left = _durationRect.x()
|
const auto left = _durationRect.x()
|
||||||
+ _durationRect.width()
|
+ _durationRect.width()
|
||||||
|
@ -276,6 +256,14 @@ void VoiceRecordBar::updateMessageGeometry() {
|
||||||
textHeight);
|
textHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoiceRecordBar::updateLockGeometry() {
|
||||||
|
const auto right = anim::interpolate(
|
||||||
|
-_lock->width(),
|
||||||
|
st::historyRecordLockPosition.x(),
|
||||||
|
_showLockAnimation.value(_lockShowing.current() ? 1. : 0.));
|
||||||
|
_lock->moveToRight(right, _lock->y());
|
||||||
|
}
|
||||||
|
|
||||||
void VoiceRecordBar::init() {
|
void VoiceRecordBar::init() {
|
||||||
hide();
|
hide();
|
||||||
// Keep VoiceRecordBar behind SendButton.
|
// Keep VoiceRecordBar behind SendButton.
|
||||||
|
@ -291,7 +279,25 @@ void VoiceRecordBar::init() {
|
||||||
|
|
||||||
sizeValue(
|
sizeValue(
|
||||||
) | rpl::start_with_next([=](QSize size) {
|
) | rpl::start_with_next([=](QSize size) {
|
||||||
updateControlsGeometry(size);
|
_centerY = size.height() / 2;
|
||||||
|
{
|
||||||
|
const auto maxD = st::historyRecordSignalMax * 2;
|
||||||
|
const auto point = _centerY - st::historyRecordSignalMax;
|
||||||
|
_redCircleRect = { point, point, maxD, maxD };
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const auto durationLeft = _redCircleRect.x()
|
||||||
|
+ _redCircleRect.width()
|
||||||
|
+ st::historyRecordDurationSkip;
|
||||||
|
const auto &ascent = _cancelFont->ascent;
|
||||||
|
_durationRect = QRect(
|
||||||
|
durationLeft,
|
||||||
|
_redCircleRect.y() - (ascent - _redCircleRect.height()) / 2,
|
||||||
|
_cancelFont->width(FormatVoiceDuration(kMaxSamples)),
|
||||||
|
ascent);
|
||||||
|
}
|
||||||
|
updateMessageGeometry();
|
||||||
|
updateLockGeometry();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
paintRequest(
|
paintRequest(
|
||||||
|
@ -326,11 +332,7 @@ void VoiceRecordBar::init() {
|
||||||
const auto duration = st::historyRecordLockShowDuration;
|
const auto duration = st::historyRecordLockShowDuration;
|
||||||
_lock->show();
|
_lock->show();
|
||||||
auto callback = [=](auto value) {
|
auto callback = [=](auto value) {
|
||||||
const auto right = anim::interpolate(
|
updateLockGeometry();
|
||||||
-_lock->width(),
|
|
||||||
st::historyRecordLockPosition.x(),
|
|
||||||
value);
|
|
||||||
_lock->moveToRight(right, _lock->y());
|
|
||||||
if (value == 0. && !show) {
|
if (value == 0. && !show) {
|
||||||
_lock->hide();
|
_lock->hide();
|
||||||
} else if (value == 1. && show) {
|
} else if (value == 1. && show) {
|
||||||
|
|
|
@ -54,8 +54,8 @@ public:
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void updateControlsGeometry(QSize size);
|
|
||||||
void updateMessageGeometry();
|
void updateMessageGeometry();
|
||||||
|
void updateLockGeometry();
|
||||||
|
|
||||||
void recordError();
|
void recordError();
|
||||||
void recordUpdated(quint16 level, int samples);
|
void recordUpdated(quint16 level, int samples);
|
||||||
|
|
Loading…
Reference in New Issue