mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix media with caption in a narrow window.
This commit is contained in:
parent
2e8a03dfd1
commit
e2bca0a7ff
3 changed files with 7 additions and 5 deletions
|
@ -123,12 +123,13 @@ QSize ExtendedPreview::countOptimalSize() {
|
||||||
QSize ExtendedPreview::countCurrentSize(int newWidth) {
|
QSize ExtendedPreview::countCurrentSize(int newWidth) {
|
||||||
const auto &preview = _invoice->extendedPreview;
|
const auto &preview = _invoice->extendedPreview;
|
||||||
const auto dimensions = preview.dimensions;
|
const auto dimensions = preview.dimensions;
|
||||||
|
const auto thumbMaxWidth = std::min(newWidth, st::maxMediaSize);
|
||||||
const auto minWidth = std::clamp(
|
const auto minWidth = std::clamp(
|
||||||
_parent->minWidthForMedia(),
|
_parent->minWidthForMedia(),
|
||||||
(_parent->hasBubble()
|
(_parent->hasBubble()
|
||||||
? st::historyPhotoBubbleMinWidth
|
? st::historyPhotoBubbleMinWidth
|
||||||
: st::minPhotoSize),
|
: st::minPhotoSize),
|
||||||
std::min(newWidth, st::maxMediaSize));
|
thumbMaxWidth);
|
||||||
const auto scaled = (preview.videoDuration >= 0)
|
const auto scaled = (preview.videoDuration >= 0)
|
||||||
? CountMediaSize(
|
? CountMediaSize(
|
||||||
CountDesiredMediaSize(dimensions),
|
CountDesiredMediaSize(dimensions),
|
||||||
|
@ -145,7 +146,7 @@ QSize ExtendedPreview::countCurrentSize(int newWidth) {
|
||||||
(st::msgPadding.left()
|
(st::msgPadding.left()
|
||||||
+ _caption.maxWidth()
|
+ _caption.maxWidth()
|
||||||
+ st::msgPadding.right()));
|
+ st::msgPadding.right()));
|
||||||
newWidth = qMax(newWidth, maxWithCaption);
|
newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth);
|
||||||
const auto captionw = newWidth
|
const auto captionw = newWidth
|
||||||
- st::msgPadding.left()
|
- st::msgPadding.left()
|
||||||
- st::msgPadding.right();
|
- st::msgPadding.right();
|
||||||
|
|
|
@ -207,7 +207,7 @@ QSize Gif::countCurrentSize(int newWidth) {
|
||||||
(st::msgPadding.left()
|
(st::msgPadding.left()
|
||||||
+ _caption.maxWidth()
|
+ _caption.maxWidth()
|
||||||
+ st::msgPadding.right()));
|
+ st::msgPadding.right()));
|
||||||
newWidth = qMax(newWidth, maxWithCaption);
|
newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth);
|
||||||
const auto captionw = newWidth
|
const auto captionw = newWidth
|
||||||
- st::msgPadding.left()
|
- st::msgPadding.left()
|
||||||
- st::msgPadding.right();
|
- st::msgPadding.right();
|
||||||
|
|
|
@ -176,10 +176,11 @@ QSize Photo::countCurrentSize(int newWidth) {
|
||||||
if (_serviceWidth) {
|
if (_serviceWidth) {
|
||||||
return { _serviceWidth, _serviceWidth };
|
return { _serviceWidth, _serviceWidth };
|
||||||
}
|
}
|
||||||
|
const auto thumbMaxWidth = qMin(newWidth, st::maxMediaSize);
|
||||||
const auto minWidth = std::clamp(
|
const auto minWidth = std::clamp(
|
||||||
_parent->minWidthForMedia(),
|
_parent->minWidthForMedia(),
|
||||||
(_parent->hasBubble() ? st::historyPhotoBubbleMinWidth : st::minPhotoSize),
|
(_parent->hasBubble() ? st::historyPhotoBubbleMinWidth : st::minPhotoSize),
|
||||||
std::min(newWidth, st::maxMediaSize));
|
thumbMaxWidth);
|
||||||
auto pix = CountPhotoMediaSize(
|
auto pix = CountPhotoMediaSize(
|
||||||
CountDesiredMediaSize({ _data->width(), _data->height() }),
|
CountDesiredMediaSize({ _data->width(), _data->height() }),
|
||||||
newWidth,
|
newWidth,
|
||||||
|
@ -192,7 +193,7 @@ QSize Photo::countCurrentSize(int newWidth) {
|
||||||
(st::msgPadding.left()
|
(st::msgPadding.left()
|
||||||
+ _caption.maxWidth()
|
+ _caption.maxWidth()
|
||||||
+ st::msgPadding.right()));
|
+ st::msgPadding.right()));
|
||||||
newWidth = qMax(newWidth, maxWithCaption);
|
newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth);
|
||||||
const auto captionw = newWidth
|
const auto captionw = newWidth
|
||||||
- st::msgPadding.left()
|
- st::msgPadding.left()
|
||||||
- st::msgPadding.right();
|
- st::msgPadding.right();
|
||||||
|
|
Loading…
Add table
Reference in a new issue