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; textTop: 7px;
} }
stickersRestrictedLabel: FlatLabel(defaultFlatLabel) { stickersRestrictedLabel: FlatLabel(defaultFlatLabel) {
minWidth: 320px; minWidth: 200px;
align: align(center); align: align(center);
textFg: noContactsColor; textFg: noContactsColor;
} }

View File

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

View File

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

View File

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

View File

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

View File

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