Improve stickers list variable width support.

This commit is contained in:
John Preston 2017-11-14 12:15:14 +04:00
parent 7db80d20f1
commit defa0ae4d0
6 changed files with 53 additions and 14 deletions

View File

@ -29,7 +29,7 @@ switchPmButton: RoundButton(defaultBoxButton) {
textTop: 7px;
}
stickersRestrictedLabel: FlatLabel(defaultFlatLabel) {
minWidth: 320px;
minWidth: 200px;
align: align(center);
textFg: noContactsColor;
}

View File

@ -493,6 +493,10 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
void StickersListWidget::visibleTopBottomUpdated(
int visibleTop,
int visibleBottom) {
if (!_columnCount) {
return;
}
auto top = getVisibleTop();
Inner::visibleTopBottomUpdated(visibleTop, visibleBottom);
if (_section == Section::Featured) {
@ -831,7 +835,9 @@ void StickersListWidget::paintMegagroupEmptySet(Painter &p, int y, bool buttonSe
auto infoLeft = megagroupSetInfoLeft();
_megagroupSetAbout.drawLeft(p, infoLeft, y, width() - infoLeft, width());
auto &textBg = buttonSelected ? st::stickerGroupCategoryAdd.textBgOver : st::stickerGroupCategoryAdd.textBg;
auto &textBg = buttonSelected
? st::stickerGroupCategoryAdd.textBgOver
: st::stickerGroupCategoryAdd.textBg;
auto button = _megagroupSetButtonRect.translated(0, y);
App::roundRect(p, myrtlrect(button), textBg, ImageRoundRadius::Small);
@ -1146,6 +1152,9 @@ void StickersListWidget::resizeEvent(QResizeEvent *e) {
_settings->moveToLeft(
(width() - _settings->width()) / 2,
height() / 3);
if (!_megagroupSetAbout.isEmpty()) {
refreshMegagroupSetGeometry();
}
}
void StickersListWidget::leaveEventHook(QEvent *e) {
@ -1213,14 +1222,19 @@ void StickersListWidget::refreshStickers() {
if (_footer && _columnCount > 0) {
refreshFooterIcons();
}
_settings->setVisible(_section == Section::Stickers && _mySets.isEmpty());
refreshSettingsVisibility();
_lastMousePosition = QCursor::pos();
updateSelected();
update();
}
void StickersListWidget::refreshSettingsVisibility() {
auto visible = (_section == Section::Stickers)
&& _mySets.isEmpty();
_settings->setVisible(visible);
}
void StickersListWidget::refreshFooterIcons() {
Expects(_columnCount > 0);
@ -1566,6 +1580,8 @@ void StickersListWidget::setSelected(OverState newSelected) {
} else {
rtlupdate(removeButtonRect(button->section));
}
} else if (base::get_if<OverGroupAdd>(&_selected)) {
rtlupdate(megagroupSetButtonRectFinal());
}
};
updateSelected();
@ -1607,6 +1623,7 @@ void StickersListWidget::showStickerSet(uint64 setId) {
_section = Section::Featured;
refreshRecentStickers(true);
refreshSettingsVisibility();
if (_footer) {
_footer->refreshIcons(ValidateIconAnimations::Scroll);
}
@ -1622,6 +1639,7 @@ void StickersListWidget::showStickerSet(uint64 setId) {
if (needRefresh) {
_section = Section::Stickers;
refreshRecentStickers(true);
refreshSettingsVisibility();
}
auto y = 0;
@ -1659,7 +1677,9 @@ void StickersListWidget::showMegagroupSet(ChannelData *megagroup) {
_megagroupSet = megagroup;
if (_megagroupSetAbout.isEmpty()) {
_megagroupSetAbout.setText(st::stickerGroupCategoryAbout, lang(lng_group_stickers_description));
_megagroupSetAbout.setText(
st::stickerGroupCategoryAbout,
lang(lng_group_stickers_description));
_megagroupSetButtonText = lang(lng_group_stickers_add).toUpper();
refreshMegagroupSetGeometry();
}

View File

@ -167,6 +167,7 @@ private:
Hidden,
};
void refreshMegagroupStickers(GroupStickersPlace place);
void refreshSettingsVisibility();
void updateSelected();
void setSelected(OverState newSelected);

View File

@ -386,9 +386,7 @@ void TabbedSelector::resizeEvent(QResizeEvent *e) {
updateScrollGeometry();
}
_bottomShadow->setGeometry(_tabsSlider->x(), _scroll->y() + _scroll->height() - st::lineWidth, _tabsSlider->width(), st::lineWidth);
if (_restrictedLabel) {
_restrictedLabel->move((width() - _restrictedLabel->width()), (height() / 3 - _restrictedLabel->height() / 2));
}
updateRestrictedLabelGeometry();
_footerTop = height() - st::emojiFooterHeight;
for (auto &tab : _tabs) {
@ -399,6 +397,18 @@ void TabbedSelector::resizeEvent(QResizeEvent *e) {
update();
}
void TabbedSelector::updateRestrictedLabelGeometry() {
if (!_restrictedLabel) {
return;
}
auto labelWidth = width() - st::stickerPanPadding * 2;
_restrictedLabel->resizeToWidth(labelWidth);
_restrictedLabel->moveToLeft(
(width() - _restrictedLabel->width()) / 2,
(height() / 3 - _restrictedLabel->height() / 2));
}
void TabbedSelector::paintEvent(QPaintEvent *e) {
Painter p(this);
@ -554,11 +564,18 @@ void TabbedSelector::checkRestrictedPeer() {
(_currentTabType == SelectorTab::Gifs) ? megagroup->restricted(ChannelRestriction::f_send_gifs) : false;
if (restricted) {
if (!_restrictedLabel) {
auto text = (_currentTabType == SelectorTab::Stickers) ? lang(lng_restricted_send_stickers) :
(_currentTabType == SelectorTab::Gifs) ? lang(lng_restricted_send_gifs) : QString();
_restrictedLabel.create(this, text, Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel);
auto text = (_currentTabType == SelectorTab::Stickers)
? lang(lng_restricted_send_stickers)
: (_currentTabType == SelectorTab::Gifs)
? lang(lng_restricted_send_gifs)
: QString();
_restrictedLabel.create(
this,
text,
Ui::FlatLabel::InitType::Simple,
st::stickersRestrictedLabel);
_restrictedLabel->show();
_restrictedLabel->move((width() - _restrictedLabel->width()), (height() / 3 - _restrictedLabel->height() / 2));
updateRestrictedLabelGeometry();
currentTab()->footer()->hide();
_scroll->hide();
_bottomShadow->hide();

View File

@ -155,6 +155,7 @@ private:
void checkRestrictedPeer();
bool isRestrictedView();
void updateRestrictedLabelGeometry();
QImage grabForAnimation();

View File

@ -185,11 +185,11 @@ bool Controller::takeThirdSectionFromLayer() {
}
void Controller::resizeForThirdSection() {
auto layout = computeColumnLayout();
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
if (Adaptive::ThreeColumn()) {
return;
}
auto layout = computeColumnLayout();
auto tabbedSelectorSectionEnabled =
Auth().data().tabbedSelectorSectionEnabled();
auto thirdSectionInfoEnabled =