Fix _height value in inline bot result Gif layout.

This fixes render glitches in GIFs column with opened MediaView.
This commit is contained in:
John Preston 2017-12-18 18:10:24 +04:00
parent 977dee3599
commit 16ca2d39c5
3 changed files with 14 additions and 17 deletions

View File

@ -596,12 +596,13 @@ void GifsListWidget::layoutInlineRow(Row &row, int fullWidth) {
row.height = 0;
int availw = fullWidth - (st::inlineResultsLeft - st::buttonRadius);
for (int i = 0; i < count; ++i) {
int index = indices[i];
int w = desiredWidth
? (row.items[index]->maxWidth() * availw / desiredWidth)
: row.items[index]->maxWidth();
int actualw = qMax(w, int(st::inlineResultsMinWidth));
row.height = qMax(row.height, row.items[index]->resizeGetHeight(actualw));
const auto index = indices[i];
const auto &item = row.items[index];
const auto w = desiredWidth
? (item->maxWidth() * availw / desiredWidth)
: item->maxWidth();
auto actualw = qMax(w, st::inlineResultsMinWidth);
row.height = qMax(row.height, item->resizeGetHeight(actualw));
if (desiredWidth) {
availw -= actualw;
desiredWidth -= row.items[index]->maxWidth();

View File

@ -134,6 +134,12 @@ void DeleteSavedGifClickHandler::onClickImpl() const {
Auth().data().markSavedGifsUpdated();
}
int Gif::resizeGetHeight(int width) {
_width = width;
_height = _minh;
return _height;
}
void Gif::paint(Painter &p, const QRect &clip, const PaintContext *context) const {
DocumentData *document = getShownDocument();
document->automaticLoad(nullptr);
@ -921,12 +927,6 @@ void Contact::initDimensions() {
_minh += st::inlineRowMargin * 2 + st::inlineRowBorder;
}
int32 Contact::resizeGetHeight(int32 width) {
_width = qMin(width, _maxw);
_height = _minh;
return _height;
}
void Contact::paint(Painter &p, const QRect &clip, const PaintContext *context) const {
int32 left = st::emojiPanHeaderLeft - st::inlineResultsLeft;

View File

@ -80,10 +80,7 @@ public:
// ClickHandlerHost interface
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
int resizeGetHeight(int width) override {
_width = width;
return _minh;
}
int resizeGetHeight(int width) override;
private:
QSize countFrameSize() const;
@ -306,7 +303,6 @@ public:
Contact(not_null<Context*> context, Result *result);
void initDimensions() override;
int resizeGetHeight(int width) override;
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
HistoryTextState getState(