From 866ff628b72011b895bc5819e2082803707deeba Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 12 Nov 2017 21:46:20 +0400 Subject: [PATCH] Fix render bug, enable wide third column. --- .../chat_helpers/stickers_list_widget.cpp | 31 ++++++++++++++----- .../chat_helpers/stickers_list_widget.h | 2 ++ .../info/profile/info_profile_cover.cpp | 5 ++- .../info/profile/info_profile_cover.h | 2 +- .../profile/info_profile_inner_widget.cpp | 2 +- Telegram/SourceFiles/window/window.style | 3 +- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index e10dfc7e27..d24137894a 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -588,16 +588,18 @@ int StickersListWidget::countDesiredHeight(int newWidth) { return 0; } auto availableWidth = newWidth - (st::stickerPanPadding - st::buttonRadius); - _columnCount = availableWidth / st::stickerPanWidthMin; - auto singleWidth = availableWidth / _columnCount; + auto columnCount = availableWidth / st::stickerPanWidthMin; + auto singleWidth = availableWidth / columnCount; auto fullWidth = (st::buttonRadius + newWidth + st::emojiScroll.width); - auto rowsRight = (fullWidth - _columnCount * singleWidth) / 2; + auto rowsRight = (fullWidth - columnCount * singleWidth) / 2; accumulate_max(rowsRight, st::emojiScroll.width); _rowsLeft = fullWidth - - _columnCount * singleWidth + - columnCount * singleWidth - rowsRight - st::buttonRadius; _singleSize = QSize(singleWidth, singleWidth); + setColumnCount(columnCount); + auto visibleHeight = minimalHeight(); auto minimalLastHeight = (visibleHeight - st::stickerPanPadding); auto countResult = [this, minimalLastHeight] { @@ -1120,6 +1122,13 @@ void StickersListWidget::removeFavedSticker(int section, int index) { MTP::send(MTPmessages_FaveSticker(sticker->mtpInput(), MTP_bool(unfave))); } +void StickersListWidget::setColumnCount(int count) { + if (_columnCount != count) { + _columnCount = count; + refreshFooterIcons(); + } +} + void StickersListWidget::mouseMoveEvent(QMouseEvent *e) { _lastMousePosition = e->globalPos(); updateSelected(); @@ -1194,10 +1203,7 @@ void StickersListWidget::refreshStickers() { resizeToWidth(width()); if (_footer && _columnCount > 0) { - _footer->refreshIcons(ValidateIconAnimations::None); - if (_footer->hasOnlyFeaturedSets() && _section != Section::Featured) { - showStickerSet(Stickers::FeaturedSetId); - } + refreshFooterIcons(); } _settings->setVisible(_section == Section::Stickers && _mySets.isEmpty()); @@ -1207,6 +1213,15 @@ void StickersListWidget::refreshStickers() { update(); } +void StickersListWidget::refreshFooterIcons() { + Expects(_columnCount > 0); + + _footer->refreshIcons(ValidateIconAnimations::None); + if (_footer->hasOnlyFeaturedSets() && _section != Section::Featured) { + showStickerSet(Stickers::FeaturedSetId); + } +} + void StickersListWidget::preloadImages() { auto &sets = shownSets(); for (int i = 0, l = sets.size(), k = 0; i < l; ++i) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index 9df4eb3ec8..874b95c947 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -217,6 +217,8 @@ private: void removeRecentSticker(int section, int index); void removeFavedSticker(int section, int index); + void setColumnCount(int count); + void refreshFooterIcons(); ChannelData *_megagroupSet = nullptr; Sets _mySets; diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index b7eb16caa5..cb61194c87 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -184,9 +184,12 @@ SectionWithToggle *SectionWithToggle::setToggleShown( return this; } -void SectionWithToggle::toggle(bool toggled) { +void SectionWithToggle::toggle(bool toggled, anim::type animated) { if (_toggle) { _toggle->setChecked(toggled); + if (animated == anim::type::instant) { + _toggle->finishAnimating(); + } } } diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.h b/Telegram/SourceFiles/info/profile/info_profile_cover.h index 320d06a653..b157c5fe67 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.h +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.h @@ -45,7 +45,7 @@ public: using FixedHeightWidget::FixedHeightWidget; SectionWithToggle *setToggleShown(rpl::producer &&shown); - void toggle(bool toggled); + void toggle(bool toggled, anim::type animated); bool toggled() const; rpl::producer toggledValue() const; diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index caa808b128..e3446e97b2 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -245,7 +245,7 @@ void InnerWidget::saveState(not_null memento) { } void InnerWidget::restoreState(not_null memento) { - _cover->toggle(memento->infoExpanded()); + _cover->toggle(memento->infoExpanded(), anim::type::instant); if (_members) { _members->restoreState(memento); } diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index c1c1114b21..40353344f3 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -33,8 +33,9 @@ windowShadowShift: 1px; columnMinimalWidthLeft: 260px; columnMaximalWidthLeft: 540px; columnMinimalWidthMain: 380px; +columnDesiredWidthMain: 512px; columnMinimalWidthThird: 292px;//345px; -columnMaximalWidthThird: 345px; +columnMaximalWidthThird: 430px;//345px; adaptiveChatWideWidth: 880px;