mirror of https://github.com/procxx/kepka.git
Improve positioning of chat helper panels.
This commit is contained in:
parent
ffc9585196
commit
78d245c02c
|
@ -6546,7 +6546,7 @@ void HistoryWidget::moveFieldControls() {
|
||||||
if (_inlineResults) {
|
if (_inlineResults) {
|
||||||
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
||||||
}
|
}
|
||||||
_emojiPanel->moveBottom(_field->y() - st::historySendPadding);
|
_emojiPanel->moveBottom(buttonsBottom);
|
||||||
|
|
||||||
auto fullWidthButtonRect = QRect(0, bottom - _botStart->height(), width(), _botStart->height());
|
auto fullWidthButtonRect = QRect(0, bottom - _botStart->height(), width(), _botStart->height());
|
||||||
_botStart->setGeometry(fullWidthButtonRect);
|
_botStart->setGeometry(fullWidthButtonRect);
|
||||||
|
@ -7215,12 +7215,6 @@ void HistoryWidget::updateControlsGeometry() {
|
||||||
|
|
||||||
updateHistoryDownPosition();
|
updateHistoryDownPosition();
|
||||||
|
|
||||||
_emojiPanel->setMinTop(0);
|
|
||||||
_emojiPanel->setMinBottom(_attachEmoji->height());
|
|
||||||
if (_inlineResults) {
|
|
||||||
_inlineResults->setMinTop(0);
|
|
||||||
_inlineResults->setMinBottom(_attachEmoji->height());
|
|
||||||
}
|
|
||||||
if (_membersDropdown) {
|
if (_membersDropdown) {
|
||||||
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax());
|
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ constexpr auto kInlineBotRequestDelay = 400;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Inner::Inner(QWidget *parent) : TWidget(parent) {
|
Inner::Inner(QWidget *parent) : TWidget(parent) {
|
||||||
setMaxHeight(st::emojiPanMaxHeight - st::emojiCategory.height);
|
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, st::emojiPanMinHeight);
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
@ -75,16 +75,15 @@ void Inner::setVisibleTopBottom(int visibleTop, int visibleBottom) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Inner::countHeight(bool plain) {
|
int Inner::countHeight() {
|
||||||
auto result = st::stickerPanPadding;
|
auto result = st::stickerPanPadding;
|
||||||
auto minLastH = plain ? 0 : (_maxHeight - st::stickerPanPadding);
|
|
||||||
if (_switchPmButton) {
|
if (_switchPmButton) {
|
||||||
result += _switchPmButton->height() + st::inlineResultsSkip;
|
result += _switchPmButton->height() + st::inlineResultsSkip;
|
||||||
}
|
}
|
||||||
for (int i = 0, l = _rows.count(); i < l; ++i) {
|
for (int i = 0, l = _rows.count(); i < l; ++i) {
|
||||||
result += _rows[i].height;
|
result += _rows[i].height;
|
||||||
}
|
}
|
||||||
return qMax(minLastH, result) + st::stickerPanPadding;
|
return result + st::stickerPanPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inner::~Inner() = default;
|
Inner::~Inner() = default;
|
||||||
|
@ -437,7 +436,7 @@ int Inner::refreshInlineRows(UserData *bot, const CacheEntry *entry, bool result
|
||||||
inlineRowFinalize(row, sumWidth, true);
|
inlineRowFinalize(row, sumWidth, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 h = countHeight();
|
auto h = countHeight();
|
||||||
if (h != height()) resize(width(), h);
|
if (h != height()) resize(width(), h);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
@ -544,7 +543,7 @@ bool Inner::inlineItemVisible(const ItemBase *layout) {
|
||||||
top += _rows.at(i).height;
|
top += _rows.at(i).height;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (top < _visibleTop + _maxHeight) && (top + _rows[row].items[col]->height() > _visibleTop);
|
return (top < _visibleBottom) && (top + _rows[row].items[col]->height() > _visibleTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inner::updateSelected() {
|
void Inner::updateSelected() {
|
||||||
|
@ -698,28 +697,18 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setMinTop(int minTop) {
|
|
||||||
_minTop = minTop;
|
|
||||||
updateContentHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::setMinBottom(int minBottom) {
|
|
||||||
_minBottom = minBottom;
|
|
||||||
updateContentHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::moveBottom(int bottom) {
|
void Widget::moveBottom(int bottom) {
|
||||||
_bottom = bottom;
|
_bottom = bottom;
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateContentHeight() {
|
void Widget::updateContentHeight() {
|
||||||
auto wantedBottom = countBottom();
|
auto addedHeight = innerPadding().top() + innerPadding().bottom();
|
||||||
auto maxContentHeight = wantedBottom - st::emojiPanMargins.top() - st::emojiPanMargins.bottom();
|
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * _bottom) - addedHeight;
|
||||||
auto contentHeight = qMin(_contentMaxHeight, maxContentHeight);
|
auto contentHeight = snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
|
||||||
auto resultTop = wantedBottom - st::emojiPanMargins.bottom() - contentHeight - st::emojiPanMargins.top();
|
accumulate_min(contentHeight, _bottom - addedHeight);
|
||||||
accumulate_max(resultTop, _minTop);
|
accumulate_min(contentHeight, _contentMaxHeight);
|
||||||
auto hs = contentHeight;
|
auto resultTop = _bottom - addedHeight - contentHeight;
|
||||||
if (contentHeight == _contentHeight) {
|
if (contentHeight == _contentHeight) {
|
||||||
move(x(), resultTop);
|
move(x(), resultTop);
|
||||||
return;
|
return;
|
||||||
|
@ -730,13 +719,15 @@ void Widget::updateContentHeight() {
|
||||||
|
|
||||||
resize(QRect(0, 0, innerRect().width(), _contentHeight).marginsAdded(innerPadding()).size());
|
resize(QRect(0, 0, innerRect().width(), _contentHeight).marginsAdded(innerPadding()).size());
|
||||||
_height = height();
|
_height = height();
|
||||||
move(x(), resultTop);
|
moveToLeft(0, resultTop);
|
||||||
|
|
||||||
if (was > _contentHeight) {
|
if (was > _contentHeight) {
|
||||||
_scroll->resize(_scroll->width(), _contentHeight);
|
_scroll->resize(_scroll->width(), _contentHeight);
|
||||||
_inner->setMaxHeight(_contentHeight);
|
auto scrollTop = _scroll->scrollTop();
|
||||||
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _contentHeight);
|
||||||
} else {
|
} else {
|
||||||
_inner->setMaxHeight(_contentHeight);
|
auto scrollTop = _scroll->scrollTop();
|
||||||
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _contentHeight);
|
||||||
_scroll->resize(_scroll->width(), _contentHeight);
|
_scroll->resize(_scroll->width(), _contentHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,12 +784,7 @@ void Widget::paintContent(Painter &p) {
|
||||||
p.fillRect(myrtlrect(inner.x(), sidesTop, st::buttonRadius, sidesHeight), st::emojiPanBg);
|
p.fillRect(myrtlrect(inner.x(), sidesTop, st::buttonRadius, sidesHeight), st::emojiPanBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Widget::countBottom() const {
|
|
||||||
return _bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::moveByBottom() {
|
void Widget::moveByBottom() {
|
||||||
moveToLeft(0, y());
|
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,7 +892,6 @@ void Widget::showStarted() {
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
recountContentMaxHeight();
|
recountContentMaxHeight();
|
||||||
_inner->preloadImages();
|
_inner->preloadImages();
|
||||||
moveByBottom();
|
|
||||||
show();
|
show();
|
||||||
App::wnd()->enableGifPauseReason(Window::GifPauseReason::InlineResults);
|
App::wnd()->enableGifPauseReason(Window::GifPauseReason::InlineResults);
|
||||||
startShowAnimation();
|
startShowAnimation();
|
||||||
|
@ -1095,7 +1080,7 @@ int Widget::showInlineRows(bool newResults) {
|
||||||
_scroll->scrollToY(0);
|
_scroll->scrollToY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hidden = isHidden();
|
auto hidden = isHidden();
|
||||||
if (!hidden && !clear) {
|
if (!hidden && !clear) {
|
||||||
recountContentMaxHeight();
|
recountContentMaxHeight();
|
||||||
}
|
}
|
||||||
|
@ -1115,7 +1100,7 @@ int Widget::showInlineRows(bool newResults) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::recountContentMaxHeight() {
|
void Widget::recountContentMaxHeight() {
|
||||||
_contentMaxHeight = qMin(_inner->countHeight(true), st::emojiPanMaxHeight);
|
_contentMaxHeight = _inner->countHeight();
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,6 @@ class Inner : public TWidget, public Context, private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
Inner(QWidget *parent);
|
Inner(QWidget *parent);
|
||||||
|
|
||||||
void setMaxHeight(int maxHeight);
|
|
||||||
|
|
||||||
void hideFinish(bool completely);
|
void hideFinish(bool completely);
|
||||||
|
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
|
@ -78,7 +76,7 @@ public:
|
||||||
void inlineItemRepaint(const ItemBase *layout) override;
|
void inlineItemRepaint(const ItemBase *layout) override;
|
||||||
bool inlineItemVisible(const ItemBase *layout) override;
|
bool inlineItemVisible(const ItemBase *layout) override;
|
||||||
|
|
||||||
int countHeight(bool plain = false);
|
int countHeight();
|
||||||
|
|
||||||
void setResultSelectedCallback(base::lambda<void(Result *result, UserData *bot)> callback) {
|
void setResultSelectedCallback(base::lambda<void(Result *result, UserData *bot)> callback) {
|
||||||
_resultSelectedCallback = std::move(callback);
|
_resultSelectedCallback = std::move(callback);
|
||||||
|
@ -113,8 +111,6 @@ private:
|
||||||
|
|
||||||
void refreshSwitchPmButton(const CacheEntry *entry);
|
void refreshSwitchPmButton(const CacheEntry *entry);
|
||||||
|
|
||||||
int32 _maxHeight;
|
|
||||||
|
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
|
|
||||||
|
@ -164,8 +160,6 @@ class Widget : public TWidget, private MTP::Sender {
|
||||||
public:
|
public:
|
||||||
Widget(QWidget *parent);
|
Widget(QWidget *parent);
|
||||||
|
|
||||||
void setMinTop(int minTop);
|
|
||||||
void setMinBottom(int minBottom);
|
|
||||||
void moveBottom(int bottom);
|
void moveBottom(int bottom);
|
||||||
|
|
||||||
void hideFast();
|
void hideFast();
|
||||||
|
@ -199,7 +193,6 @@ private slots:
|
||||||
void onEmptyInlineRows();
|
void onEmptyInlineRows();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int countBottom() const;
|
|
||||||
void moveByBottom();
|
void moveByBottom();
|
||||||
void paintContent(Painter &p);
|
void paintContent(Painter &p);
|
||||||
|
|
||||||
|
@ -235,8 +228,6 @@ private:
|
||||||
bool refreshInlineRows(int *added = nullptr);
|
bool refreshInlineRows(int *added = nullptr);
|
||||||
void inlineResultsDone(const MTPmessages_BotResults &result);
|
void inlineResultsDone(const MTPmessages_BotResults &result);
|
||||||
|
|
||||||
int _minTop = 0;
|
|
||||||
int _minBottom = 0;
|
|
||||||
int _contentMaxHeight = 0;
|
int _contentMaxHeight = 0;
|
||||||
int _contentHeight = 0;
|
int _contentHeight = 0;
|
||||||
bool _horizontal = false;
|
bool _horizontal = false;
|
||||||
|
|
|
@ -353,27 +353,16 @@ EmojiPanel::EmojiPanel(QWidget *parent) : TWidget(parent)
|
||||||
hideChildren();
|
hideChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanel::setMinTop(int minTop) {
|
|
||||||
_minTop = minTop;
|
|
||||||
updateContentHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmojiPanel::setMinBottom(int minBottom) {
|
|
||||||
_minBottom = minBottom;
|
|
||||||
updateContentHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmojiPanel::moveBottom(int bottom) {
|
void EmojiPanel::moveBottom(int bottom) {
|
||||||
_bottom = bottom;
|
_bottom = bottom;
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanel::updateContentHeight() {
|
void EmojiPanel::updateContentHeight() {
|
||||||
auto wantedBottom = countBottom();
|
auto addedHeight = innerPadding().top() + marginTop() + marginBottom() + innerPadding().bottom();
|
||||||
auto maxContentHeight = wantedBottom - st::emojiPanMargins.top() - st::emojiPanMargins.bottom() - marginTop() - marginBottom();
|
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * _bottom) - addedHeight;
|
||||||
auto contentHeight = qMin(_contentMaxHeight, maxContentHeight);
|
auto contentHeight = snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
|
||||||
auto resultTop = wantedBottom - st::emojiPanMargins.bottom() - marginBottom() - contentHeight - marginTop() - st::emojiPanMargins.top();
|
auto resultTop = _bottom - addedHeight - contentHeight;
|
||||||
accumulate_max(resultTop, _minTop);
|
|
||||||
if (contentHeight == _contentHeight) {
|
if (contentHeight == _contentHeight) {
|
||||||
move(x(), resultTop);
|
move(x(), resultTop);
|
||||||
return;
|
return;
|
||||||
|
@ -505,10 +494,6 @@ int EmojiPanel::marginBottom() const {
|
||||||
return st::emojiCategory.height;
|
return st::emojiCategory.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EmojiPanel::countBottom() const {
|
|
||||||
return (parentWidget()->height() - _minBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmojiPanel::moveByBottom() {
|
void EmojiPanel::moveByBottom() {
|
||||||
moveToRight(0, y());
|
moveToRight(0, y());
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
|
|
|
@ -48,8 +48,6 @@ class EmojiPanel : public TWidget {
|
||||||
public:
|
public:
|
||||||
EmojiPanel(QWidget *parent);
|
EmojiPanel(QWidget *parent);
|
||||||
|
|
||||||
void setMinTop(int minTop);
|
|
||||||
void setMinBottom(int minBottom);
|
|
||||||
void moveBottom(int bottom);
|
void moveBottom(int bottom);
|
||||||
|
|
||||||
void hideFast();
|
void hideFast();
|
||||||
|
@ -141,7 +139,6 @@ private:
|
||||||
|
|
||||||
int marginTop() const;
|
int marginTop() const;
|
||||||
int marginBottom() const;
|
int marginBottom() const;
|
||||||
int countBottom() const;
|
|
||||||
void moveByBottom();
|
void moveByBottom();
|
||||||
void paintSlideFrame(Painter &p, TimeMs ms);
|
void paintSlideFrame(Painter &p, TimeMs ms);
|
||||||
void paintContent(Painter &p);
|
void paintContent(Painter &p);
|
||||||
|
@ -200,8 +197,6 @@ private:
|
||||||
gsl::not_null<StickersListWidget*> stickers() const;
|
gsl::not_null<StickersListWidget*> stickers() const;
|
||||||
gsl::not_null<GifsListWidget*> gifs() const;
|
gsl::not_null<GifsListWidget*> gifs() const;
|
||||||
|
|
||||||
int _minTop = 0;
|
|
||||||
int _minBottom = 0;
|
|
||||||
int _contentMaxHeight = 0;
|
int _contentMaxHeight = 0;
|
||||||
int _contentHeight = 0;
|
int _contentHeight = 0;
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,6 @@ stickersSettingsUnreadPosition: point(4px, 5px);
|
||||||
|
|
||||||
emojiPanMargins: margins(10px, 10px, 10px, 10px);
|
emojiPanMargins: margins(10px, 10px, 10px, 10px);
|
||||||
|
|
||||||
|
|
||||||
emojiTabs: SettingsSlider(defaultTabsSlider) {
|
emojiTabs: SettingsSlider(defaultTabsSlider) {
|
||||||
rippleRoundRadius: buttonRadius;
|
rippleRoundRadius: buttonRadius;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +151,9 @@ emojiPanAnimation: PanelAnimation(defaultPanelAnimation) {
|
||||||
emojiPanPadding: 12px;
|
emojiPanPadding: 12px;
|
||||||
emojiPanSize: size(45px, 41px);
|
emojiPanSize: size(45px, 41px);
|
||||||
emojiPanWidth: 345px;
|
emojiPanWidth: 345px;
|
||||||
emojiPanMaxHeight: 720px;
|
emojiPanMinHeight: 278px;
|
||||||
|
emojiPanMaxHeight: 640px;
|
||||||
|
emojiPanHeightRatio: 0.75;
|
||||||
emojiPanShowDuration: 200;
|
emojiPanShowDuration: 200;
|
||||||
emojiPanDuration: 200;
|
emojiPanDuration: 200;
|
||||||
emojiPanHover: windowBgOver;
|
emojiPanHover: windowBgOver;
|
||||||
|
|
Loading…
Reference in New Issue