mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix effect selector for !_useTransparency case.
This commit is contained in:
parent
d0d1ef9e66
commit
bbb3a51b74
4 changed files with 88 additions and 16 deletions
|
@ -670,7 +670,7 @@ defaultEmojiPan: EmojiPan {
|
||||||
boxLabel: boxLabel;
|
boxLabel: boxLabel;
|
||||||
icons: defaultComposeIcons;
|
icons: defaultComposeIcons;
|
||||||
about: defaultEmojiPanAbout;
|
about: defaultEmojiPanAbout;
|
||||||
aboutPadding: margins(12px, 2px, 12px, 2px);
|
aboutPadding: margins(12px, 3px, 12px, 2px);
|
||||||
autocompleteBottomSkip: 0px;
|
autocompleteBottomSkip: 0px;
|
||||||
}
|
}
|
||||||
statusEmojiPan: EmojiPan(defaultEmojiPan) {
|
statusEmojiPan: EmojiPan(defaultEmojiPan) {
|
||||||
|
|
|
@ -377,6 +377,32 @@ int Selector::extendTopForCategoriesAndAbout(int width) const {
|
||||||
return std::max(extendTopForCategories(), _aboutExtend);
|
return std::max(extendTopForCategories(), _aboutExtend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Selector::opaqueExtendTopAbout(int width) const {
|
||||||
|
if (_about) {
|
||||||
|
const auto padding = _st.aboutPadding;
|
||||||
|
const auto available = width - padding.left() - padding.right();
|
||||||
|
const auto countAboutHeight = [&](int width) {
|
||||||
|
_about->resizeToWidth(width);
|
||||||
|
return _about->height();
|
||||||
|
};
|
||||||
|
const auto desired = Ui::FindNiceTooltipWidth(
|
||||||
|
std::min(available, _st.about.minWidth * 2),
|
||||||
|
available,
|
||||||
|
countAboutHeight);
|
||||||
|
|
||||||
|
_about->resizeToWidth(desired);
|
||||||
|
_aboutExtend = padding.top() + _about->height() + padding.bottom();
|
||||||
|
} else {
|
||||||
|
_aboutExtend = 0;
|
||||||
|
}
|
||||||
|
return _aboutExtend;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selector::setOpaqueHeightExpand(int expand, Fn<void(int)> apply) {
|
||||||
|
_opaqueHeightExpand = expand;
|
||||||
|
_opaqueApplyHeightExpand = std::move(apply);
|
||||||
|
}
|
||||||
|
|
||||||
int Selector::minimalHeight() const {
|
int Selector::minimalHeight() const {
|
||||||
return _skipy
|
return _skipy
|
||||||
+ std::min(_recentRows * _size, st::emojiPanMinHeight)
|
+ std::min(_recentRows * _size, st::emojiPanMinHeight)
|
||||||
|
@ -399,15 +425,19 @@ void Selector::initGeometry(int innerTop) {
|
||||||
const auto forAbout = width - margins.left() - margins.right();
|
const auto forAbout = width - margins.left() - margins.right();
|
||||||
_collapsedTopSkip = _useTransparency
|
_collapsedTopSkip = _useTransparency
|
||||||
? (extendTopForCategoriesAndAbout(forAbout) + _specialExpandTopSkip)
|
? (extendTopForCategoriesAndAbout(forAbout) + _specialExpandTopSkip)
|
||||||
: 0;
|
: opaqueExtendTopAbout(forAbout);
|
||||||
_topAddOnExpand = _collapsedTopSkip - _aboutExtend;
|
_topAddOnExpand = _collapsedTopSkip - _aboutExtend;
|
||||||
const auto height = margins.top()
|
const auto height = margins.top()
|
||||||
+ _aboutExtend
|
+ _aboutExtend
|
||||||
+ innerHeight
|
+ innerHeight
|
||||||
+ margins.bottom();
|
+ margins.bottom();
|
||||||
const auto left = style::RightToLeft() ? 0 : (parent.width() - width);
|
const auto left = style::RightToLeft() ? 0 : (parent.width() - width);
|
||||||
const auto top = innerTop - margins.top() - _collapsedTopSkip;
|
const auto top = innerTop
|
||||||
const auto add = _st.icons.stripBubble.height() - margins.bottom();
|
- margins.top()
|
||||||
|
- (_useTransparency ? _collapsedTopSkip : 0);
|
||||||
|
const auto add = _useTransparency
|
||||||
|
? (_st.icons.stripBubble.height() - margins.bottom())
|
||||||
|
: 0;
|
||||||
_outer = QRect(0, _collapsedTopSkip - _aboutExtend, width, height);
|
_outer = QRect(0, _collapsedTopSkip - _aboutExtend, width, height);
|
||||||
_outerWithBubble = _outer.marginsAdded({ 0, 0, 0, add });
|
_outerWithBubble = _outer.marginsAdded({ 0, 0, 0, add });
|
||||||
setGeometry(_outerWithBubble.marginsAdded(
|
setGeometry(_outerWithBubble.marginsAdded(
|
||||||
|
@ -568,7 +598,7 @@ void Selector::paintCollapsed(QPainter &p) {
|
||||||
}
|
}
|
||||||
p.drawImage(_outer.topLeft(), _paintBuffer);
|
p.drawImage(_outer.topLeft(), _paintBuffer);
|
||||||
} else {
|
} else {
|
||||||
p.fillRect(_inner, _st.bg);
|
p.fillRect(_outer.marginsRemoved(marginsForShadow()), _st.bg);
|
||||||
}
|
}
|
||||||
_strip->paint(
|
_strip->paint(
|
||||||
p,
|
p,
|
||||||
|
@ -647,6 +677,13 @@ Selector::ExpandingRects Selector::updateExpandingRects(float64 progress) {
|
||||||
? int(base::SafeRound(
|
? int(base::SafeRound(
|
||||||
radius - sqrt(categories * (2 * radius - categories))))
|
radius - sqrt(categories * (2 * radius - categories))))
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
if (!_useTransparency && _opaqueApplyHeightExpand) {
|
||||||
|
Ui::PostponeCall(this, [=] {
|
||||||
|
_opaqueApplyHeightExpand(y() + outer.y() + outer.height());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
.categories = QRect(inner.x(), inner.y(), inner.width(), categories),
|
.categories = QRect(inner.x(), inner.y(), inner.width(), categories),
|
||||||
.list = list,
|
.list = list,
|
||||||
|
@ -877,8 +914,9 @@ void Selector::expand() {
|
||||||
const auto heightLimit = _reactions.customAllowed
|
const auto heightLimit = _reactions.customAllowed
|
||||||
? st::emojiPanMaxHeight
|
? st::emojiPanMaxHeight
|
||||||
: minimalHeight();
|
: minimalHeight();
|
||||||
|
const auto opaqueAdded = _useTransparency ? 0 : _opaqueHeightExpand;
|
||||||
const auto willBeHeight = std::min(
|
const auto willBeHeight = std::min(
|
||||||
parent.height() - y(),
|
parent.height() - y() + opaqueAdded,
|
||||||
margins.top() + heightLimit + margins.bottom());
|
margins.top() + heightLimit + margins.bottom());
|
||||||
const auto additionalBottom = willBeHeight - height();
|
const auto additionalBottom = willBeHeight - height();
|
||||||
const auto additional = _specialExpandTopSkip + additionalBottom;
|
const auto additional = _specialExpandTopSkip + additionalBottom;
|
||||||
|
@ -903,7 +941,9 @@ void Selector::expand() {
|
||||||
}
|
}
|
||||||
_expanded = true;
|
_expanded = true;
|
||||||
_paintBuffer = _cachedRound.PrepareImage(size());
|
_paintBuffer = _cachedRound.PrepareImage(size());
|
||||||
_expanding.start([=] { update(); }, 0., full, full);
|
_expanding.start([=] {
|
||||||
|
update();
|
||||||
|
}, 0., full, full);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +963,9 @@ void Selector::createList() {
|
||||||
&_show->session(),
|
&_show->session(),
|
||||||
_strip ? _reactions.recent : std::vector<Data::Reaction>(),
|
_strip ? _reactions.recent : std::vector<Data::Reaction>(),
|
||||||
_strip.get());
|
_strip.get());
|
||||||
_scroll = Ui::CreateChild<Ui::ScrollArea>(this, _reactions.customAllowed
|
_scroll = Ui::CreateChild<Ui::ScrollArea>(this, !_useTransparency
|
||||||
|
? st::emojiScroll
|
||||||
|
: _reactions.customAllowed
|
||||||
? st::reactPanelScroll
|
? st::reactPanelScroll
|
||||||
: st::reactPanelScrollRounded);
|
: st::reactPanelScrollRounded);
|
||||||
_scroll->hide();
|
_scroll->hide();
|
||||||
|
@ -1069,7 +1111,7 @@ bool AdjustMenuGeometryForSelector(
|
||||||
const auto margins = selector->marginsForShadow();
|
const auto margins = selector->marginsForShadow();
|
||||||
const auto categoriesAboutTop = selector->useTransparency()
|
const auto categoriesAboutTop = selector->useTransparency()
|
||||||
? selector->extendTopForCategoriesAndAbout(width)
|
? selector->extendTopForCategoriesAndAbout(width)
|
||||||
: 0;
|
: selector->opaqueExtendTopAbout(width);
|
||||||
menu->setForceWidth(width - added);
|
menu->setForceWidth(width - added);
|
||||||
const auto height = menu->height();
|
const auto height = menu->height();
|
||||||
const auto fullTop = margins.top() + categoriesAboutTop + extend.top();
|
const auto fullTop = margins.top() + categoriesAboutTop + extend.top();
|
||||||
|
@ -1082,9 +1124,7 @@ bool AdjustMenuGeometryForSelector(
|
||||||
const auto additionalPaddingBottom
|
const auto additionalPaddingBottom
|
||||||
= (willBeHeightWithoutBottomPadding >= minimalHeight
|
= (willBeHeightWithoutBottomPadding >= minimalHeight
|
||||||
? 0
|
? 0
|
||||||
: useTransparency
|
: (minimalHeight - willBeHeightWithoutBottomPadding));
|
||||||
? (minimalHeight - willBeHeightWithoutBottomPadding)
|
|
||||||
: 0);
|
|
||||||
menu->setAdditionalMenuPadding(QMargins(
|
menu->setAdditionalMenuPadding(QMargins(
|
||||||
margins.left() + extend.left(),
|
margins.left() + extend.left(),
|
||||||
fullTop,
|
fullTop,
|
||||||
|
@ -1100,9 +1140,32 @@ bool AdjustMenuGeometryForSelector(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto origin = menu->preparedOrigin();
|
const auto origin = menu->preparedOrigin();
|
||||||
if (!additionalPaddingBottom
|
const auto expandDown = (origin == Ui::PanelAnimation::Origin::TopLeft)
|
||||||
|| origin == Ui::PanelAnimation::Origin::TopLeft
|
|| (origin == Ui::PanelAnimation::Origin::TopRight);
|
||||||
|| origin == Ui::PanelAnimation::Origin::TopRight) {
|
if (!useTransparency) {
|
||||||
|
const auto expandBy = additionalPaddingBottom;
|
||||||
|
selector->setOpaqueHeightExpand(expandBy, [=](int bottom) {
|
||||||
|
const auto add = bottom - menu->height();
|
||||||
|
if (add > 0) {
|
||||||
|
const auto updated = menu->geometry().marginsAdded({
|
||||||
|
0, expandDown ? 0 : add, 0, expandDown ? add : 0 });
|
||||||
|
menu->setFixedSize(updated.size());
|
||||||
|
menu->setGeometry(updated);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu->setAdditionalMenuPadding(QMargins(
|
||||||
|
margins.left() + extend.left(),
|
||||||
|
fullTop,
|
||||||
|
margins.right() + extend.right(),
|
||||||
|
0
|
||||||
|
), QMargins(
|
||||||
|
margins.left(),
|
||||||
|
margins.top(),
|
||||||
|
margins.right(),
|
||||||
|
0
|
||||||
|
));
|
||||||
|
return menu->prepareGeometryFor(desiredPosition);
|
||||||
|
} else if (!additionalPaddingBottom || expandDown) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
menu->setAdditionalMenuPadding(QMargins(
|
menu->setAdditionalMenuPadding(QMargins(
|
||||||
|
|
|
@ -104,12 +104,15 @@ public:
|
||||||
[[nodiscard]] QMargins marginsForShadow() const;
|
[[nodiscard]] QMargins marginsForShadow() const;
|
||||||
[[nodiscard]] int extendTopForCategories() const;
|
[[nodiscard]] int extendTopForCategories() const;
|
||||||
[[nodiscard]] int extendTopForCategoriesAndAbout(int width) const;
|
[[nodiscard]] int extendTopForCategoriesAndAbout(int width) const;
|
||||||
|
[[nodiscard]] int opaqueExtendTopAbout(int width) const;
|
||||||
[[nodiscard]] int minimalHeight() const;
|
[[nodiscard]] int minimalHeight() const;
|
||||||
[[nodiscard]] int countAppearedWidth(float64 progress) const;
|
[[nodiscard]] int countAppearedWidth(float64 progress) const;
|
||||||
void setSpecialExpandTopSkip(int skip);
|
void setSpecialExpandTopSkip(int skip);
|
||||||
void initGeometry(int innerTop);
|
void initGeometry(int innerTop);
|
||||||
void beforeDestroy();
|
void beforeDestroy();
|
||||||
|
|
||||||
|
void setOpaqueHeightExpand(int expand, Fn<void(int)> apply);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<ChosenReaction> chosen() const {
|
[[nodiscard]] rpl::producer<ChosenReaction> chosen() const {
|
||||||
return _chosen.events();
|
return _chosen.events();
|
||||||
}
|
}
|
||||||
|
@ -216,6 +219,10 @@ private:
|
||||||
int _specialExpandTopSkip = 0;
|
int _specialExpandTopSkip = 0;
|
||||||
int _collapsedTopSkip = 0;
|
int _collapsedTopSkip = 0;
|
||||||
int _topAddOnExpand = 0;
|
int _topAddOnExpand = 0;
|
||||||
|
|
||||||
|
int _opaqueHeightExpand = 0;
|
||||||
|
Fn<void(int)> _opaqueApplyHeightExpand;
|
||||||
|
|
||||||
const int _size = 0;
|
const int _size = 0;
|
||||||
int _recentRows = 0;
|
int _recentRows = 0;
|
||||||
int _columns = 0;
|
int _columns = 0;
|
||||||
|
|
|
@ -667,7 +667,9 @@ void Reactions::Panel::create() {
|
||||||
TextWithEntities{ (mode == Mode::Message
|
TextWithEntities{ (mode == Mode::Message
|
||||||
? tr::lng_stories_reaction_as_message(tr::now)
|
? tr::lng_stories_reaction_as_message(tr::now)
|
||||||
: QString()) },
|
: QString()) },
|
||||||
[=](bool fast) { hide(mode); });
|
[=](bool fast) { hide(mode); },
|
||||||
|
nullptr,
|
||||||
|
true);
|
||||||
|
|
||||||
_selector->chosen(
|
_selector->chosen(
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
|
|
Loading…
Add table
Reference in a new issue