Improve narrow topics column in forum.

This commit is contained in:
John Preston 2022-10-21 14:36:05 +04:00
parent ce17904dcc
commit eab23df174
4 changed files with 33 additions and 17 deletions

View file

@ -444,8 +444,16 @@ void ForumTopic::paintUserpic(
std::shared_ptr<Data::CloudImageView> &view,
const Dialogs::Ui::PaintContext &context) const {
const auto &st = context.st;
const auto position = QPoint(st->padding.left(), st->padding.top());
auto position = QPoint(st->padding.left(), st->padding.top());
if (_icon) {
if (context.narrow) {
const auto ratio = style::DevicePixelRatio();
const auto tag = Data::CustomEmojiManager::SizeTag::Normal;
const auto size = Data::FrameSizeFromTag(tag) / ratio;
position = QPoint(
(context.width - size) / 2,
(st->height - size) / 2);
}
_icon->paint(p, {
.preview = st::windowBgOver->c,
.now = context.now,
@ -455,11 +463,16 @@ void ForumTopic::paintUserpic(
} else {
validateDefaultIcon();
const auto size = st::defaultForumTopicIcon.size;
const auto esize = st::emojiSize;
const auto shift = (esize - size) / 2;
p.drawImage(
position + st::forumTopicIconPosition + QPoint(shift, 0),
_defaultIcon);
if (context.narrow) {
position = QPoint(
(context.width - size) / 2,
(st->height - size) / 2);
} else {
const auto esize = st::emojiSize;
const auto shift = (esize - size) / 2;
position += st::forumTopicIconPosition + QPoint(shift, 0);
}
p.drawImage(position, _defaultIcon);
}
}

View file

@ -309,7 +309,7 @@ void PaintRow(
}
auto nameleft = context.st->nameLeft;
if (context.width <= nameleft) {
if (context.narrow) {
if (!draft && item && !item->isEmpty()) {
PaintNarrowCounter(p, context, badgesState);
}

View file

@ -434,7 +434,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
}
void TopBarWidget::paintTopBar(Painter &p) {
if (!_activeChat.key) {
if (!_activeChat.key || _narrowMode) {
return;
}
auto nameleft = _leftTaken;
@ -855,6 +855,12 @@ void TopBarWidget::refreshInfoButton() {
}
void TopBarWidget::resizeEvent(QResizeEvent *e) {
const auto narrowMode = (_activeChat.section == Section::ChatsList)
&& (width() < _back->width() + _search->width());
if (_narrowMode != narrowMode) {
_narrowMode = narrowMode;
updateControlsVisibility();
}
updateSearchVisibility();
updateControlsGeometry();
}
@ -865,11 +871,7 @@ int TopBarWidget::countSelectedButtonsTop(float64 selectedShown) {
void TopBarWidget::updateSearchVisibility() {
const auto historyMode = (_activeChat.section == Section::History);
const auto smallDialogsColumn = _activeChat.key.folder()
&& (width() < _back->width() + _search->width());
_search->setVisible(historyMode
&& !smallDialogsColumn
&& !_chooseForReportReason);
_search->setVisible(historyMode && !_chooseForReportReason);
}
void TopBarWidget::updateControlsGeometry() {
@ -915,9 +917,7 @@ void TopBarWidget::updateControlsGeometry() {
} else if (_back->isHidden()) {
_leftTaken = st::topBarArrowPadding.right();
} else {
const auto smallDialogsColumn = _activeChat.key.folder()
&& (width() < _back->width() + _search->width());
_leftTaken = smallDialogsColumn ? (width() - _back->width()) / 2 : 0;
_leftTaken = _narrowMode ? (width() - _back->width()) / 2 : 0;
_back->moveToLeft(_leftTaken, otherButtonsTop);
_leftTaken += _back->width();
}
@ -1005,7 +1005,9 @@ void TopBarWidget::updateControlsVisibility() {
? (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
: false);
updateSearchVisibility();
_menuToggle->setVisible(hasMenu && !_chooseForReportReason);
_menuToggle->setVisible(hasMenu
&& !_chooseForReportReason
&& !_narrowMode);
_infoToggle->setVisible(historyMode
&& !_activeChat.key.folder()
&& !isOneColumn

View file

@ -195,6 +195,7 @@ private:
int _leftTaken = 0;
int _rightTaken = 0;
bool _animatingMode = false;
bool _narrowMode = false;
std::unique_ptr<Ui::InfiniteRadialAnimation> _connecting;
SendActionPainter *_sendAction = nullptr;