Refactored column width in SingleMediaPreview.
This commit is contained in:
parent
96b40f43e9
commit
116aa01e51
|
@ -131,9 +131,13 @@ void SingleMediaPreview::preparePreview(
|
||||||
auto maxthumbh = qMin(qRound(1.5 * _previewWidth), st::confirmMaxHeight);
|
auto maxthumbh = qMin(qRound(1.5 * _previewWidth), st::confirmMaxHeight);
|
||||||
const auto minthumbh = st::sendBoxAlbumGroupSize.height()
|
const auto minthumbh = st::sendBoxAlbumGroupSize.height()
|
||||||
+ st::sendBoxAlbumGroupSkipTop * 2;
|
+ st::sendBoxAlbumGroupSkipTop * 2;
|
||||||
_previewHeight = qRound(originalHeight * float64(_previewWidth) / originalWidth);
|
_previewHeight = qRound(originalHeight
|
||||||
|
* float64(_previewWidth)
|
||||||
|
/ originalWidth);
|
||||||
if (_previewHeight > maxthumbh) {
|
if (_previewHeight > maxthumbh) {
|
||||||
_previewWidth = qRound(_previewWidth * float64(maxthumbh) / _previewHeight);
|
_previewWidth = qRound(_previewWidth
|
||||||
|
* float64(maxthumbh)
|
||||||
|
/ _previewHeight);
|
||||||
accumulate_max(_previewWidth, kMinPreviewWidth);
|
accumulate_max(_previewWidth, kMinPreviewWidth);
|
||||||
_previewHeight = maxthumbh;
|
_previewHeight = maxthumbh;
|
||||||
} else if (_previewHeight < minthumbh) {
|
} else if (_previewHeight < minthumbh) {
|
||||||
|
@ -194,7 +198,8 @@ void SingleMediaPreview::prepareAnimatedPreview(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleMediaPreview::clipCallback(Media::Clip::Notification notification) {
|
void SingleMediaPreview::clipCallback(
|
||||||
|
Media::Clip::Notification notification) {
|
||||||
using namespace Media::Clip;
|
using namespace Media::Clip;
|
||||||
switch (notification) {
|
switch (notification) {
|
||||||
case NotificationReinit: {
|
case NotificationReinit: {
|
||||||
|
@ -204,7 +209,13 @@ void SingleMediaPreview::clipCallback(Media::Clip::Notification notification) {
|
||||||
|
|
||||||
if (_gifPreview && _gifPreview->ready() && !_gifPreview->started()) {
|
if (_gifPreview && _gifPreview->ready() && !_gifPreview->started()) {
|
||||||
auto s = QSize(_previewWidth, _previewHeight);
|
auto s = QSize(_previewWidth, _previewHeight);
|
||||||
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None);
|
_gifPreview->start(
|
||||||
|
s.width(),
|
||||||
|
s.height(),
|
||||||
|
s.width(),
|
||||||
|
s.height(),
|
||||||
|
ImageRoundRadius::None,
|
||||||
|
RectPart::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -223,16 +234,37 @@ void SingleMediaPreview::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
if (!_sticker) {
|
if (!_sticker) {
|
||||||
if (_previewLeft > st::boxPhotoPadding.left()) {
|
if (_previewLeft > st::boxPhotoPadding.left()) {
|
||||||
p.fillRect(st::boxPhotoPadding.left(), 0, _previewLeft - st::boxPhotoPadding.left(), _previewHeight, st::confirmBg);
|
p.fillRect(
|
||||||
|
st::boxPhotoPadding.left(),
|
||||||
|
0,
|
||||||
|
_previewLeft - st::boxPhotoPadding.left(),
|
||||||
|
_previewHeight,
|
||||||
|
st::confirmBg);
|
||||||
}
|
}
|
||||||
if (_previewLeft + _previewWidth < width() - st::boxPhotoPadding.right()) {
|
if ((_previewLeft + _previewWidth)
|
||||||
p.fillRect(_previewLeft + _previewWidth, 0, width() - st::boxPhotoPadding.right() - _previewLeft - _previewWidth, _previewHeight, st::confirmBg);
|
< (width() - st::boxPhotoPadding.right())) {
|
||||||
|
p.fillRect(
|
||||||
|
_previewLeft + _previewWidth,
|
||||||
|
0,
|
||||||
|
width()
|
||||||
|
- st::boxPhotoPadding.right()
|
||||||
|
- _previewLeft
|
||||||
|
- _previewWidth,
|
||||||
|
_previewHeight,
|
||||||
|
st::confirmBg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_gifPreview && _gifPreview->started()) {
|
if (_gifPreview && _gifPreview->started()) {
|
||||||
auto s = QSize(_previewWidth, _previewHeight);
|
auto s = QSize(_previewWidth, _previewHeight);
|
||||||
auto paused = _gifPaused();
|
auto paused = _gifPaused();
|
||||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : crl::now());
|
auto frame = _gifPreview->current(
|
||||||
|
s.width(),
|
||||||
|
s.height(),
|
||||||
|
s.width(),
|
||||||
|
s.height(),
|
||||||
|
ImageRoundRadius::None,
|
||||||
|
RectPart::None,
|
||||||
|
paused ? 0 : crl::now());
|
||||||
p.drawPixmap(_previewLeft, 0, frame);
|
p.drawPixmap(_previewLeft, 0, frame);
|
||||||
} else if (_lottiePreview && _lottiePreview->ready()) {
|
} else if (_lottiePreview && _lottiePreview->ready()) {
|
||||||
const auto frame = _lottiePreview->frame();
|
const auto frame = _lottiePreview->frame();
|
||||||
|
@ -250,7 +282,11 @@ void SingleMediaPreview::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
if (_animated && !_gifPreview && !_lottiePreview) {
|
if (_animated && !_gifPreview && !_lottiePreview) {
|
||||||
const auto innerSize = st::msgFileLayout.thumbSize;
|
const auto innerSize = st::msgFileLayout.thumbSize;
|
||||||
auto inner = QRect(_previewLeft + (_previewWidth - innerSize) / 2, (_previewHeight - innerSize) / 2, innerSize, innerSize);
|
auto inner = QRect(
|
||||||
|
_previewLeft + (_previewWidth - innerSize) / 2,
|
||||||
|
(_previewHeight - innerSize) / 2,
|
||||||
|
innerSize,
|
||||||
|
innerSize);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::msgDateImgBg);
|
p.setBrush(st::msgDateImgBg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue