2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 06:55:58 +00:00

Improve grouped files layout in chat.

This commit is contained in:
John Preston
2020-10-19 18:37:59 +03:00
parent 012ebdd15e
commit 263d6a30f2
26 changed files with 343 additions and 264 deletions

View File

@@ -158,11 +158,12 @@ EditCaptionBox::EditCaptionBox(
_thumbw = 0;
_thumbnailImageLoaded = true;
} else {
const auto thumbSize = st::msgFileThumbLayout.thumbSize;
const auto tw = dimensions.width(), th = dimensions.height();
if (tw > th) {
_thumbw = (tw * st::msgFileThumbSize) / th;
_thumbw = (tw * thumbSize) / th;
} else {
_thumbw = st::msgFileThumbSize;
_thumbw = thumbSize;
}
_refreshThumbnail = [=] {
const auto image = computeImage();
@@ -180,8 +181,8 @@ EditCaptionBox::EditCaptionBox(
_thumbw * cIntRetinaFactor(),
0,
options,
st::msgFileThumbSize,
st::msgFileThumbSize));
thumbSize,
thumbSize));
_thumbnailImageLoaded = true;
};
_refreshThumbnail();
@@ -355,8 +356,8 @@ EditCaptionBox::EditCaptionBox(
this,
object_ptr<Ui::Checkbox>(
this,
tr::lng_send_file(tr::now),
false,
tr::lng_send_compressed(tr::now),
true,
st::defaultBoxCheckbox),
st::editMediaCheckboxMargins);
_wayWrap = r.data();
@@ -364,7 +365,7 @@ EditCaptionBox::EditCaptionBox(
r->entity()->checkedChanges(
) | rpl::start_with_next([&](bool checked) {
_asFile = checked;
_asFile = !checked;
}, _wayWrap->lifetime());
_controller->session().data().itemRemoved(
@@ -813,12 +814,11 @@ void EditCaptionBox::updateBoxSize() {
if (_photo) {
newHeight += _wayWrap->height() / 2;
}
const auto &st = _thumbw ? st::msgFileThumbLayout : st::msgFileLayout;
if (_photo || _animated) {
newHeight += std::max(_thumbh, _gifh);
} else if (_thumbw) {
newHeight += 0 + st::msgFileThumbSize + 0;
} else if (_doc) {
newHeight += 0 + st::msgFileSize + 0;
} else if (_thumbw || _doc) {
newHeight += 0 + st.thumbSize + 0;
} else {
newHeight += st::boxTitleFont->height;
}
@@ -887,7 +887,8 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
p.drawPixmap(_thumbx, st::boxPhotoPadding.top() + offset, _thumb);
}
if (_animated && !_streamed) {
QRect inner(_thumbx + (_thumbw - st::msgFileSize) / 2, st::boxPhotoPadding.top() + (th - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize);
const auto &st = st::msgFileLayout;
QRect inner(_thumbx + (_thumbw - st.thumbSize) / 2, st::boxPhotoPadding.top() + (th - st.thumbSize) / 2, st.thumbSize, st.thumbSize);
p.setPen(Qt::NoPen);
p.setBrush(st::msgDateImgBg);
@@ -900,20 +901,13 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
icon->paintInCenter(p, inner);
}
} else if (_doc) {
const auto &st = _thumbw ? st::msgFileThumbLayout : st::msgFileLayout;
const auto w = width() - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
const auto h = _thumbw ? (0 + st::msgFileThumbSize + 0) : (0 + st::msgFileSize + 0);
auto nameleft = 0, nametop = 0, nameright = 0, statustop = 0;
if (_thumbw) {
nameleft = 0 + st::msgFileThumbSize + st::msgFileThumbPadding.right();
nametop = st::msgFileThumbNameTop - st::msgFileThumbPadding.top();
nameright = 0;
statustop = st::msgFileThumbStatusTop - st::msgFileThumbPadding.top();
} else {
nameleft = 0 + st::msgFileSize + st::msgFilePadding.right();
nametop = st::msgFileNameTop - st::msgFilePadding.top();
nameright = 0;
statustop = st::msgFileStatusTop - st::msgFilePadding.top();
}
const auto h = 0 + st.thumbSize + 0;
const auto nameleft = 0 + st.thumbSize + st.padding.right();
const auto nametop = st.nameTop - st.padding.top();
const auto nameright = 0;
const auto statustop = st.statusTop - st.padding.top();
const auto editButton = _isAllowedEditMedia
? _editMedia->width() + st::editMediaButtonSkip
: 0;
@@ -922,21 +916,20 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
// Ui::FillRoundCorner(p, x, y, w, h, st::msgInBg, Ui::MessageInCorners, &st::msgInShadow);
const auto rthumb = style::rtlrect(x + 0, y + 0, st.thumbSize, st.thumbSize, width());
if (_thumbw) {
QRect rthumb(style::rtlrect(x + 0, y + 0, st::msgFileThumbSize, st::msgFileThumbSize, width()));
p.drawPixmap(rthumb.topLeft(), _thumb);
} else {
const QRect inner(style::rtlrect(x + 0, y + 0, st::msgFileSize, st::msgFileSize, width()));
p.setPen(Qt::NoPen);
p.setBrush(st::msgFileInBg);
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(inner);
p.drawEllipse(rthumb);
}
const auto icon = &(_isAudio ? st::historyFileInPlay : _isImage ? st::historyFileInImage : st::historyFileInDocument);
icon->paintInCenter(p, inner);
icon->paintInCenter(p, rthumb);
}
p.setFont(st::semiboldFont);
p.setPen(st::historyFileNameInFg);