Fix window extents terminology

Extents is a synonym of size but we're setting not window size.
This commit is contained in:
Ilya Fedin 2023-08-27 01:35:39 +04:00 committed by John Preston
parent 77c2e12ebc
commit d0eb7ec522
4 changed files with 39 additions and 39 deletions

View File

@ -241,7 +241,7 @@ int Selector::countWidth(int desiredWidth, int maxWidth) {
return std::max(2 * _skipx + _columns * _size, desiredWidth); return std::max(2 * _skipx + _columns * _size, desiredWidth);
} }
QMargins Selector::extentsForShadow() const { QMargins Selector::marginsForShadow() const {
const auto line = st::lineWidth; const auto line = st::lineWidth;
return useTransparency() return useTransparency()
? st::reactionCornerShadow ? st::reactionCornerShadow
@ -264,26 +264,26 @@ void Selector::setSpecialExpandTopSkip(int skip) {
} }
void Selector::initGeometry(int innerTop) { void Selector::initGeometry(int innerTop) {
const auto extents = extentsForShadow(); const auto margins = marginsForShadow();
const auto parent = parentWidget()->rect(); const auto parent = parentWidget()->rect();
const auto innerWidth = 2 * _skipx + _columns * _size; const auto innerWidth = 2 * _skipx + _columns * _size;
const auto innerHeight = st::reactStripHeight; const auto innerHeight = st::reactStripHeight;
const auto width = _useTransparency const auto width = _useTransparency
? (innerWidth + extents.left() + extents.right()) ? (innerWidth + margins.left() + margins.right())
: parent.width(); : parent.width();
const auto height = innerHeight + extents.top() + extents.bottom(); const auto height = innerHeight + margins.top() + margins.bottom();
const auto left = style::RightToLeft() ? 0 : (parent.width() - width); const auto left = style::RightToLeft() ? 0 : (parent.width() - width);
_collapsedTopSkip = _useTransparency _collapsedTopSkip = _useTransparency
? (extendTopForCategories() + _specialExpandTopSkip) ? (extendTopForCategories() + _specialExpandTopSkip)
: 0; : 0;
const auto top = innerTop - extents.top() - _collapsedTopSkip; const auto top = innerTop - margins.top() - _collapsedTopSkip;
const auto add = _st.icons.stripBubble.height() - extents.bottom(); const auto add = _st.icons.stripBubble.height() - margins.bottom();
_outer = QRect(0, _collapsedTopSkip, width, height); _outer = QRect(0, _collapsedTopSkip, width, height);
_outerWithBubble = _outer.marginsAdded({ 0, 0, 0, add }); _outerWithBubble = _outer.marginsAdded({ 0, 0, 0, add });
setGeometry(_outerWithBubble.marginsAdded( setGeometry(_outerWithBubble.marginsAdded(
{ 0, _collapsedTopSkip, 0, 0 } { 0, _collapsedTopSkip, 0, 0 }
).translated(left, top)); ).translated(left, top));
_inner = _outer.marginsRemoved(extents); _inner = _outer.marginsRemoved(margins);
if (!_strip) { if (!_strip) {
expand(); expand();
@ -343,9 +343,9 @@ void Selector::paintAppearing(QPainter &p) {
} }
_paintBuffer.fill(_st.bg->c); _paintBuffer.fill(_st.bg->c);
auto q = QPainter(&_paintBuffer); auto q = QPainter(&_paintBuffer);
const auto extents = extentsForShadow(); const auto margins = marginsForShadow();
const auto appearedWidth = countAppearedWidth(_appearProgress); const auto appearedWidth = countAppearedWidth(_appearProgress);
const auto fullWidth = _inner.x() + appearedWidth + extents.right(); const auto fullWidth = _inner.x() + appearedWidth + margins.right();
const auto size = QSize(fullWidth, _outer.height()); const auto size = QSize(fullWidth, _outer.height());
q.translate(_inner.topLeft() - QPoint(0, _collapsedTopSkip)); q.translate(_inner.topLeft() - QPoint(0, _collapsedTopSkip));
@ -455,7 +455,7 @@ auto Selector::paintExpandingBg(QPainter &p, float64 progress)
const auto radius = _reactions.customAllowed const auto radius = _reactions.customAllowed
? (radiusStart + progress * (radiusEnd - radiusStart)) ? (radiusStart + progress * (radiusEnd - radiusStart))
: radiusStart; : radiusStart;
const auto extents = extentsForShadow(); const auto margins = marginsForShadow();
const auto expanding = anim::easeOutCirc(1., progress); const auto expanding = anim::easeOutCirc(1., progress);
const auto expandUp = anim::interpolate(0, _collapsedTopSkip, expanding); const auto expandUp = anim::interpolate(0, _collapsedTopSkip, expanding);
const auto expandDown = anim::interpolate( const auto expandDown = anim::interpolate(
@ -470,7 +470,7 @@ auto Selector::paintExpandingBg(QPainter &p, float64 progress)
p.fillRect(fill, _st.bg); p.fillRect(fill, _st.bg);
} }
} else { } else {
const auto inner = outer.marginsRemoved(extentsForShadow()); const auto inner = outer.marginsRemoved(marginsForShadow());
p.fillRect(inner, _st.bg); p.fillRect(inner, _st.bg);
p.fillRect( p.fillRect(
inner.x(), inner.x(),
@ -483,7 +483,7 @@ auto Selector::paintExpandingBg(QPainter &p, float64 progress)
0, 0,
extendTopForCategories(), extendTopForCategories(),
expanding); expanding);
const auto inner = outer.marginsRemoved(extents); const auto inner = outer.marginsRemoved(margins);
_shadowTop = inner.y() + categories; _shadowTop = inner.y() + categories;
_shadowSkip = (_useTransparency && categories < radius) _shadowSkip = (_useTransparency && categories < radius)
? int(base::SafeRound( ? int(base::SafeRound(
@ -494,7 +494,7 @@ auto Selector::paintExpandingBg(QPainter &p, float64 progress)
.list = inner.marginsRemoved({ 0, categories, 0, 0 }), .list = inner.marginsRemoved({ 0, categories, 0, 0 }),
.radius = radius, .radius = radius,
.expanding = expanding, .expanding = expanding,
.finalBottom = height() - extents.bottom(), .finalBottom = height() - margins.bottom(),
}; };
} }
@ -521,7 +521,7 @@ void Selector::paintExpanded(QPainter &p) {
if (_useTransparency) { if (_useTransparency) {
p.drawImage(0, 0, _paintBuffer); p.drawImage(0, 0, _paintBuffer);
} else { } else {
const auto inner = rect().marginsRemoved(extentsForShadow()); const auto inner = rect().marginsRemoved(marginsForShadow());
p.fillRect(inner, _st.bg); p.fillRect(inner, _st.bg);
p.fillRect( p.fillRect(
inner.x(), inner.x(),
@ -694,13 +694,13 @@ void Selector::expand() {
_willExpand.fire({}); _willExpand.fire({});
preloadAllRecentsAnimations(); preloadAllRecentsAnimations();
const auto parent = parentWidget()->geometry(); const auto parent = parentWidget()->geometry();
const auto extents = extentsForShadow(); const auto margins = marginsForShadow();
const auto heightLimit = _reactions.customAllowed const auto heightLimit = _reactions.customAllowed
? st::emojiPanMaxHeight ? st::emojiPanMaxHeight
: minimalHeight(); : minimalHeight();
const auto willBeHeight = std::min( const auto willBeHeight = std::min(
parent.height() - y(), parent.height() - y(),
extents.top() + heightLimit + extents.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;
if (additionalBottom < 0 || additional <= 0) { if (additionalBottom < 0 || additional <= 0) {
@ -834,7 +834,7 @@ void Selector::createList() {
_list->jumpedToPremium( _list->jumpedToPremium(
) | rpl::start_with_next(_jumpedToPremium, _list->lifetime()); ) | rpl::start_with_next(_jumpedToPremium, _list->lifetime());
const auto inner = rect().marginsRemoved(extentsForShadow()); const auto inner = rect().marginsRemoved(marginsForShadow());
const auto footer = _reactions.customAllowed const auto footer = _reactions.customAllowed
? _list->createFooter().data() ? _list->createFooter().data()
: nullptr; : nullptr;
@ -904,16 +904,16 @@ bool AdjustMenuGeometryForSelector(
const auto desiredWidth = menu->menu()->width() + added; const auto desiredWidth = menu->menu()->width() + added;
const auto maxWidth = menu->st().menu.widthMax + added; const auto maxWidth = menu->st().menu.widthMax + added;
const auto width = selector->countWidth(desiredWidth, maxWidth); const auto width = selector->countWidth(desiredWidth, maxWidth);
const auto extents = selector->extentsForShadow(); const auto margins = selector->marginsForShadow();
const auto categoriesTop = selector->useTransparency() const auto categoriesTop = selector->useTransparency()
? selector->extendTopForCategories() ? selector->extendTopForCategories()
: 0; : 0;
menu->setForceWidth(width - added); menu->setForceWidth(width - added);
const auto height = menu->height(); const auto height = menu->height();
const auto fullTop = extents.top() + categoriesTop + extend.top(); const auto fullTop = margins.top() + categoriesTop + extend.top();
const auto minimalHeight = extents.top() const auto minimalHeight = margins.top()
+ selector->minimalHeight() + selector->minimalHeight()
+ extents.bottom(); + margins.bottom();
const auto willBeHeightWithoutBottomPadding = fullTop const auto willBeHeightWithoutBottomPadding = fullTop
+ height + height
- menu->st().shadow.extend.top(); - menu->st().shadow.extend.top();
@ -924,15 +924,15 @@ bool AdjustMenuGeometryForSelector(
? (minimalHeight - willBeHeightWithoutBottomPadding) ? (minimalHeight - willBeHeightWithoutBottomPadding)
: 0); : 0);
menu->setAdditionalMenuPadding(QMargins( menu->setAdditionalMenuPadding(QMargins(
extents.left() + extend.left(), margins.left() + extend.left(),
fullTop, fullTop,
extents.right() + extend.right(), margins.right() + extend.right(),
additionalPaddingBottom additionalPaddingBottom
), QMargins( ), QMargins(
extents.left(), margins.left(),
extents.top(), margins.top(),
extents.right(), margins.right(),
std::min(additionalPaddingBottom, extents.bottom()) std::min(additionalPaddingBottom, margins.bottom())
)); ));
if (!menu->prepareGeometryFor(desiredPosition)) { if (!menu->prepareGeometryFor(desiredPosition)) {
return false; return false;
@ -944,14 +944,14 @@ bool AdjustMenuGeometryForSelector(
return true; return true;
} }
menu->setAdditionalMenuPadding(QMargins( menu->setAdditionalMenuPadding(QMargins(
extents.left() + extend.left(), margins.left() + extend.left(),
fullTop + additionalPaddingBottom, fullTop + additionalPaddingBottom,
extents.right() + extend.right(), margins.right() + extend.right(),
0 0
), QMargins( ), QMargins(
extents.left(), margins.left(),
extents.top(), margins.top(),
extents.right(), margins.right(),
0 0
)); ));
selector->setSpecialExpandTopSkip(additionalPaddingBottom); selector->setSpecialExpandTopSkip(additionalPaddingBottom);

View File

@ -61,7 +61,7 @@ public:
[[nodiscard]] bool useTransparency() const; [[nodiscard]] bool useTransparency() const;
int countWidth(int desiredWidth, int maxWidth); int countWidth(int desiredWidth, int maxWidth);
[[nodiscard]] QMargins extentsForShadow() const; [[nodiscard]] QMargins marginsForShadow() const;
[[nodiscard]] int extendTopForCategories() const; [[nodiscard]] int extendTopForCategories() const;
[[nodiscard]] int minimalHeight() const; [[nodiscard]] int minimalHeight() const;
[[nodiscard]] int countAppearedWidth(float64 progress) const; [[nodiscard]] int countAppearedWidth(float64 progress) const;

View File

@ -243,18 +243,18 @@ void Reactions::Panel::create() {
const auto desiredWidth = st::storiesReactionsWidth; const auto desiredWidth = st::storiesReactionsWidth;
const auto maxWidth = desiredWidth * 2; const auto maxWidth = desiredWidth * 2;
const auto width = _selector->countWidth(desiredWidth, maxWidth); const auto width = _selector->countWidth(desiredWidth, maxWidth);
const auto extents = _selector->extentsForShadow(); const auto margins = _selector->marginsForShadow();
const auto categoriesTop = _selector->extendTopForCategories(); const auto categoriesTop = _selector->extendTopForCategories();
const auto full = extents.left() + width + extents.right(); const auto full = margins.left() + width + margins.right();
_shownValue = 0.; _shownValue = 0.;
rpl::combine( rpl::combine(
_controller->layoutValue(), _controller->layoutValue(),
_shownValue.value() _shownValue.value()
) | rpl::start_with_next([=](const Layout &layout, float64 shown) { ) | rpl::start_with_next([=](const Layout &layout, float64 shown) {
const auto width = extents.left() const auto width = margins.left()
+ _selector->countAppearedWidth(shown) + _selector->countAppearedWidth(shown)
+ extents.right(); + margins.right();
const auto height = layout.reactions.height(); const auto height = layout.reactions.height();
const auto shift = (width / 2); const auto shift = (width / 2);
const auto right = (mode == Mode::Message) const auto right = (mode == Mode::Message)
@ -271,7 +271,7 @@ void Reactions::Panel::create() {
const auto innerTop = height const auto innerTop = height
- st::storiesReactionsBottomSkip - st::storiesReactionsBottomSkip
- st::reactStripHeight; - st::reactStripHeight;
const auto maxAdded = innerTop - extents.top() - categoriesTop; const auto maxAdded = innerTop - margins.top() - categoriesTop;
const auto added = std::min(maxAdded, st::storiesReactionsAddedTop); const auto added = std::min(maxAdded, st::storiesReactionsAddedTop);
_selector->setSpecialExpandTopSkip(added); _selector->setSpecialExpandTopSkip(added);
_selector->initGeometry(innerTop); _selector->initGeometry(innerTop);

@ -1 +1 @@
Subproject commit 552db4b24f4542dcb6d19302d7e29ff00349b156 Subproject commit bcf88b90658c7e0925c11c486732d874477baf0d