Rename some Ui methods.

myEnsureResized -> Ui::SendPendingMoveResizeEvents.
myGrab -> Ui::GrabWidget.
myGrabImage -> Ui::GrabWidgetToImage.
This commit is contained in:
John Preston 2017-12-26 15:41:48 +03:00
parent 5f8143e6a4
commit 2569df9e5a
44 changed files with 197 additions and 111 deletions

View File

@ -169,7 +169,7 @@ QPixmap BoxContent::grabInnerCache() {
auto isBottomShadowVisible = !_bottomShadow->isHidden();
if (isTopShadowVisible) _topShadow->setVisible(false);
if (isBottomShadowVisible) _bottomShadow->setVisible(false);
auto result = myGrab(this, _scroll->geometry());
auto result = Ui::GrabWidget(this, _scroll->geometry());
if (isTopShadowVisible) _topShadow->setVisible(true);
if (isBottomShadowVisible) _bottomShadow->setVisible(true);
return result;

View File

@ -104,7 +104,7 @@ void PeerListBox::prepare() {
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
if (_select) {
_select->finishAnimating();
myEnsureResized(_select);
Ui::SendPendingMoveResizeEvents(_select);
_scrollBottomFixed = true;
onScrollToY(0);
}

View File

@ -52,7 +52,7 @@ ShareBox::ShareBox(QWidget*, CopyCallback &&copyCallback, SubmitCallback &&submi
void ShareBox::prepare() {
_select->resizeToWidth(st::boxWideWidth);
myEnsureResized(_select);
Ui::SendPendingMoveResizeEvents(_select);
setTitle(langFactory(lng_share_title));

View File

@ -388,10 +388,15 @@ void Panel::toggleOpacityAnimation(bool visible) {
if (_useTransparency) {
if (_animationCache.isNull()) {
showControls();
_animationCache = myGrab(this);
_animationCache = Ui::GrabWidget(this);
hideChildren();
}
_opacityAnimation.start([this] { update(); }, _visible ? 0. : 1., _visible ? 1. : 0., st::callPanelDuration, _visible ? anim::easeOutCirc : anim::easeInCirc);
_opacityAnimation.start(
[this] { update(); },
_visible ? 0. : 1.,
_visible ? 1. : 0.,
st::callPanelDuration,
_visible ? anim::easeOutCirc : anim::easeInCirc);
}
if (isHidden() && _visible) {
show();

View File

@ -250,7 +250,7 @@ void EmojiColorPicker::hideFast() {
void EmojiColorPicker::hideAnimated() {
if (_cache.isNull()) {
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
clearSelection();
}
_hiding = true;
@ -265,7 +265,7 @@ void EmojiColorPicker::showAnimated() {
}
_hiding = false;
if (_cache.isNull()) {
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
clearSelection();
}
show();

View File

@ -408,7 +408,7 @@ void FieldAutocomplete::hideAnimated() {
if (_cache.isNull()) {
_scroll->show();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
}
_scroll->hide();
_hiding = true;
@ -429,7 +429,7 @@ void FieldAutocomplete::showAnimated() {
}
if (_cache.isNull()) {
_scroll->show();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
}
_scroll->hide();
_hiding = false;

View File

@ -255,7 +255,7 @@ void TabbedPanel::prepareCache() {
auto showAnimation = base::take(_a_show);
auto showAnimationData = base::take(_showAnimation);
showChildren();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
_showAnimation = base::take(showAnimationData);
_a_show = base::take(showAnimation);
if (_a_show.animating()) {
@ -296,7 +296,7 @@ QImage TabbedPanel::grabForAnimation() {
auto showAnimation = base::take(_a_show);
showChildren();
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());

View File

@ -489,7 +489,7 @@ QImage TabbedSelector::grabForAnimation() {
showAll();
_topShadow->hide();
_tabsSlider->hide();
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());

View File

@ -229,7 +229,7 @@ void DialogsWidget::startWidthAnimation() {
st::columnMinimalWidthLeft,
scrollGeometry.height());
_scroll->setGeometry(grabGeometry);
myEnsureResized(_scroll);
Ui::SendPendingMoveResizeEvents(_scroll);
auto image = QImage(
grabGeometry.size() * cIntRetinaFactor(),
QImage::Format_ARGB32_Premultiplied);

View File

@ -294,7 +294,7 @@ not_null<ChannelData*> Widget::channel() const {
QPixmap Widget::grabForShowAnimation(const Window::SectionSlideParams &params) {
if (params.withTopBarShadow) _fixedBarShadow->hide();
auto result = myGrab(this);
auto result = Ui::GrabWidget(this);
if (params.withTopBarShadow) _fixedBarShadow->show();
return result;
}
@ -319,7 +319,7 @@ bool Widget::showInternal(
void Widget::setInternalState(const QRect &geometry, not_null<SectionMemento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
restoreState(memento);
}

View File

@ -143,7 +143,9 @@ void DragArea::hideStart() {
return;
}
if (_cache.isNull()) {
_cache = myGrab(this, innerRect().marginsAdded(st::boxRoundShadow.extend));
_cache = Ui::GrabWidget(
this,
innerRect().marginsAdded(st::boxRoundShadow.extend));
}
_hiding = true;
setIn(false);
@ -162,7 +164,9 @@ void DragArea::showStart() {
}
_hiding = false;
if (_cache.isNull()) {
_cache = myGrab(this, innerRect().marginsAdded(st::boxRoundShadow.extend));
_cache = Ui::GrabWidget(
this,
innerRect().marginsAdded(st::boxRoundShadow.extend));
}
show();
_a_opacity.start([this] { opacityAnimationCallback(); }, 0., 1., st::boxDuration);

View File

@ -280,7 +280,7 @@ void HistoryHider::startHide() {
if (Adaptive::OneColumn()) {
QTimer::singleShot(0, this, SLOT(deleteLater()));
} else {
if (_offered) _cacheForAnim = myGrab(this, _box);
if (_offered) _cacheForAnim = Ui::GrabWidget(this, _box);
if (_forwardRequest) MTP::cancel(_forwardRequest);
_send->hide();
_cancel->hide();

View File

@ -87,7 +87,7 @@ void Widget::setInternalState(
const QRect &geometry,
not_null<Memento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
restoreState(memento);
}

View File

@ -652,7 +652,7 @@ QPixmap WrapWidget::grabForShowAnimation(
//if (params.withTabs && _topTabs) {
// _topTabs->hide();
//}
auto result = myGrab(this);
auto result = Ui::GrabWidget(this);
if (params.withTopBarShadow) {
_topShadow->setVisible(true);
}

View File

@ -122,7 +122,7 @@ void Widget::setInternalState(
const QRect &geometry,
not_null<Memento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
restoreState(memento);
}

View File

@ -84,7 +84,7 @@ void Widget::setInternalState(
const QRect &geometry,
not_null<Memento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
restoreState(memento);
}

View File

@ -103,7 +103,7 @@ void Widget::setInternalState(
const QRect &geometry,
not_null<Memento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
restoreState(memento);
}

View File

@ -874,7 +874,7 @@ void Widget::prepareCache() {
auto showAnimation = base::take(_a_show);
auto showAnimationData = base::take(_showAnimation);
showChildren();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
_showAnimation = base::take(showAnimationData);
_a_show = base::take(showAnimation);
if (_a_show.animating()) {
@ -911,7 +911,7 @@ void Widget::startShowAnimation() {
}
QImage Widget::grabForPanelAnimation() {
myEnsureResized(this);
Ui::SendPendingMoveResizeEvents(this);
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
result.fill(Qt::transparent);

View File

@ -336,7 +336,7 @@ void Widget::showAnimated(const QPixmap &bgAnimCache, bool back) {
_a_show.finish();
showControls();
(_showBack ? _cacheUnder : _cacheOver) = myGrab(this);
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
hideControls();
_a_show.start([this] { animationCallback(); }, 0., 1., st::slideDuration, Window::SlideAnimation::transition());
@ -491,7 +491,7 @@ void Widget::Step::resizeEvent(QResizeEvent *e) {
}
void Widget::Step::updateLabelsPosition() {
myEnsureResized(_description->entity());
Ui::SendPendingMoveResizeEvents(_description->entity());
if (hasCover()) {
_title->moveToLeft((width() - _title->width()) / 2, contentTop() + st::introCoverTitleTop);
_description->moveToLeft((width() - _description->width()) / 2, contentTop() + st::introCoverDescriptionTop);
@ -503,7 +503,7 @@ void Widget::Step::updateLabelsPosition() {
if (_errorCentered) {
_error->entity()->resizeToWidth(width());
}
myEnsureResized(_error->entity());
Ui::SendPendingMoveResizeEvents(_error->entity());
auto errorLeft = _errorCentered ? 0 : (contentLeft() + st::buttonRadius);
auto errorTop = contentTop() + (_errorBelowLink ? st::introErrorBelowLinkTop : st::introErrorTop);
_error->moveToLeft(errorLeft, errorTop);
@ -773,8 +773,16 @@ void Widget::Step::prepareShowAnimated(Step *after) {
Widget::Step::CoverAnimation Widget::Step::prepareCoverAnimation(Step *after) {
auto result = CoverAnimation();
result.title = Ui::FlatLabel::CrossFade(after->_title, _title, st::introBg);
result.description = Ui::FlatLabel::CrossFade(after->_description->entity(), _description->entity(), st::introBg, after->_description->pos(), _description->pos());
result.title = Ui::FlatLabel::CrossFade(
after->_title,
_title,
st::introBg);
result.description = Ui::FlatLabel::CrossFade(
after->_description->entity(),
_description->entity(),
st::introBg,
after->_description->pos(),
_description->pos());
result.contentSnapshotWas = after->prepareContentSnapshot();
result.contentSnapshotNow = prepareContentSnapshot();
return result;
@ -783,13 +791,15 @@ Widget::Step::CoverAnimation Widget::Step::prepareCoverAnimation(Step *after) {
QPixmap Widget::Step::prepareContentSnapshot() {
auto otherTop = _description->y() + _description->height();
auto otherRect = myrtlrect(contentLeft(), otherTop, st::introStepWidth, height() - otherTop);
return myGrab(this, otherRect);
return Ui::GrabWidget(this, otherRect);
}
QPixmap Widget::Step::prepareSlideAnimation() {
auto grabLeft = (width() - st::introStepWidth) / 2;
auto grabTop = contentTop();
return myGrab(this, QRect(grabLeft, grabTop, st::introStepWidth, st::introStepHeight));
return Ui::GrabWidget(
this,
QRect(grabLeft, grabTop, st::introStepWidth, st::introStepHeight));
}
void Widget::Step::showAnimated(Direction direction) {

View File

@ -2554,7 +2554,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
auto sectionTop = getMainSectionTop();
if (selectingPeer() && Adaptive::OneColumn()) {
result.oldContentCache = myGrab(this, QRect(
result.oldContentCache = Ui::GrabWidget(this, QRect(
0,
sectionTop,
_dialogsWidth,
@ -2568,7 +2568,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
_history->grabStart();
}
if (Adaptive::OneColumn()) {
result.oldContentCache = myGrab(this, QRect(
result.oldContentCache = Ui::GrabWidget(this, QRect(
0,
sectionTop,
_dialogsWidth,
@ -2578,7 +2578,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
if (_thirdShadow) {
_thirdShadow->hide();
}
result.oldContentCache = myGrab(this, QRect(
result.oldContentCache = Ui::GrabWidget(this, QRect(
_dialogsWidth,
sectionTop,
width() - _dialogsWidth,
@ -2890,7 +2890,7 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams &param
auto sectionTop = getMainSectionTop();
if (Adaptive::OneColumn()) {
result = myGrab(this, QRect(
result = Ui::GrabWidget(this, QRect(
0,
sectionTop,
_dialogsWidth,
@ -2900,7 +2900,7 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams &param
if (_thirdShadow) {
_thirdShadow->hide();
}
result = myGrab(this, QRect(
result = Ui::GrabWidget(this, QRect(
_dialogsWidth,
sectionTop,
width() - _dialogsWidth,
@ -3001,10 +3001,15 @@ void MainWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
_a_show.finish();
showAll();
(_showBack ? _cacheUnder : _cacheOver) = myGrab(this);
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
hideAll();
_a_show.start([this] { animationCallback(); }, 0., 1., st::slideDuration, Window::SlideAnimation::transition());
_a_show.start(
[this] { animationCallback(); },
0.,
1.,
st::slideDuration,
Window::SlideAnimation::transition());
show();
}

View File

@ -194,11 +194,11 @@ void MainWindow::clearWidgetsHook() {
QPixmap MainWindow::grabInner() {
QPixmap result;
if (_intro) {
result = myGrab(_intro);
result = Ui::GrabWidget(_intro);
} else if (_passcode) {
result = myGrab(_passcode);
result = Ui::GrabWidget(_passcode);
} else if (_main) {
result = myGrab(_main);
result = Ui::GrabWidget(_main);
}
return result;
}

View File

@ -426,7 +426,7 @@ void Panel::startAnimation() {
auto to = _hiding ? 0. : 1.;
if (_cache.isNull()) {
showChildren();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
}
hideChildren();
_a_appearance.start([this] { appearanceCallback(); }, from, to, st::defaultInnerDropdown.duration);

View File

@ -207,7 +207,7 @@ void VolumeWidget::startAnimation() {
auto to = _hiding ? 0. : 1.;
if (_cache.isNull()) {
showChildren();
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
}
hideChildren();
_a_appearance.start([this] { appearanceCallback(); }, from, to, st::defaultInnerDropdown.duration);

View File

@ -1634,7 +1634,7 @@ void MediaView::setClipControllerGeometry() {
controllerBottom - _clipController->height() - st::mediaviewCaptionPadding.bottom() - st::mediaviewCaptionMargin.height(),
st::mediaviewControllerSize.width(),
st::mediaviewControllerSize.height());
myEnsureResized(_clipController);
Ui::SendPendingMoveResizeEvents(_clipController);
}
void MediaView::onVideoPauseResume() {

View File

@ -109,10 +109,15 @@ void PasscodeWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
showAll();
setInnerFocus();
_passcode->finishAnimating();
(_showBack ? _cacheUnder : _cacheOver) = myGrab(this);
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
hideAll();
_a_show.start([this] { animationCallback(); }, 0., 1., st::slideDuration, Window::SlideAnimation::transition());
_a_show.start(
[this] { animationCallback(); },
0.,
1.,
st::slideDuration,
Window::SlideAnimation::transition());
show();
}

View File

@ -91,10 +91,14 @@ void CoverDropArea::paintEvent(QPaintEvent *e) {
void CoverDropArea::setupAnimation() {
if (_cache.isNull()) {
_cache = myGrab(this);
_cache = Ui::GrabWidget(this);
}
auto from = _hiding ? 1. : 0., to = _hiding ? 0. : 1.;
_a_appearance.start([this]() { update(); }, from, to, st::profileDropAreaDuration);
_a_appearance.start(
[this] { update(); },
from,
to,
st::profileDropAreaDuration);
}
} // namespace Profile

View File

@ -74,7 +74,7 @@ void FadeAnimation::refreshCache() {
}
QPixmap FadeAnimation::grabContent() {
myEnsureResized(_widget);
SendPendingMoveResizeEvents(_widget);
_size = _widget->size();
if (_size.isEmpty()) {
auto image = QImage(
@ -84,7 +84,7 @@ QPixmap FadeAnimation::grabContent() {
image.fill(Qt::transparent);
return App::pixmapFromImageInPlace(std::move(image));
}
auto widgetContent = myGrab(_widget);
auto widgetContent = GrabWidget(_widget);
if (_scale < 1.) {
auto result = QImage(kWideScale * _size * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());

View File

@ -367,7 +367,10 @@ QPixmap SendButton::grabContent() {
result.fill(Qt::transparent);
{
Painter p(&result);
p.drawPixmap((kWideScale - 1) / 2 * width(), (kWideScale - 1) / 2 * height(), myGrab(this));
p.drawPixmap(
(kWideScale - 1) / 2 * width(),
(kWideScale - 1) / 2 * height(),
GrabWidget(this));
}
return App::pixmapFromImageInPlace(std::move(result));
}
@ -715,7 +718,7 @@ void UserpicButton::grabOldUserpic() {
countPhotoPosition(),
QSize(_st.photoSize, _st.photoSize)
);
_oldUserpic = myGrab(this, photoRect);
_oldUserpic = GrabWidget(this, photoRect);
}
void UserpicButton::startNewPhotoShowing() {

View File

@ -118,6 +118,7 @@ QString GetOverride(const QString &familyName) {
} // Fonts
namespace Ui {
namespace {
class WidgetCreator : public QWidget {
@ -182,48 +183,61 @@ void SendPendingEventsRecursive(QWidget *target, bool parentHiddenFlag) {
} // namespace
void myEnsureResized(QWidget *target) {
if (!target) {
return;
}
void SendPendingMoveResizeEvents(not_null<QWidget*> target) {
CreateWidgetStateRecursive(target);
SendPendingEventsRecursive(target, !target->isVisible());
}
QPixmap myGrab(TWidget *target, QRect rect, QColor bg) {
myEnsureResized(target);
if (rect.isNull()) rect = target->rect();
auto result = QPixmap(rect.size() * cIntRetinaFactor());
result.setDevicePixelRatio(cRetinaFactor());
if (!target->testAttribute(Qt::WA_OpaquePaintEvent)) {
result.fill(bg);
QPixmap GrabWidget(not_null<TWidget*> target, QRect rect, QColor bg) {
SendPendingMoveResizeEvents(target);
if (rect.isNull()) {
rect = target->rect();
}
target->grabStart();
target->render(&result, QPoint(0, 0), rect, QWidget::DrawChildren | QWidget::IgnoreMask);
target->grabFinish();
return result;
}
QImage myGrabImage(TWidget *target, QRect rect, QColor bg) {
myEnsureResized(target);
if (rect.isNull()) rect = target->rect();
auto result = QImage(rect.size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
auto result = QPixmap(rect.size() * cIntRetinaFactor());
result.setDevicePixelRatio(cRetinaFactor());
if (!target->testAttribute(Qt::WA_OpaquePaintEvent)) {
result.fill(bg);
}
target->grabStart();
target->render(&result, QPoint(0, 0), rect, QWidget::DrawChildren | QWidget::IgnoreMask);
target->render(
&result,
QPoint(0, 0),
rect,
QWidget::DrawChildren | QWidget::IgnoreMask);
target->grabFinish();
return result;
}
QImage GrabWidgetToImage(not_null<TWidget*> target, QRect rect, QColor bg) {
Ui::SendPendingMoveResizeEvents(target);
if (rect.isNull()) {
rect = target->rect();
}
auto result = QImage(
rect.size() * cIntRetinaFactor(),
QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
if (!target->testAttribute(Qt::WA_OpaquePaintEvent)) {
result.fill(bg);
}
target->grabStart();
target->render(
&result,
QPoint(0, 0),
rect,
QWidget::DrawChildren | QWidget::IgnoreMask);
target->grabFinish();
return result;
}
} // namespace Ui
void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton button, const QPoint &globalPoint) {
if (auto windowHandle = widget->window()->windowHandle()) {
auto localPoint = windowHandle->mapFromGlobal(globalPoint);

View File

@ -29,6 +29,8 @@ QString GetOverride(const QString &familyName);
} // namespace
class TWidget;
template <typename Object>
class object_ptr;
@ -57,6 +59,17 @@ inline ChildWidget *AttachParentChild(
return nullptr;
}
void SendPendingMoveResizeEvents(not_null<QWidget*> target);
QPixmap GrabWidget(
not_null<TWidget*> target,
QRect rect = QRect(),
QColor bg = QColor(255, 255, 255, 0));
QImage GrabWidgetToImage(
not_null<TWidget*> target,
QRect rect = QRect(),
QColor bg = QColor(255, 255, 255, 0));
} // namespace Ui
enum class RectPart {
@ -209,8 +222,6 @@ private:
};
class TWidget;
template <typename Base>
class TWidgetHelper : public Base {
public:
@ -444,10 +455,6 @@ QPointer<const Widget> make_weak(const Widget *object) {
return QPointer<const Widget>(object);
}
void myEnsureResized(QWidget *target);
QPixmap myGrab(TWidget *target, QRect rect = QRect(), QColor bg = QColor(255, 255, 255, 0));
QImage myGrabImage(TWidget *target, QRect rect = QRect(), QColor bg = QColor(255, 255, 255, 0));
class SingleQueuedInvokation : public QObject {
public:
SingleQueuedInvokation(base::lambda<void()> callback) : _callback(callback) {

View File

@ -247,7 +247,7 @@ void InnerDropdown::prepareCache() {
auto showAnimation = base::take(_a_show);
auto showAnimationData = base::take(_showAnimation);
showChildren();
_cache = myGrab(this);
_cache = GrabWidget(this);
_showAnimation = base::take(showAnimationData);
_a_show = base::take(showAnimation);
if (_a_show.animating()) {
@ -305,7 +305,7 @@ void InnerDropdown::startShowAnimation() {
}
QImage InnerDropdown::grabForPanelAnimation() {
myEnsureResized(this);
SendPendingMoveResizeEvents(this);
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
result.fill(Qt::transparent);

View File

@ -244,7 +244,7 @@ bool FlatTextarea::heightAutoupdated() {
if (_minHeight < 0 || _maxHeight < 0 || _inHeightCheck) return false;
_inHeightCheck = true;
myEnsureResized(this);
SendPendingMoveResizeEvents(this);
int newh = ceil(document()->size().height()) + 2 * fakeMargin();
if (newh > _maxHeight) {
@ -1824,7 +1824,7 @@ bool InputArea::heightAutoupdated() {
if (_st.heightMin < 0 || _st.heightMax < 0 || _inHeightCheck) return false;
_inHeightCheck = true;
myEnsureResized(this);
SendPendingMoveResizeEvents(this);
int newh = qCeil(_inner->document()->size().height()) + _st.textMargins.top() + _st.textMargins.bottom();
if (newh > _st.heightMax) {

View File

@ -640,7 +640,12 @@ void FlatLabel::clickHandlerPressedChanged(const ClickHandlerPtr &action, bool a
update();
}
std::unique_ptr<CrossFadeAnimation> FlatLabel::CrossFade(FlatLabel *from, FlatLabel *to, style::color bg, QPoint fromPosition, QPoint toPosition) {
std::unique_ptr<CrossFadeAnimation> FlatLabel::CrossFade(
not_null<FlatLabel*> from,
not_null<FlatLabel*> to,
style::color bg,
QPoint fromPosition,
QPoint toPosition) {
auto result = std::make_unique<CrossFadeAnimation>(bg);
struct Data {
@ -649,9 +654,9 @@ std::unique_ptr<CrossFadeAnimation> FlatLabel::CrossFade(FlatLabel *from, FlatLa
int lineHeight = 0;
int lineAddTop = 0;
};
auto prepareData = [&bg](FlatLabel *label) {
auto prepareData = [&bg](not_null<FlatLabel*> label) {
auto result = Data();
result.full = myGrabImage(label, QRect(), bg->c);
result.full = GrabWidgetToImage(label, QRect(), bg->c);
auto textWidth = label->width() - label->_st.margin.left() - label->_st.margin.right();
label->_text.countLineWidths(textWidth, &result.lineWidths);
result.lineHeight = label->_st.style.font->height;

View File

@ -128,7 +128,12 @@ public:
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
static std::unique_ptr<CrossFadeAnimation> CrossFade(FlatLabel *from, FlatLabel *to, style::color bg, QPoint fromPosition = QPoint(), QPoint toPosition = QPoint());
static std::unique_ptr<CrossFadeAnimation> CrossFade(
not_null<FlatLabel*> from,
not_null<FlatLabel*> to,
style::color bg,
QPoint fromPosition = QPoint(),
QPoint toPosition = QPoint());
protected:
void paintEvent(QPaintEvent *e) override;

View File

@ -320,7 +320,7 @@ void PopupMenu::prepareCache() {
auto showAnimation = base::take(_a_show);
auto showAnimationData = base::take(_showAnimation);
showChildren();
_cache = myGrab(this);
_cache = GrabWidget(this);
_showAnimation = base::take(showAnimationData);
_a_show = base::take(showAnimation);
}
@ -396,7 +396,7 @@ void PopupMenu::showAnimationCallback() {
}
QImage PopupMenu::grabForPanelAnimation() {
myEnsureResized(this);
SendPendingMoveResizeEvents(this);
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
result.fill(Qt::transparent);

View File

@ -359,7 +359,9 @@ void ScrollArea::touchDeaccelerate(int32 elapsed) {
}
void ScrollArea::onScrolled() {
myEnsureResized(widget());
if (const auto inner = widget()) {
SendPendingMoveResizeEvents(inner);
}
bool em = false;
int horizontalValue = horizontalScrollBar()->value();
@ -703,8 +705,10 @@ void ScrollArea::scrollToWidget(not_null<QWidget*> widget) {
}
void ScrollArea::scrollToY(int toTop, int toBottom) {
myEnsureResized(widget());
myEnsureResized(this);
if (const auto inner = widget()) {
SendPendingMoveResizeEvents(inner);
}
SendPendingMoveResizeEvents(this);
int toMin = 0, toMax = scrollTopMax();
if (toTop < toMin) {

View File

@ -89,8 +89,11 @@ void Shadow::paint(Painter &p, const QRect &box, int outerWidth, const style::Sh
}
}
QPixmap Shadow::grab(TWidget *target, const style::Shadow &shadow, RectParts sides) {
myEnsureResized(target);
QPixmap Shadow::grab(
not_null<TWidget*> target,
const style::Shadow &shadow,
RectParts sides) {
SendPendingMoveResizeEvents(target);
auto rect = target->rect();
auto extend = QMargins(
(sides & RectPart::Left) ? shadow.extend.left() : 0,

View File

@ -42,14 +42,26 @@ private:
class Shadow : public TWidget {
public:
Shadow(QWidget *parent, const style::Shadow &st, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom) : TWidget(parent)
Shadow(
QWidget *parent,
const style::Shadow &st,
RectParts sides = RectPart::AllSides)
: TWidget(parent)
, _st(st)
, _sides(sides) {
}
static void paint(Painter &p, const QRect &box, int outerWidth, const style::Shadow &st, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom);
static void paint(
Painter &p,
const QRect &box,
int outerWidth,
const style::Shadow &st,
RectParts sides = RectPart::AllSides);
static QPixmap grab(TWidget *target, const style::Shadow &shadow, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom);
static QPixmap grab(
not_null<TWidget*> target,
const style::Shadow &shadow,
RectParts sides = RectPart::AllSides);
protected:
void paintEvent(QPaintEvent *e) override;

View File

@ -311,7 +311,7 @@ void ImportantTooltip::refreshAnimationCache() {
auto animation = base::take(_visibleAnimation);
auto visible = std::exchange(_visible, true);
showChildren();
_cache = myGrab(this);
_cache = GrabWidget(this);
_visible = base::take(visible);
_visibleAnimation = base::take(animation);
}

View File

@ -122,7 +122,7 @@ void SlideWrap<RpWidget>::animationStep() {
if (shouldBeHidden != isHidden()) {
setVisible(!shouldBeHidden);
if (shouldBeHidden) {
myEnsureResized(this);
SendPendingMoveResizeEvents(this);
}
}
}

View File

@ -405,7 +405,7 @@ void LayerStackWidget::setCacheImages() {
auto bodyCache = QPixmap(), mainMenuCache = QPixmap();
auto specialLayerCache = QPixmap();
if (_specialLayer) {
myEnsureResized(_specialLayer);
Ui::SendPendingMoveResizeEvents(_specialLayer);
auto sides = RectPart::Left | RectPart::Right;
if (_specialLayer->y() > 0) {
sides |= RectPart::Top;
@ -425,7 +425,7 @@ void LayerStackWidget::setCacheImages() {
if (_mainMenu) {
setAttribute(Qt::WA_OpaquePaintEvent, false);
hideChildren();
bodyCache = myGrab(App::wnd()->bodyWidget());
bodyCache = Ui::GrabWidget(App::wnd()->bodyWidget());
showChildren();
mainMenuCache = Ui::Shadow::grab(_mainMenu, st::boxRoundShadow, RectPart::Right);
}
@ -733,7 +733,7 @@ void LayerStackWidget::initChildLayer(LayerWidget *layer) {
layer->setClosedCallback([this, layer] { onLayerClosed(layer); });
layer->setResizedCallback([this] { onLayerResized(); });
connect(layer, SIGNAL(destroyed(QObject*)), this, SLOT(onLayerDestroyed(QObject*)));
myEnsureResized(layer);
Ui::SendPendingMoveResizeEvents(layer);
layer->parentResized();
}

View File

@ -539,7 +539,7 @@ void Notification::refreshLang() {
}
void Notification::prepareActionsCache() {
auto replyCache = myGrab(_reply);
auto replyCache = Ui::GrabWidget(_reply);
auto fadeWidth = st::notifyFadeRight.width();
auto actionsTop = st::notifyTextTop + st::msgNameFont->height;
auto replyRight = _replyPadding - st::notifyBorderWidth;

View File

@ -105,7 +105,7 @@ public:
// This can be used to grab with or without top bar shadow.
// This will be protected when animation preparation will be done inside.
virtual QPixmap grabForShowAnimation(const SectionSlideParams &params) {
return myGrab(this);
return Ui::GrabWidget(this);
}
// Attempt to show the required section inside the existing one.

View File

@ -136,8 +136,8 @@ void WarningWidget::startAnimation(bool hiding) {
_hiding = hiding;
if (_cache.isNull()) {
showChildren();
myEnsureResized(this);
_cache = myGrab(this, _outer);
Ui::SendPendingMoveResizeEvents(this);
_cache = Ui::GrabWidget(this, _outer);
}
hideChildren();
_animation.start([this] {