diff --git a/Telegram/Resources/icons/profile_divider_bottom.png b/Telegram/Resources/icons/profile_divider_bottom.png deleted file mode 100644 index 31fee84f91..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_bottom.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_bottom@2x.png b/Telegram/Resources/icons/profile_divider_bottom@2x.png deleted file mode 100644 index 87fb656212..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_bottom@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_bottom@3x.png b/Telegram/Resources/icons/profile_divider_bottom@3x.png deleted file mode 100644 index 99d87293e7..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_bottom@3x.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_left.png b/Telegram/Resources/icons/profile_divider_left.png deleted file mode 100644 index 9bcfd455e1..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_left.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_left@2x.png b/Telegram/Resources/icons/profile_divider_left@2x.png deleted file mode 100644 index b4488556ca..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_left@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_left@3x.png b/Telegram/Resources/icons/profile_divider_left@3x.png deleted file mode 100644 index ccf2312a9c..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_left@3x.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_top.png b/Telegram/Resources/icons/profile_divider_top.png deleted file mode 100644 index 6dcdc143c0..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_top.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_top@2x.png b/Telegram/Resources/icons/profile_divider_top@2x.png deleted file mode 100644 index 5bc32a739b..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_top@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/profile_divider_top@3x.png b/Telegram/Resources/icons/profile_divider_top@3x.png deleted file mode 100644 index 938e1e1c20..0000000000 Binary files a/Telegram/Resources/icons/profile_divider_top@3x.png and /dev/null differ diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index e5ad1c9a64..f2f8bd648d 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -2810,7 +2810,7 @@ void ApiWrap::requestAttachedStickerSets(not_null photo) { : MTP_inputStickerSetShortName(setData->vshort_name()); Ui::show( Box(App::wnd()->sessionController(), setId), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }).fail([=](const RPCError &error) { Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); @@ -4903,7 +4903,7 @@ void ApiWrap::editUploadedFile( _session->data().sendHistoryChangeNotifications(); Ui::show( Box(tr::lng_edit_media_invalid_file(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } else { sendMessageFail(error, peer); } diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 916b0ed02e..e783d4a621 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -45,7 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_mediaview.h" #include "styles/style_chat_helpers.h" #include "styles/style_history.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include #include diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index 38595e7651..c398302519 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "core/click_handler_types.h" #include "core/update_checker.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include diff --git a/Telegram/SourceFiles/boxes/about_box.h b/Telegram/SourceFiles/boxes/about_box.h index 4010000bb8..3ec637de26 100644 --- a/Telegram/SourceFiles/boxes/about_box.h +++ b/Telegram/SourceFiles/boxes/about_box.h @@ -14,7 +14,7 @@ class LinkButton; class FlatLabel; } // namespace Ui -class AboutBox : public BoxContent { +class AboutBox : public Ui::BoxContent { public: AboutBox(QWidget*); diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index 76bfe2582c..d9d7b7761c 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -7,606 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/abstract_box.h" -#include "styles/style_boxes.h" -#include "styles/style_profile.h" -#include "storage/localstorage.h" -#include "lang/lang_keys.h" -#include "ui/effects/radial_animation.h" -#include "ui/widgets/buttons.h" -#include "ui/widgets/scroll_area.h" -#include "ui/widgets/labels.h" -#include "ui/widgets/shadow.h" -#include "ui/wrap/fade_wrap.h" -#include "ui/text/text_utilities.h" -#include "ui/painter.h" -#include "base/timer.h" #include "mainwidget.h" #include "mainwindow.h" #include "app.h" -struct AbstractBox::LoadingProgress { - LoadingProgress( - Fn &&callback, - const style::InfiniteRadialAnimation &st); - - Ui::InfiniteRadialAnimation animation; - base::Timer removeTimer; -}; - -AbstractBox::LoadingProgress::LoadingProgress( - Fn &&callback, - const style::InfiniteRadialAnimation &st) -: animation(std::move(callback), st) { -} - -void BoxContent::setTitle(rpl::producer title) { - getDelegate()->setTitle(std::move(title) | Ui::Text::ToWithEntities()); -} - -QPointer BoxContent::addButton( - rpl::producer text, - Fn clickCallback) { - return addButton( - std::move(text), - std::move(clickCallback), - st::defaultBoxButton); -} - -QPointer BoxContent::addLeftButton( - rpl::producer text, - Fn clickCallback) { - return getDelegate()->addLeftButton( - std::move(text), - std::move(clickCallback), - st::defaultBoxButton); -} - -void BoxContent::setInner(object_ptr inner) { - setInner(std::move(inner), st::boxLayerScroll); -} - -void BoxContent::setInner(object_ptr inner, const style::ScrollArea &st) { - if (inner) { - getDelegate()->setLayerType(true); - _scroll.create(this, st); - _scroll->setGeometryToLeft(0, _innerTopSkip, width(), 0); - _scroll->setOwnedWidget(std::move(inner)); - if (_topShadow) { - _topShadow->raise(); - _bottomShadow->raise(); - } else { - _topShadow.create(this); - _bottomShadow.create(this); - } - if (!_preparing) { - // We didn't set dimensions yet, this will be called from finishPrepare(); - finishScrollCreate(); - } - } else { - getDelegate()->setLayerType(false); - _scroll.destroyDelayed(); - _topShadow.destroyDelayed(); - _bottomShadow.destroyDelayed(); - } -} - -void BoxContent::finishPrepare() { - _preparing = false; - if (_scroll) { - finishScrollCreate(); - } - setInnerFocus(); -} - -void BoxContent::finishScrollCreate() { - Expects(_scroll != nullptr); - - if (!_scroll->isHidden()) { - _scroll->show(); - } - updateScrollAreaGeometry(); - connect(_scroll, SIGNAL(scrolled()), this, SLOT(onScroll())); - connect(_scroll, SIGNAL(innerResized()), this, SLOT(onInnerResize())); -} - -void BoxContent::scrollToWidget(not_null widget) { - if (_scroll) { - _scroll->scrollToWidget(widget); - } -} - -void BoxContent::onScrollToY(int top, int bottom) { - if (_scroll) { - _scroll->scrollToY(top, bottom); - } -} - -void BoxContent::onDraggingScrollDelta(int delta) { - _draggingScrollDelta = _scroll ? delta : 0; - if (_draggingScrollDelta) { - if (!_draggingScrollTimer) { - _draggingScrollTimer.create(this); - _draggingScrollTimer->setSingleShot(false); - connect(_draggingScrollTimer, SIGNAL(timeout()), this, SLOT(onDraggingScrollTimer())); - } - _draggingScrollTimer->start(15); - } else { - _draggingScrollTimer.destroy(); - } -} - -void BoxContent::onDraggingScrollTimer() { - auto delta = (_draggingScrollDelta > 0) ? qMin(_draggingScrollDelta * 3 / 20 + 1, int32(Ui::kMaxScrollSpeed)) : qMax(_draggingScrollDelta * 3 / 20 - 1, -int32(Ui::kMaxScrollSpeed)); - _scroll->scrollToY(_scroll->scrollTop() + delta); -} - -void BoxContent::updateInnerVisibleTopBottom() { - if (auto widget = static_cast(_scroll ? _scroll->widget() : nullptr)) { - auto top = _scroll->scrollTop(); - widget->setVisibleTopBottom(top, top + _scroll->height()); - } -} - -void BoxContent::updateShadowsVisibility() { - if (!_scroll) return; - - auto top = _scroll->scrollTop(); - _topShadow->toggle( - (top > 0 || _innerTopSkip > 0), - anim::type::normal); - _bottomShadow->toggle( - (top < _scroll->scrollTopMax() || _innerBottomSkip > 0), - anim::type::normal); -} - -void BoxContent::onScroll() { - updateInnerVisibleTopBottom(); - updateShadowsVisibility(); -} - -void BoxContent::onInnerResize() { - updateInnerVisibleTopBottom(); - updateShadowsVisibility(); -} - -void BoxContent::setDimensionsToContent( - int newWidth, - not_null content) { - content->resizeToWidth(newWidth); - content->heightValue( - ) | rpl::start_with_next([=](int height) { - setDimensions(newWidth, height); - }, content->lifetime()); -} - -void BoxContent::setInnerTopSkip(int innerTopSkip, bool scrollBottomFixed) { - if (_innerTopSkip != innerTopSkip) { - auto delta = innerTopSkip - _innerTopSkip; - _innerTopSkip = innerTopSkip; - if (_scroll && width() > 0) { - auto scrollTopWas = _scroll->scrollTop(); - updateScrollAreaGeometry(); - if (scrollBottomFixed) { - _scroll->scrollToY(scrollTopWas + delta); - } - } - } -} - -void BoxContent::setInnerBottomSkip(int innerBottomSkip) { - if (_innerBottomSkip != innerBottomSkip) { - auto delta = innerBottomSkip - _innerBottomSkip; - _innerBottomSkip = innerBottomSkip; - if (_scroll && width() > 0) { - updateScrollAreaGeometry(); - } - } -} - -void BoxContent::setInnerVisible(bool scrollAreaVisible) { - if (_scroll) { - _scroll->setVisible(scrollAreaVisible); - } -} - -QPixmap BoxContent::grabInnerCache() { - auto isTopShadowVisible = !_topShadow->isHidden(); - auto isBottomShadowVisible = !_bottomShadow->isHidden(); - if (isTopShadowVisible) _topShadow->setVisible(false); - if (isBottomShadowVisible) _bottomShadow->setVisible(false); - auto result = Ui::GrabWidget(this, _scroll->geometry()); - if (isTopShadowVisible) _topShadow->setVisible(true); - if (isBottomShadowVisible) _bottomShadow->setVisible(true); - return result; -} - -void BoxContent::resizeEvent(QResizeEvent *e) { - if (_scroll) { - updateScrollAreaGeometry(); - } -} - -void BoxContent::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Escape && !_closeByEscape) { - e->accept(); - } else { - RpWidget::keyPressEvent(e); - } -} - -void BoxContent::updateScrollAreaGeometry() { - auto newScrollHeight = height() - _innerTopSkip - _innerBottomSkip; - auto changed = (_scroll->height() != newScrollHeight); - _scroll->setGeometryToLeft(0, _innerTopSkip, width(), newScrollHeight); - _topShadow->entity()->resize(width(), st::lineWidth); - _topShadow->moveToLeft(0, _innerTopSkip); - _bottomShadow->entity()->resize(width(), st::lineWidth); - _bottomShadow->moveToLeft( - 0, - height() - _innerBottomSkip - st::lineWidth); - if (changed) { - updateInnerVisibleTopBottom(); - - auto top = _scroll->scrollTop(); - _topShadow->toggle( - (top > 0 || _innerTopSkip > 0), - anim::type::instant); - _bottomShadow->toggle( - (top < _scroll->scrollTopMax() || _innerBottomSkip > 0), - anim::type::instant); - } -} - -object_ptr BoxContent::doTakeInnerWidget() { - return _scroll->takeWidget(); -} - -void BoxContent::paintEvent(QPaintEvent *e) { - Painter p(this); - - if (testAttribute(Qt::WA_OpaquePaintEvent)) { - for (auto rect : e->region().rects()) { - p.fillRect(rect, st::boxBg); - } - } -} - -AbstractBox::AbstractBox( - not_null layer, - object_ptr content) -: LayerWidget(layer) -, _layer(layer) -, _content(std::move(content)) { - _content->setParent(this); - _content->setDelegate(this); - - _additionalTitle.changes( - ) | rpl::start_with_next([=] { - updateSize(); - update(); - }, lifetime()); -} - -AbstractBox::~AbstractBox() = default; - -void AbstractBox::setLayerType(bool layerType) { - _layerType = layerType; - updateTitlePosition(); -} - -int AbstractBox::titleHeight() const { - return _layerType ? st::boxLayerTitleHeight : st::boxTitleHeight; -} - -int AbstractBox::buttonsHeight() const { - const auto padding = _layerType - ? st::boxLayerButtonPadding - : st::boxButtonPadding; - return padding.top() + st::defaultBoxButton.height + padding.bottom(); -} - -int AbstractBox::buttonsTop() const { - const auto padding = _layerType - ? st::boxLayerButtonPadding - : st::boxButtonPadding; - return height() - padding.bottom() - st::defaultBoxButton.height; -} - -QRect AbstractBox::loadingRect() const { - const auto padding = _layerType - ? st::boxLayerButtonPadding - : st::boxButtonPadding; - const auto size = st::boxLoadingSize; - const auto skipx = _layerType - ? st::boxLayerTitlePosition.x() - : st::boxTitlePosition.x(); - const auto skipy = (st::defaultBoxButton.height - size) / 2; - return QRect( - skipx, - height() - padding.bottom() - skipy - size, - size, - size); -} - -void AbstractBox::paintEvent(QPaintEvent *e) { - Painter p(this); - auto clip = e->rect(); - auto paintTopRounded = clip.intersects(QRect(0, 0, width(), st::boxRadius)); - auto paintBottomRounded = clip.intersects(QRect(0, height() - st::boxRadius, width(), st::boxRadius)); - if (paintTopRounded || paintBottomRounded) { - auto parts = RectPart::None | 0; - if (paintTopRounded) parts |= RectPart::FullTop; - if (paintBottomRounded) parts |= RectPart::FullBottom; - App::roundRect(p, rect(), st::boxBg, BoxCorners, nullptr, parts); - } - auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); - if (!other.isEmpty()) { - for (auto rect : other.rects()) { - p.fillRect(rect, st::boxBg); - } - } - if (!_additionalTitle.current().isEmpty() - && clip.intersects(QRect(0, 0, width(), titleHeight()))) { - paintAdditionalTitle(p); - } - if (_loadingProgress) { - const auto rect = loadingRect(); - _loadingProgress->animation.draw( - p, - rect.topLeft(), - rect.size(), - width()); - } -} - -void AbstractBox::paintAdditionalTitle(Painter &p) { - p.setFont(st::boxLayerTitleAdditionalFont); - p.setPen(st::boxTitleAdditionalFg); - p.drawTextLeft(_titleLeft + (_title ? _title->width() : 0) + st::boxLayerTitleAdditionalSkip, _titleTop + st::boxTitleFont->ascent - st::boxLayerTitleAdditionalFont->ascent, width(), _additionalTitle.current()); -} - -void AbstractBox::parentResized() { - auto newHeight = countRealHeight(); - auto parentSize = parentWidget()->size(); - setGeometry((parentSize.width() - width()) / 2, (parentSize.height() - newHeight) / 2, width(), newHeight); - update(); -} - -void AbstractBox::setTitle(rpl::producer title) { - const auto wasTitle = hasTitle(); - if (title) { - _title.create(this, std::move(title), st::boxTitle); - _title->show(); - updateTitlePosition(); - } else { - _title.destroy(); - } - if (wasTitle != hasTitle()) { - updateSize(); - } -} - -void AbstractBox::setAdditionalTitle(rpl::producer additional) { - _additionalTitle = std::move(additional); -} - -void AbstractBox::setCloseByOutsideClick(bool close) { - _closeByOutsideClick = close; -} - -bool AbstractBox::closeByOutsideClick() const { - return _closeByOutsideClick; -} - -bool AbstractBox::hasTitle() const { - return (_title != nullptr) || !_additionalTitle.current().isEmpty(); -} - -void AbstractBox::showBox( - object_ptr box, - LayerOptions options, - anim::type animated) { - _layer->showBox(std::move(box), options, animated); -} - -void AbstractBox::updateSize() { - setDimensions(width(), _maxContentHeight); -} - -void AbstractBox::updateButtonsPositions() { - if (!_buttons.empty() || _leftButton) { - auto padding = _layerType ? st::boxLayerButtonPadding : st::boxButtonPadding; - auto right = padding.right(); - auto top = buttonsTop(); - if (_leftButton) { - _leftButton->moveToLeft(right, top); - } - for (const auto &button : _buttons) { - button->moveToRight(right, top); - right += button->width() + padding.left(); - } - } - if (_topButton) { - _topButton->moveToRight(0, 0); - } -} - -QPointer AbstractBox::outerContainer() { - return parentWidget(); -} - -void AbstractBox::updateTitlePosition() { - _titleLeft = _layerType ? st::boxLayerTitlePosition.x() : st::boxTitlePosition.x(); - _titleTop = _layerType ? st::boxLayerTitlePosition.y() : st::boxTitlePosition.y(); - if (_title) { - _title->resizeToWidth(qMin(_title->naturalWidth(), width() - _titleLeft * 2)); - _title->moveToLeft(_titleLeft, _titleTop); - } -} - -void AbstractBox::clearButtons() { - for (auto &button : base::take(_buttons)) { - button.destroy(); - } - _leftButton.destroy(); - _topButton = nullptr; -} - -QPointer AbstractBox::addButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) { - _buttons.emplace_back(this, std::move(text), st); - auto result = QPointer(_buttons.back()); - result->setClickedCallback(std::move(clickCallback)); - result->show(); - result->widthValue( - ) | rpl::start_with_next([=] { - updateButtonsPositions(); - }, result->lifetime()); - return result; -} - -QPointer AbstractBox::addLeftButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) { - _leftButton = object_ptr(this, std::move(text), st); - auto result = QPointer(_leftButton); - result->setClickedCallback(std::move(clickCallback)); - result->show(); - result->widthValue( - ) | rpl::start_with_next([=] { - updateButtonsPositions(); - }, result->lifetime()); - return result; -} - -QPointer AbstractBox::addTopButton(const style::IconButton &st, Fn clickCallback) { - _topButton = base::make_unique_q(this, st); - auto result = QPointer(_topButton.get()); - result->setClickedCallback(std::move(clickCallback)); - result->show(); - updateButtonsPositions(); - return result; -} - -void AbstractBox::showLoading(bool show) { - const auto &st = st::boxLoadingAnimation; - if (!show) { - if (_loadingProgress && !_loadingProgress->removeTimer.isActive()) { - _loadingProgress->removeTimer.callOnce( - st.sineDuration + st.sinePeriod); - _loadingProgress->animation.stop(); - } - return; - } - if (!_loadingProgress) { - const auto callback = [=] { - if (!anim::Disabled()) { - const auto t = st::boxLoadingAnimation.thickness; - update(loadingRect().marginsAdded({ t, t, t, t })); - } - }; - _loadingProgress = std::make_unique( - callback, - st::boxLoadingAnimation); - _loadingProgress->removeTimer.setCallback([=] { - _loadingProgress = nullptr; - }); - } else { - _loadingProgress->removeTimer.cancel(); - } - _loadingProgress->animation.start(); -} - - -void AbstractBox::setDimensions(int newWidth, int maxHeight, bool forceCenterPosition) { - _maxContentHeight = maxHeight; - - auto fullHeight = countFullHeight(); - if (width() != newWidth || _fullHeight != fullHeight) { - _fullHeight = fullHeight; - if (parentWidget()) { - auto oldGeometry = geometry(); - resize(newWidth, countRealHeight()); - auto newGeometry = geometry(); - auto parentHeight = parentWidget()->height(); - if (newGeometry.top() + newGeometry.height() + st::boxVerticalMargin > parentHeight - || forceCenterPosition) { - const auto top1 = parentHeight - int(st::boxVerticalMargin) - newGeometry.height(); - const auto top2 = (parentHeight - newGeometry.height()) / 2; - const auto newTop = forceCenterPosition - ? std::min(top1, top2) - : std::max(top1, top2); - if (newTop != newGeometry.top()) { - move(newGeometry.left(), newTop); - resizeEvent(0); - } - } - parentWidget()->update(oldGeometry.united(geometry()).marginsAdded(st::boxRoundShadow.extend)); - } else { - resize(newWidth, 0); - } - } -} - -int AbstractBox::countRealHeight() const { - return qMin(_fullHeight, parentWidget()->height() - 2 * st::boxVerticalMargin); -} - -int AbstractBox::countFullHeight() const { - return contentTop() + _maxContentHeight + buttonsHeight(); -} - -int AbstractBox::contentTop() const { - return hasTitle() ? titleHeight() : (_noContentMargin ? 0 : st::boxTopMargin); -} - -void AbstractBox::resizeEvent(QResizeEvent *e) { - updateButtonsPositions(); - updateTitlePosition(); - - auto top = contentTop(); - _content->resize(width(), height() - top - buttonsHeight()); - _content->moveToLeft(0, top); - - LayerWidget::resizeEvent(e); -} - -void AbstractBox::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Escape) { - closeBox(); - } else { - LayerWidget::keyPressEvent(e); - } -} - -BoxContentDivider::BoxContentDivider(QWidget *parent) -: BoxContentDivider(parent, st::rightsDividerHeight) { -} - -BoxContentDivider::BoxContentDivider(QWidget *parent, int height) -: RpWidget(parent) { - resize(width(), height); -} - -void BoxContentDivider::paintEvent(QPaintEvent *e) { - Painter p(this); - p.fillRect(e->rect(), st::contactsAboutBg); - auto dividerFillTop = myrtlrect(0, 0, width(), st::profileDividerTop.height()); - st::profileDividerTop.fill(p, dividerFillTop); - auto dividerFillBottom = myrtlrect(0, height() - st::profileDividerBottom.height(), width(), st::profileDividerBottom.height()); - st::profileDividerBottom.fill(p, dividerFillBottom); -} - namespace Ui { namespace internal { void showBox( - object_ptr content, - LayerOptions options, - anim::type animated) { + object_ptr content, + LayerOptions options, + anim::type animated) { if (auto w = App::wnd()) { w->ui_showBox(std::move(content), options, animated); } @@ -634,14 +45,4 @@ bool isLayerShown() { return false; } -int DividerLabel::naturalWidth() const { - return -1; -} - -void DividerLabel::resizeEvent(QResizeEvent *e) { - _background->lower(); - _background->setGeometry(rect()); - return PaddingWrap::resizeEvent(e); -} - } // namespace Ui diff --git a/Telegram/SourceFiles/boxes/abstract_box.h b/Telegram/SourceFiles/boxes/abstract_box.h index d08b97c22e..95d15f0388 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.h +++ b/Telegram/SourceFiles/boxes/abstract_box.h @@ -7,14 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "window/layer_widget.h" -#include "base/unique_qptr.h" -#include "base/flags.h" -#include "ui/wrap/padding_wrap.h" -#include "ui/widgets/labels.h" -#include "ui/effects/animation_value.h" -#include "ui/text/text_entity.h" -#include "ui/rp_widget.h" +#include "ui/layers/box_layer_widget.h" class Painter; @@ -32,413 +25,13 @@ class FlatLabel; class FadeShadow; } // namespace Ui -class BoxContent; - -class BoxContentDelegate { -public: - virtual void setLayerType(bool layerType) = 0; - virtual void setTitle(rpl::producer title) = 0; - virtual void setAdditionalTitle(rpl::producer additional) = 0; - virtual void setCloseByOutsideClick(bool close) = 0; - - virtual void clearButtons() = 0; - virtual QPointer addButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) = 0; - virtual QPointer addLeftButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) = 0; - virtual QPointer addTopButton( - const style::IconButton &st, - Fn clickCallback) = 0; - virtual void showLoading(bool show) = 0; - virtual void updateButtonsPositions() = 0; - - virtual void showBox( - object_ptr box, - LayerOptions options, - anim::type animated) = 0; - virtual void setDimensions( - int newWidth, - int maxHeight, - bool forceCenterPosition = false) = 0; - virtual void setNoContentMargin(bool noContentMargin) = 0; - virtual bool isBoxShown() const = 0; - virtual void closeBox() = 0; - - template - QPointer show( - object_ptr content, - LayerOptions options = LayerOption::KeepOther, - anim::type animated = anim::type::normal) { - auto result = QPointer(content.data()); - showBox(std::move(content), options, animated); - return result; - } - - virtual QPointer outerContainer() = 0; - -}; - -class BoxContent : public Ui::RpWidget { - Q_OBJECT - -public: - BoxContent() { - setAttribute(Qt::WA_OpaquePaintEvent); - } - - bool isBoxShown() const { - return getDelegate()->isBoxShown(); - } - void closeBox() { - getDelegate()->closeBox(); - } - - void setTitle(rpl::producer title); - void setTitle(rpl::producer title) { - getDelegate()->setTitle(std::move(title)); - } - void setAdditionalTitle(rpl::producer additional) { - getDelegate()->setAdditionalTitle(std::move(additional)); - } - void setCloseByEscape(bool close) { - _closeByEscape = close; - } - void setCloseByOutsideClick(bool close) { - getDelegate()->setCloseByOutsideClick(close); - } - - void scrollToWidget(not_null widget); - - void clearButtons() { - getDelegate()->clearButtons(); - } - QPointer addButton( - rpl::producer text, - Fn clickCallback = nullptr); - QPointer addLeftButton( - rpl::producer text, - Fn clickCallback = nullptr); - QPointer addTopButton( - const style::IconButton &st, - Fn clickCallback = nullptr) { - return getDelegate()->addTopButton(st, std::move(clickCallback)); - } - QPointer addButton( - rpl::producer text, - const style::RoundButton &st) { - return getDelegate()->addButton(std::move(text), nullptr, st); - } - QPointer addButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) { - return getDelegate()->addButton( - std::move(text), - std::move(clickCallback), - st); - } - void showLoading(bool show) { - getDelegate()->showLoading(show); - } - void updateButtonsGeometry() { - getDelegate()->updateButtonsPositions(); - } - - virtual void setInnerFocus() { - setFocus(); - } - - rpl::producer<> boxClosing() const { - return _boxClosingStream.events(); - } - void notifyBoxClosing() { - _boxClosingStream.fire({}); - } - - void setDelegate(not_null newDelegate) { - _delegate = newDelegate; - _preparing = true; - prepare(); - finishPrepare(); - } - not_null getDelegate() const { - return _delegate; - } - -public slots: - void onScrollToY(int top, int bottom = -1); - - void onDraggingScrollDelta(int delta); - -protected: - virtual void prepare() = 0; - - void setLayerType(bool layerType) { - getDelegate()->setLayerType(layerType); - } - - void setNoContentMargin(bool noContentMargin) { - if (_noContentMargin != noContentMargin) { - _noContentMargin = noContentMargin; - setAttribute(Qt::WA_OpaquePaintEvent, !_noContentMargin); - } - getDelegate()->setNoContentMargin(noContentMargin); - } - void setDimensions( - int newWidth, - int maxHeight, - bool forceCenterPosition = false) { - getDelegate()->setDimensions( - newWidth, - maxHeight, - forceCenterPosition); - } - void setDimensionsToContent( - int newWidth, - not_null content); - void setInnerTopSkip(int topSkip, bool scrollBottomFixed = false); - void setInnerBottomSkip(int bottomSkip); - - template - QPointer setInnerWidget( - object_ptr inner, - const style::ScrollArea &st, - int topSkip = 0, - int bottomSkip = 0) { - auto result = QPointer(inner.data()); - setInnerTopSkip(topSkip); - setInnerBottomSkip(bottomSkip); - setInner(std::move(inner), st); - return result; - } - - template - QPointer setInnerWidget( - object_ptr inner, - int topSkip = 0, - int bottomSkip = 0) { - auto result = QPointer(inner.data()); - setInnerTopSkip(topSkip); - setInnerBottomSkip(bottomSkip); - setInner(std::move(inner)); - return result; - } - - template - object_ptr takeInnerWidget() { - return object_ptr::fromRaw( - static_cast(doTakeInnerWidget().release())); - } - - void setInnerVisible(bool scrollAreaVisible); - QPixmap grabInnerCache(); - - void resizeEvent(QResizeEvent *e) override; - void paintEvent(QPaintEvent *e) override; - void keyPressEvent(QKeyEvent *e) override; - -private slots: - void onScroll(); - void onInnerResize(); - - void onDraggingScrollTimer(); - -private: - void finishPrepare(); - void finishScrollCreate(); - void setInner(object_ptr inner); - void setInner(object_ptr inner, const style::ScrollArea &st); - void updateScrollAreaGeometry(); - void updateInnerVisibleTopBottom(); - void updateShadowsVisibility(); - object_ptr doTakeInnerWidget(); - - BoxContentDelegate *_delegate = nullptr; - - bool _preparing = false; - bool _noContentMargin = false; - bool _closeByEscape = true; - int _innerTopSkip = 0; - int _innerBottomSkip = 0; - object_ptr _scroll = { nullptr }; - object_ptr _topShadow = { nullptr }; - object_ptr _bottomShadow = { nullptr }; - - object_ptr _draggingScrollTimer = { nullptr }; - int _draggingScrollDelta = 0; - - rpl::event_stream<> _boxClosingStream; - -}; - -class AbstractBox : public Window::LayerWidget, public BoxContentDelegate { -public: - AbstractBox( - not_null layer, - object_ptr content); - ~AbstractBox(); - - void parentResized() override; - - void setLayerType(bool layerType) override; - void setTitle(rpl::producer title) override; - void setAdditionalTitle(rpl::producer additional) override; - void showBox( - object_ptr box, - LayerOptions options, - anim::type animated) override; - - void clearButtons() override; - QPointer addButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) override; - QPointer addLeftButton( - rpl::producer text, - Fn clickCallback, - const style::RoundButton &st) override; - QPointer addTopButton( - const style::IconButton &st, - Fn clickCallback) override; - void showLoading(bool show) override; - void updateButtonsPositions() override; - QPointer outerContainer() override; - - void setDimensions( - int newWidth, - int maxHeight, - bool forceCenterPosition = false) override; - - void setNoContentMargin(bool noContentMargin) override { - if (_noContentMargin != noContentMargin) { - _noContentMargin = noContentMargin; - updateSize(); - } - } - - bool isBoxShown() const override { - return !isHidden(); - } - void closeBox() override { - closeLayer(); - } - - void setCloseByOutsideClick(bool close) override; - bool closeByOutsideClick() const override; - -protected: - void keyPressEvent(QKeyEvent *e) override; - void resizeEvent(QResizeEvent *e) override; - void paintEvent(QPaintEvent *e) override; - - void doSetInnerFocus() override { - _content->setInnerFocus(); - } - void closeHook() override { - _content->notifyBoxClosing(); - } - -private: - struct LoadingProgress; - - void paintAdditionalTitle(Painter &p); - void updateTitlePosition(); - - [[nodiscard]] bool hasTitle() const; - [[nodiscard]] int titleHeight() const; - [[nodiscard]] int buttonsHeight() const; - [[nodiscard]] int buttonsTop() const; - [[nodiscard]] int contentTop() const; - [[nodiscard]] int countFullHeight() const; - [[nodiscard]] int countRealHeight() const; - [[nodiscard]] QRect loadingRect() const; - void updateSize(); - - not_null _layer; - int _fullHeight = 0; - - bool _noContentMargin = false; - int _maxContentHeight = 0; - object_ptr _content; - - object_ptr _title = { nullptr }; - Fn _titleFactory; - rpl::variable _additionalTitle; - int _titleLeft = 0; - int _titleTop = 0; - bool _layerType = false; - bool _closeByOutsideClick = true; - - std::vector> _buttons; - object_ptr _leftButton = { nullptr }; - base::unique_qptr _topButton = { nullptr }; - std::unique_ptr _loadingProgress; - -}; - -class BoxContentDivider : public Ui::RpWidget { -public: - BoxContentDivider(QWidget *parent); - BoxContentDivider(QWidget *parent, int height); - -protected: - void paintEvent(QPaintEvent *e) override; - -}; - -class BoxPointer { -public: - BoxPointer() = default; - BoxPointer(const BoxPointer &other) = default; - BoxPointer(BoxPointer &&other) : _value(base::take(other._value)) { - } - BoxPointer &operator=(const BoxPointer &other) { - if (_value != other._value) { - destroy(); - _value = other._value; - } - return *this; - } - BoxPointer &operator=(BoxPointer &&other) { - if (_value != other._value) { - destroy(); - _value = base::take(other._value); - } - return *this; - } - BoxPointer &operator=(BoxContent *other) { - if (_value != other) { - destroy(); - _value = other; - } - return *this; - } - ~BoxPointer() { - destroy(); - } - -private: - void destroy() { - if (const auto value = base::take(_value)) { - value->closeBox(); - } - } - - QPointer _value; - -}; - // Legacy global method. namespace Ui { namespace internal { void showBox( object_ptr content, - LayerOptions options, + Ui::LayerOptions options, anim::type animated); } // namespace internal @@ -446,7 +39,7 @@ void showBox( template QPointer show( object_ptr content, - LayerOptions options = LayerOption::CloseOther, + Ui::LayerOptions options = Ui::LayerOption::CloseOther, anim::type animated = anim::type::normal) { auto result = QPointer(content.data()); internal::showBox(std::move(content), options, animated); @@ -457,19 +50,4 @@ void hideLayer(anim::type animated = anim::type::normal); void hideSettingsAndLayer(anim::type animated = anim::type::normal); bool isLayerShown(); -class DividerLabel : public PaddingWrap { -public: - using PaddingWrap::PaddingWrap; - - int naturalWidth() const override; - -protected: - void resizeEvent(QResizeEvent *e) override; - -private: - object_ptr _background - = object_ptr(this); - -}; - } // namespace Ui diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 728afe6ed2..9d5356464f 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/add_contact_box.h" -#include "styles/style_boxes.h" -#include "styles/style_dialogs.h" #include "lang/lang_keys.h" #include "mtproto/sender.h" #include "base/flat_set.h" @@ -42,6 +40,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "observer_peer.h" #include "main/main_session.h" #include "facades.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" +#include "styles/style_dialogs.h" #include #include @@ -164,7 +165,7 @@ void ShowAddParticipantsError( tr::lng_cant_invite_make_admin(tr::now), tr::lng_cancel(tr::now), makeAdmin), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -199,7 +200,7 @@ void ShowAddParticipantsError( } return tr::lng_failed_add_participant(tr::now); }(); - Ui::show(Box(text), LayerOption::KeepOther); + Ui::show(Box(text), Ui::LayerOption::KeepOther); } class RevokePublicLinkBox::Inner : public TWidget, private MTP::Sender { @@ -588,16 +589,16 @@ void GroupInfoBox::createGroup( } else if (error.type() == qstr("USERS_TOO_FEW")) { Ui::show( Box(tr::lng_cant_invite_privacy(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } else if (error.type() == qstr("PEER_FLOOD")) { Ui::show( Box( PeerFloodErrorText(PeerFloodType::InviteGroup)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } else if (error.type() == qstr("USER_RESTRICTED")) { Ui::show( Box(tr::lng_cant_do_this(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } }).send(); } @@ -636,7 +637,7 @@ void GroupInfoBox::submit() { Box( std::make_unique(_navigation), std::move(initBox)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } @@ -1031,7 +1032,7 @@ void SetupChannelBox::privacyChanged(Privacy value) { Box( &_channel->session(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } _link->show(); @@ -1126,14 +1127,14 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() { const auto callback = [=] { Ui::show( Box(navigation, channel, existing), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }; closeBox(); Ui::show( Box( &channel->session(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool SetupChannelBox::onFirstCheckFail(const RPCError &error) { @@ -1412,7 +1413,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) { callback(); } }).send(); - })), LayerOption::KeepOther); + })), Ui::LayerOption::KeepOther); } } diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index 76231b4be5..e97eff55e8 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -54,7 +54,7 @@ void ShowAddParticipantsError( not_null chat, const std::vector> &users); -class AddContactBox : public BoxContent { +class AddContactBox : public Ui::BoxContent { public: AddContactBox(QWidget*, not_null session); AddContactBox( @@ -94,7 +94,7 @@ private: }; -class GroupInfoBox : public BoxContent, private MTP::Sender { +class GroupInfoBox : public Ui::BoxContent, private MTP::Sender { public: enum class Type { Group, @@ -140,7 +140,7 @@ private: }; class SetupChannelBox - : public BoxContent + : public Ui::BoxContent , public RPCSender , private base::Subscriber { public: @@ -209,7 +209,7 @@ private: }; -class EditNameBox : public BoxContent, public RPCSender { +class EditNameBox : public Ui::BoxContent, public RPCSender { public: EditNameBox(QWidget*, not_null user); @@ -238,7 +238,7 @@ private: }; class RevokePublicLinkBox - : public BoxContent + : public Ui::BoxContent , public RPCSender , private base::Subscriber { public: diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index 7ba178507e..bc4351e332 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "settings/settings_common.h" #include "export/view/export_view_settings.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_settings.h" diff --git a/Telegram/SourceFiles/boxes/auto_download_box.h b/Telegram/SourceFiles/boxes/auto_download_box.h index 50fefad68f..617a4e2038 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.h +++ b/Telegram/SourceFiles/boxes/auto_download_box.h @@ -19,7 +19,7 @@ enum class Source; } // namespace AutoDownload } // namespace Data -class AutoDownloadBox : public BoxContent { +class AutoDownloadBox : public Ui::BoxContent { public: AutoDownloadBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/auto_lock_box.cpp b/Telegram/SourceFiles/boxes/auto_lock_box.cpp index cc04ccb776..9cbfbbf253 100644 --- a/Telegram/SourceFiles/boxes/auto_lock_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_lock_box.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "ui/widgets/checkbox.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" AutoLockBox::AutoLockBox(QWidget*, not_null session) diff --git a/Telegram/SourceFiles/boxes/auto_lock_box.h b/Telegram/SourceFiles/boxes/auto_lock_box.h index 903510236e..13cd573d5a 100644 --- a/Telegram/SourceFiles/boxes/auto_lock_box.h +++ b/Telegram/SourceFiles/boxes/auto_lock_box.h @@ -17,7 +17,7 @@ namespace Ui { class Radiobutton; } // namespace Ui -class AutoLockBox : public BoxContent { +class AutoLockBox : public Ui::BoxContent { public: AutoLockBox(QWidget*, not_null session); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 7dd55753b9..9d91c177af 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/confirm_box.h" #include "app.h" #include "styles/style_overview.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" @@ -144,7 +145,7 @@ void BackgroundBox::prepare() { ) | rpl::start_with_next([=](const Data::WallPaper &paper) { Ui::show( Box(_session, paper), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }, _inner->lifetime()); _inner->removeRequests( @@ -154,7 +155,7 @@ void BackgroundBox::prepare() { } void BackgroundBox::removePaper(const Data::WallPaper &paper) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto session = _session; const auto remove = [=, weak = Ui::MakeWeak(this)]{ if (*box) { @@ -176,7 +177,7 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) { tr::lng_selected_delete(tr::now), tr::lng_cancel(tr::now), remove), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } BackgroundBox::Inner::Inner( diff --git a/Telegram/SourceFiles/boxes/background_box.h b/Telegram/SourceFiles/boxes/background_box.h index 4dbfae4677..dbfd8439e9 100644 --- a/Telegram/SourceFiles/boxes/background_box.h +++ b/Telegram/SourceFiles/boxes/background_box.h @@ -17,7 +17,7 @@ namespace Data { class WallPaper; } // namespace Data -class BackgroundBox : public BoxContent { +class BackgroundBox : public Ui::BoxContent { public: BackgroundBox(QWidget*, not_null session); diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 908efa695d..61c3a1c050 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/background_preview_box.h" #include "app.h" #include "styles/style_history.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include diff --git a/Telegram/SourceFiles/boxes/background_preview_box.h b/Telegram/SourceFiles/boxes/background_preview_box.h index 879cc0d02b..f0c929de18 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.h +++ b/Telegram/SourceFiles/boxes/background_preview_box.h @@ -24,7 +24,7 @@ class Checkbox; } // namespace Ui class BackgroundPreviewBox - : public BoxContent + : public Ui::BoxContent , private HistoryView::SimpleElementDelegate , private base::Subscriber { public: diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 9faae34d5c..69b46a1d79 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ using "ui/basic.style"; +using "ui/layers/layers.style"; using "ui/widgets/widgets.style"; using "intro/intro.style"; @@ -31,135 +32,6 @@ FeedUserpicButton { innerPart: UserpicButton; } -ServiceCheck { - margin: margins; - diameter: pixels; - shift: pixels; - thickness: pixels; - tip: point; - small: pixels; - large: pixels; - stroke: pixels; - color: color; - duration: int; -} - -boxDuration: 200; -boxRadius: 3px; - -boxButtonFont: font(boxFontSize semibold); -defaultBoxButton: RoundButton(defaultLightButton) { - width: -24px; - height: 36px; - font: boxButtonFont; -} - -boxTextStyle: TextStyle(defaultTextStyle) { - font: font(boxFontSize); - linkFont: font(boxFontSize); - linkFontOver: font(boxFontSize underline); -} - -boxLabelStyle: TextStyle(boxTextStyle) { - lineHeight: 22px; -} - -attentionBoxButton: RoundButton(defaultBoxButton) { - textFg: attentionButtonFg; - textFgOver: attentionButtonFgOver; - textBgOver: attentionButtonBgOver; - - ripple: RippleAnimation(defaultRippleAnimation) { - color: attentionButtonBgRipple; - } -} - -defaultBoxCheckbox: Checkbox(defaultCheckbox) { - width: -46px; - textPosition: point(12px, 1px); - style: boxTextStyle; -} - -boxRoundShadow: Shadow { - left: icon {{ "round_shadow_box_left", windowShadowFg }}; - topLeft: icon {{ "round_shadow_box_top_left", windowShadowFg }}; - top: icon {{ "round_shadow_box_top", windowShadowFg }}; - topRight: icon {{ "round_shadow_box_top_left-flip_horizontal", windowShadowFg }}; - right: icon {{ "round_shadow_box_left-flip_horizontal", windowShadowFg }}; - bottomRight: icon {{ "round_shadow_box_bottom_left-flip_horizontal", windowShadowFg }}; - bottom: icon {{ "round_shadow_box_bottom", windowShadowFg }}; - bottomLeft: icon {{ "round_shadow_box_bottom_left", windowShadowFg }}; - extend: margins(10px, 10px, 10px, 10px); - fallback: windowShadowFgFallback; -} - -boxTitleFont: font(17px semibold); -boxTitle: FlatLabel(defaultFlatLabel) { - textFg: boxTitleFg; - maxHeight: 24px; - style: TextStyle(defaultTextStyle) { - font: boxTitleFont; - linkFont: boxTitleFont; - linkFontOver: font(17px semibold underline); - } -} -boxTitlePosition: point(23px, 16px); -boxTitleHeight: 56px; -boxLayerTitlePosition: point(23px, 16px); -boxLayerTitleHeight: 56px; -boxLayerTitleAdditionalSkip: 9px; -boxLayerTitleAdditionalFont: normalFont; -boxLayerScroll: defaultSolidScroll; - -boxRowPadding: margins(23px, 0px, 23px, 0px); - -boxTopMargin: 6px; - -boxTitleClose: IconButton(defaultIconButton) { - width: boxTitleHeight; - height: boxTitleHeight; - - icon: boxTitleCloseIcon; - iconOver: boxTitleCloseIconOver; - - rippleAreaPosition: point(6px, 6px); - rippleAreaSize: 44px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } -} - -boxLinkButton: LinkButton(defaultLinkButton) { - font: boxTextFont; - overFont: font(boxFontSize underline); -} - -boxOptionListPadding: margins(0px, 0px, 0px, 0px); -boxOptionListSkip: 20px; -boxOptionInputSkip: 6px; - -boxVerticalMargin: 10px; -boxWidth: 320px; -boxWideWidth: 364px; -boxPadding: margins(23px, 30px, 23px, 8px); -boxMaxListHeight: 492px; -boxLittleSkip: 10px; -boxMediumSkip: 20px; - -boxButtonPadding: margins(8px, 12px, 13px, 12px); -boxLayerButtonPadding: margins(8px, 8px, 8px, 8px); -boxLabel: FlatLabel(defaultFlatLabel) { - minWidth: 274px; - align: align(topleft); - style: boxLabelStyle; -} -boxDividerLabel: FlatLabel(boxLabel) { - minWidth: 245px; - align: align(topleft); - textFg: windowSubTextFg; - style: defaultTextStyle; -} - countryRowHeight: 36px; countryRowNameFont: semiboldFont; countryRowNameFg: boxTextFg; @@ -204,12 +76,6 @@ defaultFeedUserpicButton: FeedUserpicButton { innerPart: defaultUserpicButton; } -boxLoadingAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) { - color: windowSubTextFg; - thickness: 2px; -} -boxLoadingSize: 20px; - cropPointSize: 10px; cropSkip: 13px; cropMinSize: 20px; @@ -768,7 +634,7 @@ rightsToggle: Toggle(defaultToggle) { stroke: 2px; duration: 120; } -rightsDividerHeight: 10px; +rightsDividerHeight: boxDividerHeight; rightsDividerMargin: margins(0px, 0px, 0px, 20px); rightsHeaderMargin: margins(23px, 0px, 23px, 8px); rightsToggleMargin: margins(23px, 8px, 23px, 8px); diff --git a/Telegram/SourceFiles/boxes/calendar_box.h b/Telegram/SourceFiles/boxes/calendar_box.h index b718fcf0a7..066d0425fd 100644 --- a/Telegram/SourceFiles/boxes/calendar_box.h +++ b/Telegram/SourceFiles/boxes/calendar_box.h @@ -17,7 +17,7 @@ namespace Ui { class IconButton; } // namespace Ui -class CalendarBox : public BoxContent, private base::Subscriber { +class CalendarBox : public Ui::BoxContent, private base::Subscriber { public: CalendarBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 6b50813b75..9240fbf64f 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_user.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace { @@ -61,7 +62,7 @@ void createErrorLabel( } // namespace -class ChangePhoneBox::EnterPhone : public BoxContent { +class ChangePhoneBox::EnterPhone : public Ui::BoxContent { public: EnterPhone(QWidget*, not_null session); @@ -89,7 +90,7 @@ private: }; -class ChangePhoneBox::EnterCode : public BoxContent { +class ChangePhoneBox::EnterCode : public Ui::BoxContent { public: EnterCode( QWidget*, @@ -214,7 +215,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(const QString &phoneNumber, const phoneCodeHash, codeLength, callTimeout), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const RPCError &error) { diff --git a/Telegram/SourceFiles/boxes/change_phone_box.h b/Telegram/SourceFiles/boxes/change_phone_box.h index 9eb6a84790..23a2feca18 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.h +++ b/Telegram/SourceFiles/boxes/change_phone_box.h @@ -13,7 +13,7 @@ namespace Main { class Session; } // namespace Main -class ChangePhoneBox : public BoxContent { +class ChangePhoneBox : public Ui::BoxContent { public: ChangePhoneBox(QWidget*, not_null session); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 1e6532f692..c7db08c408 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/confirm_box.h" -#include "styles/style_boxes.h" #include "lang/lang_keys.h" #include "mainwidget.h" #include "mainwindow.h" @@ -36,6 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "observer_peer.h" #include "facades.h" #include "app.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" #include #include diff --git a/Telegram/SourceFiles/boxes/confirm_box.h b/Telegram/SourceFiles/boxes/confirm_box.h index ce31a2078e..07c4971c0b 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.h +++ b/Telegram/SourceFiles/boxes/confirm_box.h @@ -20,7 +20,7 @@ class EmptyUserpic; } // namespace Ui class InformBox; -class ConfirmBox : public BoxContent, public ClickHandlerHost { +class ConfirmBox : public Ui::BoxContent, public ClickHandlerHost { public: ConfirmBox(QWidget*, const QString &text, FnMut confirmedCallback = FnMut(), FnMut cancelledCallback = FnMut()); ConfirmBox(QWidget*, const QString &text, const QString &confirmText, FnMut confirmedCallback = FnMut(), FnMut cancelledCallback = FnMut()); @@ -95,7 +95,7 @@ public: }; -class MaxInviteBox : public BoxContent, private base::Subscriber { +class MaxInviteBox : public Ui::BoxContent, private base::Subscriber { public: MaxInviteBox(QWidget*, not_null channel); @@ -123,7 +123,7 @@ private: }; -class PinMessageBox : public BoxContent, public RPCSender { +class PinMessageBox : public Ui::BoxContent, public RPCSender { public: PinMessageBox(QWidget*, not_null peer, MsgId msgId); @@ -148,7 +148,7 @@ private: }; -class DeleteMessagesBox : public BoxContent, public RPCSender { +class DeleteMessagesBox : public Ui::BoxContent, public RPCSender { public: DeleteMessagesBox( QWidget*, @@ -202,7 +202,7 @@ private: }; class ConfirmInviteBox - : public BoxContent + : public Ui::BoxContent , public RPCSender , private base::Subscriber { public: @@ -238,7 +238,7 @@ private: }; -class ConfirmDontWarnBox : public BoxContent { +class ConfirmDontWarnBox : public Ui::BoxContent { public: ConfirmDontWarnBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index 7d7782478b..8e4b8bf48d 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/confirm_phone_box.h" -#include "styles/style_boxes.h" #include "boxes/confirm_box.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" @@ -20,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "numbers.h" #include "app.h" #include "lang/lang_keys.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" namespace { @@ -54,7 +55,7 @@ Locale: ") + Platform::SystemLanguage(); } // namespace void ShowPhoneBannedError(const QString &phone) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto close = [=] { if (*box) { (*box)->closeBox(); diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.h b/Telegram/SourceFiles/boxes/confirm_phone_box.h index 17aedd96c6..d2963f9605 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.h +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.h @@ -85,7 +85,7 @@ private: }; -class ConfirmPhoneBox : public BoxContent, public RPCSender { +class ConfirmPhoneBox : public Ui::BoxContent, public RPCSender { public: static void start(const QString &phone, const QString &hash); diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 7aa97edcd3..316caefd32 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/radial_animation.h" #include "ui/text_options.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" #include "styles/style_info.h" @@ -134,7 +135,7 @@ private: }; -class ProxiesBox : public BoxContent { +class ProxiesBox : public Ui::BoxContent { public: using View = ProxiesBoxController::ItemView; @@ -166,7 +167,7 @@ private: }; -class ProxyBox : public BoxContent { +class ProxyBox : public Ui::BoxContent { public: ProxyBox( QWidget*, @@ -1029,7 +1030,7 @@ void ProxiesBoxController::ShowApplyConfirmation( if (const auto strong = box->data()) { strong->closeBox(); } - }), LayerOption::KeepOther); + }), Ui::LayerOption::KeepOther); } else { Ui::show(Box( (proxy.status() == ProxyData::Status::Unsupported @@ -1134,14 +1135,14 @@ void ProxiesBoxController::setupChecker(int id, const Checker &checker) { pointer->connect(pointer, &Connection::error, failed); } -object_ptr ProxiesBoxController::CreateOwningBox() { +object_ptr ProxiesBoxController::CreateOwningBox() { auto controller = std::make_unique(); auto box = controller->create(); Ui::AttachAsChild(box, std::move(controller)); return box; } -object_ptr ProxiesBoxController::create() { +object_ptr ProxiesBoxController::create() { auto result = Box(this); for (const auto &item : _list) { updateView(item); @@ -1249,7 +1250,7 @@ void ProxiesBoxController::setDeleted(int id, bool deleted) { updateView(*item); } -object_ptr ProxiesBoxController::editItemBox(int id) { +object_ptr ProxiesBoxController::editItemBox(int id) { return Box(findById(id)->data, [=](const ProxyData &result) { auto i = findById(id); auto j = ranges::find( @@ -1300,7 +1301,7 @@ void ProxiesBoxController::replaceItemValue( saveDelayed(); } -object_ptr ProxiesBoxController::addNewItemBox() { +object_ptr ProxiesBoxController::addNewItemBox() { return Box(ProxyData(), [=](const ProxyData &result) { auto j = ranges::find( _list, diff --git a/Telegram/SourceFiles/boxes/connection_box.h b/Telegram/SourceFiles/boxes/connection_box.h index 66b0eaa80d..37e7040f2e 100644 --- a/Telegram/SourceFiles/boxes/connection_box.h +++ b/Telegram/SourceFiles/boxes/connection_box.h @@ -7,11 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/abstract_box.h" #include "base/timer.h" +#include "base/object_ptr.h" #include "mtproto/connection_abstract.h" namespace Ui { +class BoxContent; class InputField; class PortInput; class PasswordInput; @@ -32,8 +33,8 @@ public: Type type, const QMap &fields); - static object_ptr CreateOwningBox(); - object_ptr create(); + static object_ptr CreateOwningBox(); + object_ptr create(); enum class ItemState { Connecting, @@ -60,8 +61,8 @@ public: void restoreItem(int id); void shareItem(int id); void applyItem(int id); - object_ptr editItemBox(int id); - object_ptr addNewItemBox(); + object_ptr editItemBox(int id); + object_ptr addNewItemBox(); bool setProxySettings(ProxyData::Settings value); void setProxyForCalls(bool enabled); void setTryIPv6(bool enabled); diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 617388bdc4..eb46cc606d 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_common.h" #include "base/unique_qptr.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_settings.h" @@ -724,7 +725,7 @@ object_ptr CreatePollBox::setupContent() { this, SendMenuType::Scheduled, send), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }; const auto updateValid = [=] { valid->fire(isValidQuestion() && options->isValid()); diff --git a/Telegram/SourceFiles/boxes/create_poll_box.h b/Telegram/SourceFiles/boxes/create_poll_box.h index cc38e5af33..57b7fa789e 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.h +++ b/Telegram/SourceFiles/boxes/create_poll_box.h @@ -21,7 +21,7 @@ namespace Main { class Session; } // namespace Main -class CreatePollBox : public BoxContent { +class CreatePollBox : public Ui::BoxContent { public: struct Result { PollData poll; diff --git a/Telegram/SourceFiles/boxes/download_path_box.cpp b/Telegram/SourceFiles/boxes/download_path_box.cpp index 18ca38bc68..ecd00ff84c 100644 --- a/Telegram/SourceFiles/boxes/download_path_box.cpp +++ b/Telegram/SourceFiles/boxes/download_path_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "platform/platform_specific.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" DownloadPathBox::DownloadPathBox(QWidget *parent) diff --git a/Telegram/SourceFiles/boxes/download_path_box.h b/Telegram/SourceFiles/boxes/download_path_box.h index e092ff0fbd..4ff63efce6 100644 --- a/Telegram/SourceFiles/boxes/download_path_box.h +++ b/Telegram/SourceFiles/boxes/download_path_box.h @@ -18,7 +18,7 @@ class Radioenum; class LinkButton; } // namespace Ui -class DownloadPathBox : public BoxContent { +class DownloadPathBox : public Ui::BoxContent { public: DownloadPathBox(QWidget *parent); diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 36868c4676..47f80eb78f 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -29,9 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "layout.h" #include "media/clip/media_clip_reader.h" #include "storage/storage_media_prepare.h" -#include "styles/style_boxes.h" -#include "styles/style_chat_helpers.h" -#include "styles/style_history.h" #include "ui/image/image.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/checkbox.h" @@ -42,6 +39,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "confirm_box.h" #include "facades.h" #include "app.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" +#include "styles/style_chat_helpers.h" +#include "styles/style_history.h" #include @@ -493,7 +494,7 @@ void EditCaptionBox::createEditMediaButton() { if (mimeType == qstr("image/webp")) { Ui::show( Box(tr::lng_edit_media_invalid_file(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return false; } return true; @@ -521,7 +522,7 @@ void EditCaptionBox::createEditMediaButton() { || file->type == Storage::PreparedFile::AlbumType::None) { Ui::show( Box(tr::lng_edit_media_album_error(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -551,7 +552,7 @@ void EditCaptionBox::createEditMediaButton() { if (!valid) { Ui::show( Box(tr::lng_edit_media_album_error(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -687,7 +688,7 @@ bool EditCaptionBox::fileFromClipboard(not_null data) { && _isAlbum) { Ui::show( Box(tr::lng_edit_media_album_error(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return false; } diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index 5dde6f0103..14e7cd5c38 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -36,7 +36,7 @@ class SessionController; } // namespace Window class EditCaptionBox - : public BoxContent + : public Ui::BoxContent , public RPCSender , private base::Subscriber { public: diff --git a/Telegram/SourceFiles/boxes/edit_color_box.h b/Telegram/SourceFiles/boxes/edit_color_box.h index 46b8ccf204..28ad8cc5a4 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.h +++ b/Telegram/SourceFiles/boxes/edit_color_box.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" -class EditColorBox : public BoxContent, private base::Subscriber { +class EditColorBox : public Ui::BoxContent, private base::Subscriber { public: enum class Mode { RGBA, diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 1578716bd6..d693492a13 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -27,7 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_channel.h" #include "window/window_session_controller.h" #include "styles/style_settings.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace { @@ -170,7 +170,7 @@ void EditPrivacyBox::editExceptions( }; Ui::show( Box(std::move(controller), std::move(initBox)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } QVector EditPrivacyBox::collectResult() { diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.h b/Telegram/SourceFiles/boxes/edit_privacy_box.h index 80efbdbc0a..1060157fdc 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.h +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.h @@ -23,6 +23,10 @@ template class SlideWrap; } // namespace Ui +namespace Window { +class SessionController; +} // namespace Window + class EditPrivacyBox; class EditPrivacyController { @@ -96,7 +100,7 @@ private: }; -class EditPrivacyBox : public BoxContent, private MTP::Sender { +class EditPrivacyBox : public Ui::BoxContent, private MTP::Sender { public: using Value = ApiWrap::Privacy; using Option = Value::Option; diff --git a/Telegram/SourceFiles/boxes/generic_box.cpp b/Telegram/SourceFiles/boxes/generic_box.cpp deleted file mode 100644 index 0e49abcbb9..0000000000 --- a/Telegram/SourceFiles/boxes/generic_box.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "boxes/generic_box.h" - -#include "ui/wrap/vertical_layout.h" -#include "ui/wrap/padding_wrap.h" -#include "ui/wrap/wrap.h" -#include "styles/style_boxes.h" - -void GenericBox::prepare() { - _init(this); - - auto wrap = object_ptr(this, std::move(_content)); - setDimensionsToContent(_width ? _width : st::boxWidth, wrap.data()); - setInnerWidget(std::move(wrap)); -} - -void GenericBox::addSkip(int height) { - addRow(object_ptr(this, height)); -} diff --git a/Telegram/SourceFiles/boxes/generic_box.h b/Telegram/SourceFiles/boxes/generic_box.h deleted file mode 100644 index 8c02ccca6d..0000000000 --- a/Telegram/SourceFiles/boxes/generic_box.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -#include "boxes/abstract_box.h" -#include "ui/wrap/vertical_layout.h" - -#include - -namespace st { -extern const style::margins &boxRowPadding; -} // namespace st - -class GenericBox : public BoxContent { -public: - // InitMethod::operator()(not_null box, InitArgs...) - // init(box, args...) - template < - typename InitMethod, - typename ...InitArgs, - typename = decltype(std::declval>()( - std::declval>(), - std::declval>()...))> - GenericBox( - QWidget*, - InitMethod &&init, - InitArgs &&...args); - - void setWidth(int width) { - _width = width; - } - void setFocusCallback(Fn callback) { - _focus = callback; - } - - int rowsCount() const { - return _content->count(); - } - - template < - typename Widget, - typename = std::enable_if_t< - std::is_base_of_v>> - Widget *insertRow( - int atPosition, - object_ptr &&child, - const style::margins &margin = st::boxRowPadding) { - return _content->insert( - atPosition, - std::move(child), - margin); - } - - template < - typename Widget, - typename = std::enable_if_t< - std::is_base_of_v>> - Widget *addRow( - object_ptr &&child, - const style::margins &margin = st::boxRowPadding) { - return _content->add(std::move(child), margin); - } - - void addSkip(int height); - - void setInnerFocus() override { - if (_focus) { - _focus(); - } - } - -protected: - void prepare() override; - -private: - template - struct Initer { - template < - typename OtherMethod, - typename ...OtherArgs, - typename = std::enable_if_t< - std::is_constructible_v>> - Initer(OtherMethod &&method, OtherArgs &&...args); - - void operator()(not_null box); - - template - void call( - not_null box, - std::index_sequence); - - InitMethod method; - std::tuple args; - }; - - template - auto MakeIniter(InitMethod &&method, InitArgs &&...args) - -> Initer, std::decay_t...>; - - FnMut)> _init; - Fn _focus; - object_ptr _content; - int _width = 0; - -}; - -template -template -GenericBox::Initer::Initer( - OtherMethod &&method, - OtherArgs &&...args) -: method(std::forward(method)) -, args(std::forward(args)...) { -} - -template -inline void GenericBox::Initer::operator()( - not_null box) { - call(box, std::make_index_sequence()); -} - -template -template -inline void GenericBox::Initer::call( - not_null box, - std::index_sequence) { - std::invoke(method, box, std::get(std::move(args))...); -} - -template -inline auto GenericBox::MakeIniter(InitMethod &&method, InitArgs &&...args) --> Initer, std::decay_t...> { - return { - std::forward(method), - std::forward(args)... - }; -} - -template -inline GenericBox::GenericBox( - QWidget*, - InitMethod &&init, - InitArgs &&...args) -: _init( - MakeIniter( - std::forward(init), - std::forward(args)...)) -, _content(this) { -} diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index c85399cbfb..a169f7a1f4 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/multi_select.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/dropdown_menu.h" +#include "ui/widgets/box_content_divider.h" #include "ui/text/text_entity.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" @@ -27,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "lang/lang_instance.h" #include "lang/lang_cloud_manager.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" #include "styles/style_passport.h" @@ -896,9 +898,9 @@ void Content::setupContent( }; const auto main = add(recent, false); const auto divider = content->add( - object_ptr>( + object_ptr>( content, - object_ptr(content))); + object_ptr(content))); const auto other = add(official, true); Ui::ResizeFitChild(this, content); diff --git a/Telegram/SourceFiles/boxes/language_box.h b/Telegram/SourceFiles/boxes/language_box.h index 4cc3dd56b6..92eeedd406 100644 --- a/Telegram/SourceFiles/boxes/language_box.h +++ b/Telegram/SourceFiles/boxes/language_box.h @@ -16,7 +16,7 @@ class MultiSelect; struct ScrollToRequest; } // namespace Ui -class LanguageBox : public BoxContent { +class LanguageBox : public Ui::BoxContent { public: LanguageBox(QWidget*) { } diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index 047dcc2cb5..618c1035aa 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "main/main_session.h" #include "layout.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace { diff --git a/Telegram/SourceFiles/boxes/local_storage_box.h b/Telegram/SourceFiles/boxes/local_storage_box.h index f00d83958c..8f1d2401f0 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.h +++ b/Telegram/SourceFiles/boxes/local_storage_box.h @@ -28,7 +28,7 @@ class LabelSimple; class MediaSlider; } // namespace Ui -class LocalStorageBox : public BoxContent { +class LocalStorageBox : public Ui::BoxContent { struct CreateTag { }; diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index cd0d46cf96..fb8b67b090 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -15,6 +15,7 @@ Copyright (C) 2017, Nicholas Guriev #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace { diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.h b/Telegram/SourceFiles/boxes/mute_settings_box.h index fe5c1efc6b..d916924105 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.h +++ b/Telegram/SourceFiles/boxes/mute_settings_box.h @@ -12,7 +12,7 @@ Copyright (C) 2017, Nicholas Guriev /* This class implements a dialog-box with radio-buttons for pick duration of * turning off notifications from a chat. The widget is opened by a context menu * in the left list of dialogues. */ -class MuteSettingsBox : public BoxContent { +class MuteSettingsBox : public Ui::BoxContent { public: MuteSettingsBox(QWidget *parent, not_null peer); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 1391df3643..26a073c508 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -22,8 +22,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "passport/passport_encryption.h" #include "passport/passport_panel_edit_contact.h" #include "facades.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_passport.h" +#include "styles/style_boxes.h" namespace { @@ -375,7 +376,7 @@ void PasscodeBox::validateEmail( Lang::Hard::EmailConfirmationExpired()); weak->getDelegate()->show( std::move(box), - LayerOption::CloseOther); + Ui::LayerOption::CloseOther); } } else { errors->fire(Lang::Hard::ServerError()); @@ -531,7 +532,7 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) { if (_cloudFields.turningOff && _cloudFields.notEmptyPassport) { Assert(!_cloudFields.customCheckCallback); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto confirmed = [=] { send(); if (*box) { @@ -738,7 +739,7 @@ void PasscodeBox::changeCloudPassword( } void PasscodeBox::suggestSecretReset(const QString &newPassword) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto resetSecretAndSave = [=] { checkPasswordHash([=](const Core::CloudPasswordResult &check) { resetSecret(check, newPassword, [=] { @@ -990,7 +991,7 @@ void RecoverBox::submit() { rpcFail(&RecoverBox::codeSubmitFail)); }); if (_notEmptyPassport) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto confirmed = [=] { send(); if (*box) { @@ -1019,7 +1020,7 @@ void RecoverBox::codeSubmitDone( _passwordCleared.fire({}); getDelegate()->show( Box(tr::lng_cloud_password_removed(tr::now)), - LayerOption::CloseOther); + Ui::LayerOption::CloseOther); } bool RecoverBox::codeSubmitFail(const RPCError &error) { @@ -1039,7 +1040,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) { _passwordCleared.fire({}); getDelegate()->show( Box(tr::lng_cloud_password_removed(tr::now)), - LayerOption::CloseOther); + Ui::LayerOption::CloseOther); return true; } else if (err == qstr("PASSWORD_RECOVERY_NA")) { closeBox(); @@ -1070,7 +1071,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { const auto errors = std::make_shared>(); const auto resent = std::make_shared>(); const auto requestId = std::make_shared(0); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto reloads = std::make_shared>(); const auto cancels = std::make_shared>(); @@ -1084,7 +1085,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { if (*weak) { (*weak)->getDelegate()->show( Box(tr::lng_cloud_password_was_set(tr::now)), - LayerOption::CloseOther); + Ui::LayerOption::CloseOther); } }; const auto fail = [=](const RPCError &error) { @@ -1105,7 +1106,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { Lang::Hard::EmailConfirmationExpired()); (*weak)->getDelegate()->show( std::move(box), - LayerOption::CloseOther); + Ui::LayerOption::CloseOther); } } else { errors->fire(Lang::Hard::ServerError()); diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index 7c907d523b..a8ad5ea8c6 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -25,7 +25,7 @@ namespace Core { struct CloudPasswordState; } // namespace Core -class PasscodeBox : public BoxContent, private MTP::Sender { +class PasscodeBox : public Ui::BoxContent, private MTP::Sender { public: PasscodeBox(QWidget*, not_null session, bool turningOff); @@ -133,7 +133,7 @@ private: QString _pattern; - QPointer _replacedBy; + QPointer _replacedBy; bool _turningOff = false; bool _cloudPwd = false; CloudFields _cloudFields; @@ -163,7 +163,7 @@ private: }; -class RecoverBox : public BoxContent, public RPCSender { +class RecoverBox : public Ui::BoxContent, public RPCSender { public: RecoverBox(QWidget*, const QString &pattern, bool notEmptyPassport); @@ -201,7 +201,7 @@ private: }; struct RecoveryEmailValidation { - object_ptr box; + object_ptr box; rpl::producer<> reloadRequests; rpl::producer<> cancelRequests; }; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 4835bf0396..0542e0e34a 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -7,10 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/peer_list_box.h" -#include -#include "styles/style_boxes.h" -#include "styles/style_dialogs.h" -#include "styles/style_widgets.h" #include "main/main_session.h" #include "mainwidget.h" #include "ui/widgets/multi_select.h" @@ -30,6 +26,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "base/unixtime.h" #include "window/themes/window_theme.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" +#include "styles/style_dialogs.h" +#include "styles/style_widgets.h" + +#include auto PaintUserpicCallback( not_null peer, diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index ceced9760b..3c6b84f6d6 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -752,7 +752,7 @@ private: }; class PeerListBox - : public BoxContent + : public Ui::BoxContent , public PeerListContentDelegate { public: PeerListBox( diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index bad2a093e4..190c2f3723 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -464,7 +464,7 @@ void AddBotToGroupBoxController::shareBotGame(not_null chat) { }(); Ui::show( Box(confirmText, std::move(send)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void AddBotToGroupBoxController::addBotToGroup(not_null chat) { @@ -472,7 +472,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { if (!megagroup->canAddMembers()) { Ui::show( Box(tr::lng_error_cant_add_member(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -482,7 +482,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { auto confirmText = tr::lng_bot_sure_invite(tr::now, lt_group, chat->name); Ui::show( Box(confirmText, send), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } auto AddBotToGroupBoxController::createRow(not_null history) diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 0ae8fadbf2..08c95bc723 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -98,13 +98,13 @@ void AddParticipantsBoxController::rowClicked(not_null row) { if (!_peer->isMegagroup()) { Ui::show( Box(_peer->asChannel()), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } else if (count >= Global::ChatSizeMax() && count < Global::MegagroupSizeMax()) { Ui::show( Box(tr::lng_profile_add_more_after_create(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } @@ -210,7 +210,7 @@ void AddParticipantsBoxController::Start( Box( std::move(controller), std::move(initBox)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void AddParticipantsBoxController::Start( @@ -251,7 +251,7 @@ void AddParticipantsBoxController::Start( Box( std::move(controller), std::move(initBox)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void AddParticipantsBoxController::Start( @@ -517,19 +517,19 @@ void AddSpecialBoxController::showAdmin( Box( tr::lng_sure_add_admin_unremove(tr::now), showAdminSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show(Box( tr::lng_error_cant_add_admin_unban(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show(Box( tr::lng_error_cant_add_admin_invite(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else if (_additional.restrictedRights(user).has_value()) { @@ -540,13 +540,13 @@ void AddSpecialBoxController::showAdmin( Box( tr::lng_sure_add_admin_unremove(tr::now), showAdminSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show(Box( tr::lng_error_cant_add_admin_unban(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else if (_additional.isExternal(user)) { @@ -560,13 +560,13 @@ void AddSpecialBoxController::showAdmin( Box( text, showAdminSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show( Box(tr::lng_error_cant_add_admin_invite(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -597,7 +597,7 @@ void AddSpecialBoxController::showAdmin( }); box->setSaveCallback(SaveAdminCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), LayerOption::KeepOther); + _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } void AddSpecialBoxController::editAdminDone( @@ -669,13 +669,13 @@ void AddSpecialBoxController::showRestricted( Box( tr::lng_sure_ban_admin(tr::now), showRestrictedSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show( Box(tr::lng_error_cant_ban_admin(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -704,7 +704,7 @@ void AddSpecialBoxController::showRestricted( box->setSaveCallback( SaveRestrictedCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), LayerOption::KeepOther); + _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } void AddSpecialBoxController::editRestrictedDone( @@ -759,13 +759,13 @@ void AddSpecialBoxController::kickUser( Box( tr::lng_sure_ban_admin(tr::now), kickUserSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } else { Ui::show( Box(tr::lng_error_cant_ban_admin(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } } @@ -780,7 +780,7 @@ void AddSpecialBoxController::kickUser( user->name); _editBox = Ui::show( Box(text, kickUserSure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h index b1fab5a43c..d15f474e85 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h @@ -126,8 +126,8 @@ private: bool _allLoaded = false; ParticipantsAdditionalData _additional; std::unique_ptr _onlineSorter; - BoxPointer _editBox; - QPointer _editParticipantBox; + Ui::BoxPointer _editBox; + QPointer _editParticipantBox; AdminDoneCallback _adminDoneCallback; BannedDoneCallback _bannedDoneCallback; diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 5d2ce7e037..c7138e4af7 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/peers/edit_contact_box.h" -#include "boxes/generic_box.h" #include "data/data_user.h" #include "data/data_session.h" #include "ui/wrap/vertical_layout.h" @@ -21,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "apiwrap.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -36,7 +36,7 @@ QString UserPhone(not_null user) { } void SendRequest( - QPointer box, + QPointer box, not_null user, bool sharePhone, const QString &first, @@ -82,7 +82,7 @@ void SendRequest( class Controller { public: Controller( - not_null box, + not_null box, not_null window, not_null user); @@ -99,7 +99,7 @@ private: not_null last, bool inverted); - not_null _box; + not_null _box; not_null _window; not_null _user; Ui::Checkbox *_sharePhone = nullptr; @@ -110,7 +110,7 @@ private: }; Controller::Controller( - not_null box, + not_null box, not_null window, not_null user) : _box(box) @@ -265,7 +265,7 @@ void Controller::setupSharePhoneNumber() { } // namespace void EditContactBox( - not_null box, + not_null box, not_null window, not_null user) { box->lifetime().make_state(box, window, user)->prepare(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.h b/Telegram/SourceFiles/boxes/peers/edit_contact_box.h index da19edcf44..3f3e2c7764 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.h @@ -7,14 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "ui/layers/generic_box.h" + class UserData; -class GenericBox; namespace Window { class Controller; } // namespace Window void EditContactBox( - not_null box, + not_null box, not_null window, not_null user); diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index 2b059460cc..e813bb3f1c 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "facades.h" #include "main/main_session.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -145,7 +146,7 @@ void Controller::choose(not_null chat) { Ui::Text::RichLangValue)); } } - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto sure = [=] { if (*box) { (*box)->closeBox(); @@ -158,7 +159,7 @@ void Controller::choose(not_null chat) { text, tr::lng_manage_discussion_group_link(tr::now), sure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void Controller::choose(not_null chat) { @@ -177,7 +178,7 @@ void Controller::choose(not_null chat) { text.append(tr::lng_manage_discussion_group_warning( tr::now, Ui::Text::RichLangValue)); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto sure = [=] { if (*box) { (*box)->closeBox(); @@ -193,7 +194,7 @@ void Controller::choose(not_null chat) { text, tr::lng_manage_discussion_group_link(tr::now), sure), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } object_ptr SetupAbout( @@ -256,7 +257,7 @@ object_ptr SetupCreateGroup( GroupInfoBox::Type::Megagroup, channel->name + " Chat", guarded), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }); return result; } @@ -277,7 +278,7 @@ object_ptr SetupUnlink( return result; } -object_ptr EditLinkedChatBox( +object_ptr EditLinkedChatBox( not_null navigation, not_null channel, ChannelData *chat, @@ -324,7 +325,7 @@ object_ptr EditLinkedChatBox( } // namespace -object_ptr EditLinkedChatBox( +object_ptr EditLinkedChatBox( not_null navigation, not_null channel, std::vector> &&chats, @@ -338,7 +339,7 @@ object_ptr EditLinkedChatBox( callback); } -object_ptr EditLinkedChatBox( +object_ptr EditLinkedChatBox( not_null navigation, not_null channel, not_null chat, diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h index e40864935d..cf36d107bf 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h @@ -7,20 +7,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/abstract_box.h" +#include "base/object_ptr.h" + +namespace Ui { +class BoxContent; +} // namespace Ui namespace Window { class SessionNavigation; } // namespace Window -object_ptr EditLinkedChatBox( +object_ptr EditLinkedChatBox( not_null navigation, not_null channel, not_null chat, bool canEdit, Fn callback); -object_ptr EditLinkedChatBox( +object_ptr EditLinkedChatBox( not_null navigation, not_null channel, std::vector> &&chats, diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index ff10e04bad..289708e364 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" +#include "ui/widgets/box_content_divider.h" +#include "ui/layers/generic_box.h" #include "ui/toast/toast.h" #include "ui/text/text_utilities.h" #include "ui/text_options.h" @@ -23,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_button.h" #include "settings/settings_privacy_security.h" #include "boxes/calendar_box.h" -#include "boxes/generic_box.h" #include "boxes/confirm_box.h" #include "boxes/passcode_box.h" #include "boxes/peers/edit_peer_permissions_box.h" @@ -37,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "facades.h" #include "main/main_session.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -53,7 +55,7 @@ enum class PasswordErrorType { Later, }; -void SetCloudPassword(not_null box, not_null user) { +void SetCloudPassword(not_null box, not_null user) { user->session().api().passwordState( ) | rpl::start_with_next([=] { using namespace Settings; @@ -71,7 +73,7 @@ void SetCloudPassword(not_null box, not_null user) { } void TransferPasswordError( - not_null box, + not_null box, not_null user, PasswordErrorType error) { box->setTitle(tr::lng_rights_transfer_check()); @@ -299,7 +301,7 @@ void EditAdminBox::prepare() { : tr::lng_channel_add_admin()); addControl( - object_ptr(this), + object_ptr(this), st::rightsDividerMargin); const auto chat = peer()->asChat(); @@ -404,7 +406,7 @@ void EditAdminBox::prepare() { not_null EditAdminBox::addRankInput() { addControl( - object_ptr(this), + object_ptr(this), st::rightsRankMargin); addControl( @@ -474,7 +476,7 @@ not_null*> EditAdminBox::setupTransferButton( const auto container = wrap->entity(); container->add( - object_ptr(container), + object_ptr(container), { 0, st::infoProfileSkip, 0, st::infoProfileSkip }); container->add(EditPeerInfoBox::CreateButton( this, @@ -664,7 +666,7 @@ void EditRestrictedBox::prepare() { setTitle(tr::lng_rights_user_restrictions()); addControl( - object_ptr(this), + object_ptr(this), st::rightsDividerMargin); const auto chat = peer()->asChat(); @@ -708,7 +710,7 @@ void EditRestrictedBox::prepare() { addControl(std::move(checkboxes), QMargins()); _until = prepareRights.c_chatBannedRights().vuntil_date().v; - addControl(object_ptr(this), st::rightsUntilMargin); + addControl(object_ptr(this), st::rightsUntilMargin); addControl( object_ptr( this, @@ -759,7 +761,7 @@ void EditRestrictedBox::showRestrictUntil() { setRestrictUntil( static_cast(QDateTime(date).toTime_t())); }), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); _restrictUntilBox->setMaxDate( QDate::currentDate().addDays(kMaxRestrictDelayDays)); _restrictUntilBox->setMinDate(tomorrow); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index 1804aae464..7ef9e877e1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -27,7 +27,7 @@ struct CloudPasswordResult; class CalendarBox; class PasscodeBox; -class EditParticipantBox : public BoxContent { +class EditParticipantBox : public Ui::BoxContent { public: EditParticipantBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 17d408d34c..09a0960f64 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -874,7 +874,7 @@ void ParticipantsBoxController::Start( }; Ui::show( Box(std::move(controller), initBox), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ParticipantsBoxController::addNewItem() { @@ -907,7 +907,7 @@ void ParticipantsBoxController::addNewItem() { adminDone, restrictedDone), initBox), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ParticipantsBoxController::addNewParticipants() { @@ -929,7 +929,7 @@ void ParticipantsBoxController::addNewParticipants() { channel, { already.begin(), already.end() }); } else { - Ui::show(Box(channel), LayerOption::KeepOther); + Ui::show(Box(channel), Ui::LayerOption::KeepOther); } } @@ -1474,7 +1474,7 @@ void ParticipantsBoxController::showAdmin(not_null user) { }); box->setSaveCallback(SaveAdminCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), LayerOption::KeepOther); + _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } void ParticipantsBoxController::editAdminDone( @@ -1552,7 +1552,7 @@ void ParticipantsBoxController::showRestricted(not_null user) { box->setSaveCallback( SaveRestrictedCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), LayerOption::KeepOther); + _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } void ParticipantsBoxController::editRestrictedDone( @@ -1618,7 +1618,7 @@ void ParticipantsBoxController::kickMember(not_null user) { text, tr::lng_box_remove(tr::now), crl::guard(this, [=] { kickMemberSure(user); })), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ParticipantsBoxController::unkickMember(not_null user) { @@ -1661,7 +1661,7 @@ void ParticipantsBoxController::removeAdmin(not_null user) { user->firstName), tr::lng_box_remove(tr::now), crl::guard(this, [=] { removeAdminSure(user); })), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ParticipantsBoxController::removeAdminSure(not_null user) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index bf67725023..af0b8decc7 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -244,9 +244,9 @@ private: bool _allLoaded = false; ParticipantsAdditionalData _additional; std::unique_ptr _onlineSorter; - BoxPointer _editBox; - BoxPointer _addBox; - QPointer _editParticipantBox; + Ui::BoxPointer _editBox; + Ui::BoxPointer _addBox; + QPointer _editParticipantBox; }; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp index f82e4f5d4a..fbf4de9bf2 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp @@ -13,13 +13,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_peer.h" #include "lang/lang_keys.h" -#include "styles/style_boxes.h" -#include "styles/style_info.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" #include "ui/wrap/padding_wrap.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" +#include "styles/style_layers.h" +#include "styles/style_info.h" namespace { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.h index 984a061e8e..a66065340e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.h @@ -15,7 +15,7 @@ enum class HistoryVisibility { Hidden, }; -class EditPeerHistoryVisibilityBox : public BoxContent { +class EditPeerHistoryVisibilityBox : public Ui::BoxContent { public: EditPeerHistoryVisibilityBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index dc7b15475d..56bf1dfacf 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -31,14 +31,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "mtproto/sender.h" #include "observer_peer.h" -#include "styles/style_boxes.h" -#include "styles/style_info.h" #include "ui/rp_widget.h" #include "ui/special_buttons.h" #include "ui/toast/toast.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/padding_wrap.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" @@ -46,6 +45,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_icon.h" #include "app.h" #include "facades.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" +#include "styles/style_info.h" namespace { @@ -70,7 +72,7 @@ void AddSkip( container->add(object_ptr( container, top)); - container->add(object_ptr(container)); + container->add(object_ptr(container)); container->add(object_ptr( container, bottom)); @@ -193,7 +195,7 @@ void SaveSlowmodeSeconds( void ShowEditPermissions(not_null peer) { const auto box = Ui::show( Box(peer), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); const auto saving = box->lifetime().make_state(0); const auto save = [=]( not_null peer, @@ -244,7 +246,7 @@ class Controller public: Controller( not_null navigation, - not_null box, + not_null box, not_null peer); object_ptr createContent(); @@ -330,7 +332,7 @@ private: std::optional _signaturesSavedValue; const not_null _navigation; - const not_null _box; + const not_null _box; not_null _peer; const bool _isGroup = false; @@ -351,7 +353,7 @@ private: Controller::Controller( not_null navigation, - not_null box, + not_null box, not_null peer) : _navigation(navigation) , _box(box) @@ -559,7 +561,7 @@ object_ptr Controller::createStickersEdit() { tr::lng_group_stickers_add(tr::now), st::editPeerInviteLinkButton) )->addClickHandler([=] { - Ui::show(Box(channel), LayerOption::KeepOther); + Ui::show(Box(channel), Ui::LayerOption::KeepOther); }); return std::move(result); @@ -602,13 +604,13 @@ void Controller::showEditPeerTypeBox( _privacySavedValue, _usernameSavedValue, error), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void Controller::showEditLinkedChatBox() { Expects(_peer->isChannel()); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto channel = _peer->asChannel(); const auto callback = [=](ChannelData *result) { if (*box) { @@ -633,7 +635,7 @@ void Controller::showEditLinkedChatBox() { chat, canEdit, callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } else if (!canEdit || _linkedChatsRequestId) { return; @@ -660,7 +662,7 @@ void Controller::showEditLinkedChatBox() { channel, std::move(chats), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }).fail([=](const RPCError &error) { _linkedChatsRequestId = 0; }).send(); @@ -749,7 +751,7 @@ void Controller::fillInviteLinkButton() { Expects(_controls.buttonsLayout != nullptr); const auto buttonCallback = [=] { - Ui::show(Box(_peer), LayerOption::KeepOther); + Ui::show(Box(_peer), Ui::LayerOption::KeepOther); }; AddButtonWithText( @@ -807,7 +809,7 @@ void Controller::fillHistoryVisibilityButton() { _peer, boxCallback, *_historyVisibilitySavedValue), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }; AddButtonWithText( container, @@ -1429,7 +1431,7 @@ void Controller::deleteWithConfirmation() { tr::lng_box_delete(tr::now), st::attentionBoxButton, deleteCallback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void Controller::deleteChannel() { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h index 2346277ed6..59c85a48a9 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.h @@ -28,7 +28,7 @@ class Button; } // namespace Profile } // namespace Info -class EditPeerInfoBox : public BoxContent { +class EditPeerInfoBox : public Ui::BoxContent { public: EditPeerInfoBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 740033b460..0bbe227c7b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/continuous_sliders.h" +#include "ui/widgets/box_content_divider.h" #include "ui/toast/toast.h" #include "info/profile/info_profile_button.h" #include "info/profile/info_profile_icon.h" @@ -23,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_session_controller.h" #include "mainwindow.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -387,7 +389,7 @@ Fn EditPeerPermissionsBox::addSlowmodeSlider( channel ? channel->slowmodeSeconds() : 0); container->add( - object_ptr(container), + object_ptr(container), { 0, st::infoProfileSkip, 0, st::infoProfileSkip }); container->add( diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h index c62a28a560..4faf5e4687 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h @@ -15,7 +15,7 @@ class RoundButton; class VerticalLayout; } // namespace Ui -class EditPeerPermissionsBox : public BoxContent { +class EditPeerPermissionsBox : public Ui::BoxContent { public: EditPeerPermissionsBox(QWidget*, not_null peer); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index b00af3ac3e..7c67aba61a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -24,8 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "mtproto/sender.h" #include "observer_peer.h" -#include "styles/style_boxes.h" -#include "styles/style_info.h" #include "ui/rp_widget.h" #include "ui/special_buttons.h" #include "ui/toast/toast.h" @@ -33,16 +31,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/checkbox.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/padding_wrap.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" #include "ui/special_fields.h" #include "window/window_session_controller.h" -#include +#include "styles/style_layers.h" +#include "styles/style_boxes.h" +#include "styles/style_info.h" #include #include +#include + namespace { constexpr auto kUsernameCheckTimeout = crl::time(200); @@ -189,7 +192,7 @@ void Controller::createContent() { fillPrivaciesButtons(_wrap, _privacySavedValue); // Skip. - _wrap->add(object_ptr(_wrap)); + _wrap->add(object_ptr(_wrap)); // _wrap->add(createInviteLinkCreate()); _wrap->add(createInviteLinkEdit()); @@ -471,7 +474,7 @@ void Controller::askUsernameRevoke() { Box( &_peer->session(), std::move(revokeCallback)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void Controller::usernameChanged() { @@ -553,7 +556,7 @@ void Controller::exportInviteLink(const QString &confirmation) { auto box = Box( confirmation, std::move(callback)); - *boxPointer = Ui::show(std::move(box), LayerOption::KeepOther); + *boxPointer = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } bool Controller::canEditInviteLink() const { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h index 2d4dcf1cff..5e5ba890a0 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h @@ -35,7 +35,7 @@ enum class UsernameState { NotAvailable, }; -class EditPeerTypeBox : public BoxContent { +class EditPeerTypeBox : public Ui::BoxContent { public: // Edit just the invite link. EditPeerTypeBox(QWidget*, not_null peer); diff --git a/Telegram/SourceFiles/boxes/photo_crop_box.cpp b/Telegram/SourceFiles/boxes/photo_crop_box.cpp index 81b5347fa8..918b9a41b7 100644 --- a/Telegram/SourceFiles/boxes/photo_crop_box.cpp +++ b/Telegram/SourceFiles/boxes/photo_crop_box.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/ui_utility.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" PhotoCropBox::PhotoCropBox( diff --git a/Telegram/SourceFiles/boxes/photo_crop_box.h b/Telegram/SourceFiles/boxes/photo_crop_box.h index 2db2cd7924..32ee556292 100644 --- a/Telegram/SourceFiles/boxes/photo_crop_box.h +++ b/Telegram/SourceFiles/boxes/photo_crop_box.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" -class PhotoCropBox : public BoxContent { +class PhotoCropBox : public Ui::BoxContent { public: PhotoCropBox(QWidget*, const QImage &img, const QString &title); diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index 30e7371b1d..be102184b8 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -8,8 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/rate_call_box.h" #include "lang/lang_keys.h" -#include "styles/style_boxes.h" -#include "styles/style_calls.h" #include "boxes/confirm_box.h" #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" @@ -17,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "main/main_session.h" #include "apiwrap.h" +#include "styles/style_layers.h" +#include "styles/style_calls.h" namespace { diff --git a/Telegram/SourceFiles/boxes/rate_call_box.h b/Telegram/SourceFiles/boxes/rate_call_box.h index 641afe177a..9efaa4d530 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.h +++ b/Telegram/SourceFiles/boxes/rate_call_box.h @@ -20,7 +20,7 @@ namespace Main { class Session; } // namespace Main -class RateCallBox : public BoxContent, private MTP::Sender { +class RateCallBox : public Ui::BoxContent, private MTP::Sender { public: RateCallBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index e94be583e5..5ad271db2b 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/toast/toast.h" #include "mainwindow.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_profile.h" diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index 3b48cd03dc..d7afc37616 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -17,7 +17,7 @@ class Radioenum; class InputField; } // namespace Ui -class ReportBox : public BoxContent, public RPCSender { +class ReportBox : public Ui::BoxContent, public RPCSender { public: ReportBox(QWidget*, not_null peer); ReportBox(QWidget*, not_null peer, MessageIdsList ids); diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index 04b02d49de..79b5cf5175 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "apiwrap.h" #include "main/main_session.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" SelfDestructionBox::SelfDestructionBox( diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.h b/Telegram/SourceFiles/boxes/self_destruction_box.h index f4128e8214..475f597491 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.h +++ b/Telegram/SourceFiles/boxes/self_destruction_box.h @@ -20,7 +20,7 @@ namespace Main { class Session; } // namespace Main -class SelfDestructionBox : public BoxContent, private MTP::Sender { +class SelfDestructionBox : public Ui::BoxContent, private MTP::Sender { public: SelfDestructionBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index f4b3b1a4bd..afc842773a 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "facades.h" #include "app.h" #include "styles/style_history.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" @@ -1981,7 +1982,7 @@ void SendFilesBox::sendScheduled() { const auto callback = [=](Api::SendOptions options) { send(options); }; Ui::show( HistoryView::PrepareScheduleBox(this, _sendMenuType, callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } SendFilesBox::~SendFilesBox() = default; diff --git a/Telegram/SourceFiles/boxes/send_files_box.h b/Telegram/SourceFiles/boxes/send_files_box.h index a3e6beda2a..23f7412957 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.h +++ b/Telegram/SourceFiles/boxes/send_files_box.h @@ -48,7 +48,7 @@ enum class SendFilesWay { Files, }; -class SendFilesBox : public BoxContent { +class SendFilesBox : public Ui::BoxContent { public: enum class SendLimit { One, diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 1ff16bdb9e..a2888695f9 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" #include "styles/style_settings.h" @@ -320,7 +321,7 @@ void SessionsBox::terminateOne(uint64 hash) { tr::lng_settings_reset_button(tr::now), st::attentionBoxButton, callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void SessionsBox::terminateAll() { @@ -346,7 +347,7 @@ void SessionsBox::terminateAll() { tr::lng_settings_reset_button(tr::now), st::attentionBoxButton, callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } SessionsBox::Inner::Inner(QWidget *parent) diff --git a/Telegram/SourceFiles/boxes/sessions_box.h b/Telegram/SourceFiles/boxes/sessions_box.h index 4eaf6e6a6d..b27ec5dd42 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.h +++ b/Telegram/SourceFiles/boxes/sessions_box.h @@ -22,7 +22,7 @@ namespace Main { class Session; } // namespace Main -class SessionsBox : public BoxContent, private MTP::Sender { +class SessionsBox : public Ui::BoxContent, private MTP::Sender { public: SessionsBox(QWidget*, not_null session); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 20b4ac99f2..82fea368f7 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_folder.h" #include "main/main_session.h" #include "core/application.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_history.h" @@ -479,7 +480,7 @@ void ShareBox::submitScheduled() { const auto callback = [=](Api::SendOptions options) { submit(options); }; Ui::show( HistoryView::PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ShareBox::copyLink() { diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 69dc63b9c7..55d223c042 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -52,7 +52,7 @@ void ShareGameScoreByHash( not_null session, const QString &hash); -class ShareBox : public BoxContent, public RPCSender { +class ShareBox : public Ui::BoxContent, public RPCSender { public: using CopyCallback = Fn; using SubmitCallback = Fn @@ -136,14 +136,14 @@ StickerSetBox::StickerSetBox( , _set(set) { } -QPointer StickerSetBox::Show( +QPointer StickerSetBox::Show( not_null controller, not_null document) { if (const auto sticker = document->sticker()) { if (sticker->set.type() != mtpc_inputStickerSetEmpty) { return Ui::show( Box(controller, sticker->set), - LayerOption::KeepOther).data(); + Ui::LayerOption::KeepOther).data(); } } return nullptr; @@ -695,7 +695,7 @@ void StickerSetBox::Inner::install() { if (isMasksSet()) { Ui::show( Box(tr::lng_stickers_masks_pack(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } else if (_installRequest) { return; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.h b/Telegram/SourceFiles/boxes/sticker_set_box.h index 4c5cc61fe5..ae01ba0201 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.h +++ b/Telegram/SourceFiles/boxes/sticker_set_box.h @@ -21,14 +21,14 @@ namespace Ui { class PlainShadow; } // namespace Ui -class StickerSetBox : public BoxContent, public RPCSender { +class StickerSetBox : public Ui::BoxContent, public RPCSender { public: StickerSetBox( QWidget*, not_null controller, const MTPInputStickerSet &set); - static QPointer Show( + static QPointer Show( not_null controller, not_null document); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index a44cca08c4..0d3048172d 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "facades.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" @@ -1302,7 +1303,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { Box( App::wnd()->sessionController(), Stickers::inputSetId(*set)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } }; if (selectedIndex >= 0 && !_inDragArea) { diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index 1436e3b5ad..d5aba39edb 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -26,6 +26,7 @@ class RippleAnimation; class SettingsSlider; class SlideAnimation; class CrossButton; +class BoxContentDivider; } // namespace Ui namespace Main { @@ -33,7 +34,7 @@ class Session; } // namespace Main class StickersBox final - : public BoxContent + : public Ui::BoxContent , public RPCSender , private base::Subscriber { public: @@ -365,7 +366,7 @@ private: object_ptr _megagroupSetField = { nullptr }; object_ptr _megagroupSelectedShadow = { nullptr }; object_ptr _megagroupSelectedRemove = { nullptr }; - object_ptr _megagroupDivider = { nullptr }; + object_ptr _megagroupDivider = { nullptr }; object_ptr _megagroupSubTitle = { nullptr }; base::Timer _megagroupSetAddressChangedTimer; mtpRequestId _megagroupSetRequestId = 0; diff --git a/Telegram/SourceFiles/boxes/url_auth_box.cpp b/Telegram/SourceFiles/boxes/url_auth_box.cpp index 29c0d6aa8f..65b504ce27 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "apiwrap.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" void UrlAuthBox::Activate( @@ -85,7 +86,7 @@ void UrlAuthBox::Request( const auto bot = request.is_request_write_access() ? session->data().processUser(request.vbot()).get() : nullptr; - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto finishWithUrl = [=](const QString &url) { if (*box) { (*box)->closeBox(); @@ -122,7 +123,7 @@ void UrlAuthBox::Request( }; *box = Ui::show( Box(session, url, qs(request.vdomain()), bot, callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } UrlAuthBox::UrlAuthBox( diff --git a/Telegram/SourceFiles/boxes/url_auth_box.h b/Telegram/SourceFiles/boxes/url_auth_box.h index ddad3204f4..4ac461326e 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.h +++ b/Telegram/SourceFiles/boxes/url_auth_box.h @@ -16,7 +16,7 @@ namespace Main { class Session; } // namespace Main -class UrlAuthBox : public BoxContent { +class UrlAuthBox : public Ui::BoxContent { public: static void Activate( not_null message, diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 55db8b2947..f90b173916 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "data/data_session.h" #include "data/data_user.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include diff --git a/Telegram/SourceFiles/boxes/username_box.h b/Telegram/SourceFiles/boxes/username_box.h index c1b1e8b65d..2cc31dd528 100644 --- a/Telegram/SourceFiles/boxes/username_box.h +++ b/Telegram/SourceFiles/boxes/username_box.h @@ -18,7 +18,7 @@ namespace Main { class Session; } // namespace Main -class UsernameBox : public BoxContent, public RPCSender { +class UsernameBox : public Ui::BoxContent, public RPCSender { public: UsernameBox(QWidget*, not_null session); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index bea980c4b3..f4e0d76aab 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -22,14 +22,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "layout.h" #include "app.h" #include "styles/style_calls.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Calls { namespace { constexpr auto kUpdateDebugTimeoutMs = crl::time(500); -class DebugInfoBox : public BoxContent { +class DebugInfoBox : public Ui::BoxContent { public: DebugInfoBox(QWidget*, base::weak_ptr call); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index f3b6635e20..ad1f896fc4 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_account.h" #include "mainwidget.h" #include "app.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.h b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.h index 13dfdf6e50..316b061005 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.h @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { namespace Emoji { -class ManageSetsBox : public BoxContent { +class ManageSetsBox : public Ui::BoxContent { public: explicit ManageSetsBox(QWidget*); diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 93e4400e71..a3b1f94b44 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "mainwindow.h" #include "main/main_session.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_history.h" @@ -57,7 +58,7 @@ public: }; -class EditLinkBox : public BoxContent { +class EditLinkBox : public Ui::BoxContent { public: EditLinkBox( QWidget*, @@ -247,7 +248,7 @@ FncommitMarkdownLinkEdit(selection, text, link); } - }), LayerOption::KeepOther); + }), Ui::LayerOption::KeepOther); return true; }; } diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index 3fd8c702fa..6cebd226f0 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -82,7 +82,7 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) { toast.multiline = true; toast.padding = st::stickersToastPadding; Ui::Toast::Show(toast); -// Ui::show(Box(archived, &Auth()), LayerOption::KeepOther); +// Ui::show(Box(archived, &Auth()), Ui::LayerOption::KeepOther); Auth().data().notifyStickersUpdated(); } @@ -187,7 +187,7 @@ void UndoInstallLocally(uint64 setId) { Ui::show( Box(tr::lng_stickers_not_found(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool IsFaved(not_null document) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index f88aebbac5..908cb45a27 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2775,7 +2775,7 @@ void StickersListWidget::displaySet(uint64 setId) { _displayingSet = true; checkHideWithBox(Ui::show( Box(_megagroupSet), - LayerOption::KeepOther).data()); + Ui::LayerOption::KeepOther).data()); return; } else if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) { setId = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID().vid().v; @@ -2789,11 +2789,11 @@ void StickersListWidget::displaySet(uint64 setId) { _displayingSet = true; checkHideWithBox(Ui::show( Box(controller(), Stickers::inputSetId(*it)), - LayerOption::KeepOther).data()); + Ui::LayerOption::KeepOther).data()); } } -void StickersListWidget::checkHideWithBox(QPointer box) { +void StickersListWidget::checkHideWithBox(QPointer box) { if (!box) { return; } diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index bfe030dbdd..53c11c794a 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -12,8 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/variant.h" #include "base/timer.h" -class BoxContent; - namespace Main { class Session; } // namespace Main @@ -25,6 +23,7 @@ class SessionController; namespace Ui { class LinkButton; class RippleAnimation; +class BoxContent; } // namespace Ui namespace Lottie { @@ -203,7 +202,7 @@ private: void setSection(Section section); void displaySet(uint64 setId); - void checkHideWithBox(QPointer box); + void checkHideWithBox(QPointer box); void installSet(uint64 setId); void removeMegagroupSet(bool locally); void removeSet(uint64 setId); diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 8ee6961c3d..e9c284414a 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -16,7 +16,6 @@ class MainWindow; class MainWidget; class FileUploader; class Translator; -class BoxContent; namespace Storage { class Databases; @@ -43,6 +42,7 @@ namespace Ui { namespace Animations { class Manager; } // namespace Animations +class BoxContent; } // namespace Ui namespace MTP { @@ -273,7 +273,7 @@ private: const std::unique_ptr _emojiKeywords; std::unique_ptr _translator; base::Observable _passcodedChanged; - QPointer _badProxyDisableBox; + QPointer _badProxyDisableBox; const std::unique_ptr _audio; const QImage _logo; diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 32828252a9..e98d6a5e65 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -58,7 +58,7 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) { tr::lng_open_this_link(tr::now) + qsl("\n\n") + displayUrl, tr::lng_open_link(tr::now), [=] { Ui::hideLayer(); open(); }), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } else { open(); } diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 0799098dc7..f19f54a247 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -341,7 +341,7 @@ bool HandleUnknown( Api::EntitiesFromMTP(result.ventities().value_or_empty()) }; if (result.is_update_app()) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto callback = [=] { Core::UpdateApplication(); if (*box) (*box)->closeBox(); diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index efe892b81b..709ae2234c 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/settings/info_settings_widget.h" #include "window/window_session_controller.h" #include "settings/settings_intro.h" +#include "ui/layers/box_content.h" #include "app.h" #include diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 776af0db94..39d22c4fde 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -23,7 +23,6 @@ class Image; class HistoryItem; class HistoryMessage; class HistoryService; -class BoxContent; struct WebPageCollage; enum class WebPageType; enum class NewMessageType; @@ -54,6 +53,10 @@ class PanelController; } // namespace View } // namespace Export +namespace Ui { +class BoxContent; +} // namespace Ui + namespace Passport { struct SavedCredentials; } // namespace Passport @@ -840,7 +843,7 @@ private: std::unique_ptr _exportPanel; rpl::event_stream _exportViewChanges; TimeId _exportAvailableAt = 0; - QPointer _exportSuggestion; + QPointer _exportSuggestion; rpl::variable _contactsLoaded = false; rpl::event_stream _chatsListLoadedEvents; diff --git a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp index 9e11fa53e1..7f0206ace2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp @@ -39,7 +39,7 @@ void ShowSearchFromBox( box->addButton(tr::lng_cancel(), [box, subscription] { box->closeBox(); }); - }), LayerOption::KeepOther); + }), Ui::LayerOption::KeepOther); box->boxClosing() | rpl::start_with_next( std::move(closedCallback), *subscription); diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index d40907a8a5..dec220ed0b 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/unixtime.h" #include "facades.h" #include "styles/style_export.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Export { namespace View { @@ -30,7 +30,7 @@ namespace { constexpr auto kSaveSettingsTimeout = crl::time(1000); -class SuggestBox : public BoxContent { +class SuggestBox : public Ui::BoxContent { public: SuggestBox(QWidget*); @@ -85,9 +85,9 @@ Environment PrepareEnvironment() { return result; } -QPointer SuggestStart() { +QPointer SuggestStart() { ClearSuggestStart(); - return Ui::show(Box(), LayerOption::KeepOther).data(); + return Ui::show(Box(), Ui::LayerOption::KeepOther).data(); } void ClearSuggestStart() { @@ -166,10 +166,10 @@ void PanelController::showSettings() { auto settings = base::make_unique_q( _panel, *_settings); - settings->setShowBoxCallback([=](object_ptr box) { + settings->setShowBoxCallback([=](object_ptr box) { _panel->showBox( std::move(box), - LayerOption::KeepOther, + Ui::LayerOption::KeepOther, anim::type::normal); }); @@ -256,7 +256,7 @@ void PanelController::showError(const QString &text) { const auto hidden = _panel->isHidden(); _panel->showBox( std::move(box), - LayerOption::CloseOther, + Ui::LayerOption::CloseOther, hidden ? anim::type::instant : anim::type::normal); weak->setCloseByEscape(false); weak->setCloseByOutsideClick(false); @@ -330,7 +330,7 @@ void PanelController::stopWithConfirmation(FnMut callback) { _confirmStopBox = box.data(); _panel->showBox( std::move(box), - LayerOption::CloseOther, + Ui::LayerOption::CloseOther, hidden ? anim::type::instant : anim::type::normal); if (hidden) { _panel->showAndActivate(); diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.h b/Telegram/SourceFiles/export/view/export_view_panel_controller.h index 106fb13484..3bcebb5131 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.h +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.h @@ -12,10 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/unique_qptr.h" #include "base/timer.h" -class BoxContent; - namespace Ui { class SeparatePanel; +class BoxContent; } // namespace Ui namespace Export { @@ -25,7 +24,7 @@ struct Environment; namespace View { Environment PrepareEnvironment(); -QPointer SuggestStart(); +QPointer SuggestStart(); void ClearSuggestStart(); bool IsDefaultPath(const QString &path); void ResolveSettings(Settings &settings); @@ -71,7 +70,7 @@ private: base::unique_qptr _panel; State _state; - QPointer _confirmStopBox; + QPointer _confirmStopBox; rpl::event_stream> _panelCloseEvents; bool _stopRequested = false; rpl::lifetime _lifetime; diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index e964877d71..7722112549 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -27,7 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "styles/style_widgets.h" #include "styles/style_export.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Export { namespace View { diff --git a/Telegram/SourceFiles/export/view/export_view_settings.h b/Telegram/SourceFiles/export/view/export_view_settings.h index 68fae7695d..facc3efe83 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.h +++ b/Telegram/SourceFiles/export/view/export_view_settings.h @@ -11,12 +11,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/object_ptr.h" -class BoxContent; - namespace Ui { class VerticalLayout; class Checkbox; class ScrollArea; +class BoxContent; } // namespace Ui namespace Export { @@ -34,7 +33,7 @@ public: rpl::producer<> startClicks() const; rpl::producer<> cancelClicks() const; - void setShowBoxCallback(Fn)> callback) { + void setShowBoxCallback(Fn)> callback) { _showBoxCallback = std::move(callback); } @@ -97,7 +96,7 @@ private: void changeData(Callback &&callback); PeerId _singlePeerId = 0; - Fn)> _showBoxCallback; + Fn)> _showBoxCallback; // Use through readData / changeData wrappers. Settings _internal_data; diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index a1b1e6fcf0..cb8cd92624 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "boxes/confirm_box.h" #include "boxes/url_auth_box.h" -#include "window/layer_widget.h" +#include "ui/layers/layer_widget.h" #include "lang/lang_keys.h" #include "base/observer.h" #include "history/history.h" diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index 9354b05c58..5b7578ab58 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_channel.h" #include "data/data_user.h" #include "base/unixtime.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace AdminLog { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.h index 0d21cc7558..18741954eb 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.h @@ -12,9 +12,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace AdminLog { -class FilterBox : public BoxContent { +class FilterBox : public Ui::BoxContent { public: - FilterBox(QWidget*, not_null channel, const std::vector> &admins, const FilterValue &filter, Fn saveCallback); + FilterBox( + QWidget*, + not_null channel, + const std::vector> &admins, + const FilterValue &filter, + Fn saveCallback); protected: void prepare() override; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 183a3e0e5f..555364637a 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1212,7 +1212,7 @@ void InnerWidget::suggestRestrictUser(not_null user) { }); *weakBox = Ui::show( std::move(box), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }; if (base::contains(_admins, user)) { editRestrictions(true, MTP_chatBannedRights(MTP_flags(0), MTP_int(0))); diff --git a/Telegram/SourceFiles/history/history_drag_area.cpp b/Telegram/SourceFiles/history/history_drag_area.cpp index 9b9b4069f3..d786ad5c96 100644 --- a/Telegram/SourceFiles/history/history_drag_area.cpp +++ b/Telegram/SourceFiles/history/history_drag_area.cpp @@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "app.h" #include "styles/style_chat_helpers.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" DragArea::DragArea(QWidget *parent) : TWidget(parent) { setMouseTracking(true); diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index e6f756616b..077f7477ab 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -260,7 +260,7 @@ void FastShareMessage(not_null item) { text.append(error.first); Ui::show( Box(text), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index fd549bf9af..c1bd89f430 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3003,7 +3003,7 @@ void HistoryWidget::sendScheduled() { const auto callback = [=](Api::SendOptions options) { send(options); }; Ui::show( HistoryView::PrepareScheduleBox(_list, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } SendMenuType HistoryWidget::sendMenuType() const { @@ -5725,7 +5725,7 @@ bool HistoryWidget::sendExistingDocument(not_null document) { ? Data::RestrictionError(_peer, ChatRestriction::f_send_stickers) : std::nullopt; if (error) { - Ui::show(Box(*error), LayerOption::KeepOther); + Ui::show(Box(*error), Ui::LayerOption::KeepOther); return false; } else if (!_peer || !_peer->canWrite()) { return false; @@ -5756,7 +5756,7 @@ bool HistoryWidget::sendExistingPhoto(not_null photo) { ? Data::RestrictionError(_peer, ChatRestriction::f_send_media) : std::nullopt; if (error) { - Ui::show(Box(*error), LayerOption::KeepOther); + Ui::show(Box(*error), Ui::LayerOption::KeepOther); return false; } else if (!_peer || !_peer->canWrite()) { return false; diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 6404bccd4e..94b2113cda 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" +#include "ui/layers/generic_box.h" #include "ui/toast/toast.h" #include "ui/text/text_utilities.h" #include "data/data_peer.h" @@ -23,11 +24,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "main/main_session.h" #include "boxes/confirm_box.h" -#include "boxes/generic_box.h" // window->show(Box(InitMethod())) #include "boxes/peers/edit_contact_box.h" #include "app.h" #include "styles/style_history.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace HistoryView { namespace { @@ -313,7 +313,7 @@ void ContactStatus::setupBlockHandler(not_null user) { void ContactStatus::setupShareHandler(not_null user) { _bar.entity()->shareClicks( ) | rpl::start_with_next([=] { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto share = [=] { user->setSettings(0); user->session().api().request(MTPcontacts_AcceptContact( @@ -349,7 +349,7 @@ void ContactStatus::setupReportHandler(not_null peer) { ) | rpl::start_with_next([=] { Expects(!peer->isUser()); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto callback = crl::guard(&_bar, [=] { if (*box) { (*box)->closeBox(); diff --git a/Telegram/SourceFiles/history/view/history_view_schedule_box.cpp b/Telegram/SourceFiles/history/view/history_view_schedule_box.cpp index 20b6dd9e58..64ef33a53e 100644 --- a/Telegram/SourceFiles/history/view/history_view_schedule_box.cpp +++ b/Telegram/SourceFiles/history/view/history_view_schedule_box.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/wrap/padding_wrap.h" #include "chat_helpers/message_field.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_history.h" namespace HistoryView { @@ -542,7 +542,7 @@ TimeId DefaultScheduleTime() { } void ScheduleBox( - not_null box, + not_null box, SendMenuType type, FnMut done, TimeId time) { diff --git a/Telegram/SourceFiles/history/view/history_view_schedule_box.h b/Telegram/SourceFiles/history/view/history_view_schedule_box.h index a0269a5fcf..387ee8c3c1 100644 --- a/Telegram/SourceFiles/history/view/history_view_schedule_box.h +++ b/Telegram/SourceFiles/history/view/history_view_schedule_box.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/generic_box.h" +#include "ui/layers/generic_box.h" namespace Api { struct SendOptions; @@ -19,13 +19,13 @@ namespace HistoryView { [[nodiscard]] TimeId DefaultScheduleTime(); void ScheduleBox( - not_null box, + not_null box, SendMenuType type, FnMut done, TimeId time); template -[[nodiscard]] object_ptr PrepareScheduleBox( +[[nodiscard]] object_ptr PrepareScheduleBox( Guard &&guard, SendMenuType type, Submit &&submit) { diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index f2813348f6..e1409ad36b 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "chat_helpers/message_field.h" // SendMenuType. #include "ui/widgets/scroll_area.h" #include "ui/widgets/shadow.h" +#include "ui/layers/generic_box.h" #include "ui/toast/toast.h" #include "ui/special_buttons.h" #include "ui/ui_utility.h" @@ -24,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "boxes/confirm_box.h" #include "boxes/send_files_box.h" -#include "boxes/generic_box.h" #include "window/window_session_controller.h" #include "window/window_peer_menu.h" #include "core/event_filter.h" @@ -344,7 +344,7 @@ void ScheduledWidget::uploadFile( }; Ui::show( PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool ScheduledWidget::showSendingFilesError( @@ -387,7 +387,7 @@ void ScheduledWidget::send() { const auto callback = [=](Api::SendOptions options) { send(options); }; Ui::show( PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ScheduledWidget::send(Api::SendOptions options) { @@ -432,7 +432,7 @@ void ScheduledWidget::sendExistingDocument( }; Ui::show( PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool ScheduledWidget::sendExistingDocument( @@ -442,7 +442,7 @@ bool ScheduledWidget::sendExistingDocument( _history->peer, ChatRestriction::f_send_stickers); if (error) { - Ui::show(Box(*error), LayerOption::KeepOther); + Ui::show(Box(*error), Ui::LayerOption::KeepOther); return false; } @@ -470,7 +470,7 @@ void ScheduledWidget::sendExistingPhoto(not_null photo) { }; Ui::show( PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool ScheduledWidget::sendExistingPhoto( @@ -480,7 +480,7 @@ bool ScheduledWidget::sendExistingPhoto( _history->peer, ChatRestriction::f_send_media); if (error) { - Ui::show(Box(*error), LayerOption::KeepOther); + Ui::show(Box(*error), Ui::LayerOption::KeepOther); return false; } @@ -507,7 +507,7 @@ void ScheduledWidget::sendInlineResult( }; Ui::show( PrepareScheduleBox(this, sendMenuType(), callback), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void ScheduledWidget::sendInlineResult( diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp index 2b745796c2..ca4b0317f4 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.cpp +++ b/Telegram/SourceFiles/info/info_layer_widget.cpp @@ -21,7 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "app.h" #include "styles/style_info.h" #include "styles/style_window.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Info { diff --git a/Telegram/SourceFiles/info/info_layer_widget.h b/Telegram/SourceFiles/info/info_layer_widget.h index 13241cab7e..db6edc1ace 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.h +++ b/Telegram/SourceFiles/info/info_layer_widget.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "window/layer_widget.h" +#include "ui/layers/layer_widget.h" #include "media/player/media_player_float.h" namespace Window { @@ -22,7 +22,7 @@ class WrapWidget; class TopBar; class LayerWidget - : public Window::LayerWidget + : public Ui::LayerWidget , private ::Media::Player::FloatDelegate { public: LayerWidget( diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index e20f7b471f..a4495b6778 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -163,7 +163,7 @@ object_ptr Memento::createWidget( return std::move(result); } -object_ptr Memento::createLayer( +object_ptr Memento::createLayer( not_null controller, const QRect &geometry) { if (geometry.width() >= LayerWidget::MinimalSupportedWidth()) { @@ -201,7 +201,7 @@ object_ptr MoveMemento::createWidget( return std::move(result); } -object_ptr MoveMemento::createLayer( +object_ptr MoveMemento::createLayer( not_null controller, const QRect &geometry) { if (geometry.width() < LayerWidget::MinimalSupportedWidth()) { diff --git a/Telegram/SourceFiles/info/info_memento.h b/Telegram/SourceFiles/info/info_memento.h index 73ec0da59f..45e41dff41 100644 --- a/Telegram/SourceFiles/info/info_memento.h +++ b/Telegram/SourceFiles/info/info_memento.h @@ -44,7 +44,7 @@ public: Window::Column column, const QRect &geometry) override; - object_ptr createLayer( + object_ptr createLayer( not_null controller, const QRect &geometry) override; @@ -98,7 +98,7 @@ public: Window::Column column, const QRect &geometry) override; - object_ptr createLayer( + object_ptr createLayer( not_null controller, const QRect &geometry) override; diff --git a/Telegram/SourceFiles/info/info_section_widget.cpp b/Telegram/SourceFiles/info/info_section_widget.cpp index 4050b0d401..cc0141ddf3 100644 --- a/Telegram/SourceFiles/info/info_section_widget.cpp +++ b/Telegram/SourceFiles/info/info_section_widget.cpp @@ -93,7 +93,7 @@ std::unique_ptr SectionWidget::createMemento() { return _content->createMemento(); } -object_ptr SectionWidget::moveContentToLayer( +object_ptr SectionWidget::moveContentToLayer( QRect bodyGeometry) { if (_content->controller()->wrap() != Wrap::Narrow || width() < LayerWidget::MinimalSupportedWidth()) { diff --git a/Telegram/SourceFiles/info/info_section_widget.h b/Telegram/SourceFiles/info/info_section_widget.h index 7f26ca57e7..1ca552569c 100644 --- a/Telegram/SourceFiles/info/info_section_widget.h +++ b/Telegram/SourceFiles/info/info_section_widget.h @@ -50,7 +50,7 @@ public: const Window::SectionShow ¶ms) override; std::unique_ptr createMemento() override; - object_ptr moveContentToLayer( + object_ptr moveContentToLayer( QRect bodyGeometry) override; // Float player interface. diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp index 0ccd361aa1..d94f87651d 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_controller.h" #include "ui/widgets/discrete_sliders.h" #include "ui/widgets/shadow.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/vertical_layout.h" #include "ui/search_field_controller.h" #include "styles/style_info.h" @@ -66,7 +67,7 @@ void InnerWidget::createOtherTypes() { _otherTypes->show(); createTypeButtons(); - _otherTypes->add(object_ptr(_otherTypes)); + _otherTypes->add(object_ptr(_otherTypes)); //createTabs(); _otherTypes->resizeToWidth(width()); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index d409762169..859e3d68a0 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -17,6 +17,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/widgets/shadow.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" +#include "ui/layers/generic_box.h" #include "ui/toast/toast.h" #include "ui/text/text_utilities.h" // Ui::Text::ToUpper #include "history/history_location_manager.h" // LocationClickHandler. @@ -26,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peer_list_controllers.h" #include "boxes/add_contact_box.h" #include "boxes/report_box.h" -#include "boxes/generic_box.h" // window->show(Box(InitMethod())) #include "boxes/peers/edit_contact_box.h" #include "lang/lang_keys.h" #include "info/info_controller.h" @@ -465,7 +466,7 @@ Ui::MultiSlideTracker DetailsFiller::fillChannelButtons( } object_ptr DetailsFiller::fill() { - add(object_ptr(_wrap)); + add(object_ptr(_wrap)); add(CreateSkipWidget(_wrap)); add(setupInfo()); if (!_peer->isSelf()) { @@ -746,7 +747,7 @@ object_ptr ActionsFiller::fill() { //} // //object_ptr FeedDetailsFiller::fill() { -// add(object_ptr(_wrap)); +// add(object_ptr(_wrap)); // add(CreateSkipWidget(_wrap)); // add(setupDefaultToggle()); // add(CreateSkipWidget(_wrap)); @@ -853,7 +854,7 @@ object_ptr SetupChannelMembers( ); auto members = result->entity(); - members->add(object_ptr(members)); + members->add(object_ptr(members)); members->add(CreateSkipWidget(members)); auto button = AddActionButton( members, diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index adf1ef84f6..8145c18b36 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/checkbox.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/shadow.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" #include "data/data_shared_media.h" @@ -102,7 +103,7 @@ object_ptr InnerWidget::setupContent( if (auto members = SetupChannelMembers(_controller, result.data(), _peer)) { result->add(std::move(members)); } - result->add(object_ptr(result)); + result->add(object_ptr(result)); if (auto actions = SetupActions(_controller, result.data(), _peer)) { result->add(std::move(actions)); } @@ -215,7 +216,7 @@ object_ptr InnerWidget::setupSharedMedia( auto layout = result->entity(); - layout->add(object_ptr(layout)); + layout->add(object_ptr(layout)); layout->add(object_ptr( layout, st::infoSharedMediaBottomSkip) diff --git a/Telegram/SourceFiles/intro/introcode.cpp b/Telegram/SourceFiles/intro/introcode.cpp index 2558f79691..26736e1a80 100644 --- a/Telegram/SourceFiles/intro/introcode.cpp +++ b/Telegram/SourceFiles/intro/introcode.cpp @@ -333,7 +333,7 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) { _code->setFocus(); return; } else if (!getData()->pwdRequest) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto callback = [=] { Core::UpdateApplication(); if (*box) (*box)->closeBox(); diff --git a/Telegram/SourceFiles/intro/intropwdcheck.cpp b/Telegram/SourceFiles/intro/intropwdcheck.cpp index 801f207cba..b8d31d8abf 100644 --- a/Telegram/SourceFiles/intro/intropwdcheck.cpp +++ b/Telegram/SourceFiles/intro/intropwdcheck.cpp @@ -360,7 +360,7 @@ void PwdCheckWidget::submit() { }); if (_notEmptyPassport) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto confirmed = [=] { send(); if (*box) { diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index a64998fd04..6ffe8b060a 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -38,7 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "facades.h" #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_intro.h" #include "styles/style_window.h" diff --git a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp index aade61114f..c025588fca 100644 --- a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp +++ b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp @@ -22,12 +22,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/file_utilities.h" #include "core/click_handler_types.h" #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Lang { namespace { -class ConfirmSwitchBox : public BoxContent { +class ConfirmSwitchBox : public Ui::BoxContent { public: ConfirmSwitchBox( QWidget*, @@ -46,7 +46,7 @@ private: }; -class NotReadyBox : public BoxContent { +class NotReadyBox : public Ui::BoxContent { public: NotReadyBox( QWidget*, @@ -349,7 +349,7 @@ bool CloudManager::showOfferSwitchBox() { tr::lng_cancel(tr::now), confirm, cancel), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return true; } @@ -471,7 +471,7 @@ void CloudManager::switchToLanguage(const Language &data) { tr::lng_box_ok(tr::now), tr::lng_cancel(tr::now), [=] { performSwitchAndRestart(data); }), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }).fail([=](const RPCError &error) { _switchingToLanguageRequest = 0; }).send(); @@ -515,12 +515,12 @@ void CloudManager::performSwitchToCustom() { tr::lng_box_ok(tr::now), tr::lng_cancel(tr::now), change), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } else { Ui::show( Box("Custom lang failed :(\n\nError: " + loader.errors()), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } }); } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 423acba133..ee09ab726e 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -608,7 +608,7 @@ bool MainWidget::setForwardDraft(PeerId peerId, MessageIdsList &&items) { session().data().idsToItems(items), true); if (!error.isEmpty()) { - Ui::show(Box(error), LayerOption::KeepOther); + Ui::show(Box(error), Ui::LayerOption::KeepOther); return false; } diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 0f89d24685..ae1af98e04 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -10,14 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_session.h" #include "dialogs/dialogs_layout.h" -#include "styles/style_dialogs.h" -#include "styles/style_window.h" -#include "styles/style_boxes.h" #include "history/history.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" #include "ui/widgets/tooltip.h" +#include "ui/layers/layer_widget.h" #include "ui/emoji_config.h" #include "ui/ui_utility.h" #include "lang/lang_cloud_manager.h" @@ -39,7 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_intro.h" #include "platform/platform_notifications_manager.h" #include "base/platform/base_platform_info.h" -#include "window/layer_widget.h" #include "window/notifications_manager.h" #include "window/themes/window_theme.h" #include "window/themes/window_theme_warning.h" @@ -50,6 +47,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_media_preview.h" #include "facades.h" #include "app.h" +#include "styles/style_dialogs.h" +#include "styles/style_layers.h" +#include "styles/style_window.h" #include #include @@ -274,7 +274,7 @@ void MainWindow::showSettings() { } void MainWindow::showSpecialLayer( - object_ptr layer, + object_ptr layer, anim::type animated) { if (_passcodeLock) { return; @@ -303,14 +303,16 @@ void MainWindow::showMainMenu() { if (isHidden()) showFromTray(); ensureLayerCreated(); - _layer->showMainMenu(sessionController(), anim::type::normal); + _layer->showMainMenu( + object_ptr(this, sessionController()), + anim::type::normal); } void MainWindow::ensureLayerCreated() { if (_layer) { return; } - _layer = base::make_unique_q( + _layer = base::make_unique_q( bodyWidget()); _layer->hideFinishEvents( @@ -367,8 +369,8 @@ MainWidget *MainWindow::mainWidget() { } void MainWindow::ui_showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) { if (box) { ensureLayerCreated(); @@ -600,7 +602,7 @@ void MainWindow::onShowAddContact() { if (account().sessionExists()) { Ui::show( Box(&account().session()), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } @@ -612,7 +614,7 @@ void MainWindow::onShowNewGroup() { Box( sessionController(), GroupInfoBox::Type::Group), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } @@ -624,7 +626,7 @@ void MainWindow::onShowNewChannel() { Box( sessionController(), GroupInfoBox::Type::Channel), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } } diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index ffc1604b30..11ba00c6df 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -10,11 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "platform/platform_main_window.h" #include "base/unique_qptr.h" -#include "window/layer_widget.h" +#include "ui/layers/layer_widget.h" #include "ui/effects/animation_value.h" class MainWidget; -class BoxContent; namespace Intro { class Widget; @@ -26,8 +25,6 @@ class ClearManager; namespace Window { class MediaPreviewWidget; -class LayerWidget; -class LayerStackWidget; class SectionMemento; struct SectionShow; class PasscodeLockWidget; @@ -39,6 +36,8 @@ class WarningWidget; namespace Ui { class LinkButton; +class BoxContent; +class LayerStackWidget; } // namespace Ui class MediaPreviewWidget; @@ -100,14 +99,14 @@ public: void updateTrayMenu(bool force = false) override; void showSpecialLayer( - object_ptr layer, + object_ptr layer, anim::type animated); bool showSectionInExistingLayer( not_null memento, const Window::SectionShow ¶ms); void ui_showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated); void ui_hideSettingsAndLayer(anim::type animated); void ui_removeLayerBlackout(); @@ -171,7 +170,7 @@ private: object_ptr _passcodeLock = { nullptr }; object_ptr _intro = { nullptr }; object_ptr _main = { nullptr }; - base::unique_qptr _layer; + base::unique_qptr _layer; object_ptr _mediaPreview = { nullptr }; object_ptr _testingThemeWarning = { nullptr }; diff --git a/Telegram/SourceFiles/passport/passport_form_controller.h b/Telegram/SourceFiles/passport/passport_form_controller.h index aadb0cd906..b7f56d4671 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_controller.h @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/weak_ptr.h" #include "core/core_cloud_password.h" -class BoxContent; class mtpFileLoader; namespace Storage { diff --git a/Telegram/SourceFiles/passport/passport_form_view_controller.h b/Telegram/SourceFiles/passport/passport_form_view_controller.h index 795fb84f1f..50d5b04e18 100644 --- a/Telegram/SourceFiles/passport/passport_form_view_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_view_controller.h @@ -50,8 +50,8 @@ public: virtual void editScope(int index) = 0; virtual void showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) = 0; virtual void showToast(const QString &text) = 0; virtual void suggestReset(Fn callback) = 0; @@ -64,7 +64,7 @@ public: template QPointer show( object_ptr box, - LayerOptions options = LayerOption::KeepOther, + Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type::normal) { auto result = QPointer(box.data()); showBox(std::move(box), options, animated); diff --git a/Telegram/SourceFiles/passport/passport_panel.cpp b/Telegram/SourceFiles/passport/passport_panel.cpp index b1618189da..0779886c72 100644 --- a/Telegram/SourceFiles/passport/passport_panel.cpp +++ b/Telegram/SourceFiles/passport/passport_panel.cpp @@ -93,8 +93,8 @@ void Panel::showEditValue(object_ptr from) { } void Panel::showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) { _widget->showBox(std::move(box), options, animated); _widget->showAndActivate(); diff --git a/Telegram/SourceFiles/passport/passport_panel.h b/Telegram/SourceFiles/passport/passport_panel.h index aa4ccb7233..ef40205c4f 100644 --- a/Telegram/SourceFiles/passport/passport_panel.h +++ b/Telegram/SourceFiles/passport/passport_panel.h @@ -7,13 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "window/layer_widget.h" - -class BoxContent; +#include "ui/layers/layer_widget.h" namespace Ui { class RpWidget; class SeparatePanel; +class BoxContent; } // namespace Ui namespace Passport { @@ -32,8 +31,8 @@ public: void showCriticalError(const QString &error); void showEditValue(object_ptr form); void showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated); void showToast(const QString &text); diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index 051c876b10..c67cd04bb3 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_countries.h" #include "layout.h" #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Passport { namespace { @@ -568,41 +568,6 @@ ScanInfo::ScanInfo( , error(error) { } -BoxPointer::BoxPointer(QPointer value) -: _value(value) { -} - -BoxPointer::BoxPointer(BoxPointer &&other) -: _value(base::take(other._value)) { -} - -BoxPointer &BoxPointer::operator=(BoxPointer &&other) { - std::swap(_value, other._value); - return *this; -} - -BoxPointer::~BoxPointer() { - if (const auto strong = get()) { - strong->closeBox(); - } -} - -BoxContent *BoxPointer::get() const { - return _value.data(); -} - -BoxPointer::operator BoxContent*() const { - return get(); -} - -BoxPointer::operator bool() const { - return get(); -} - -BoxContent *BoxPointer::operator->() const { - return get(); -} - PanelController::PanelController(not_null form) : _form(form) , _scopes(ComputeScopes(_form->form())) { @@ -750,7 +715,7 @@ void PanelController::setupPassword() { } void PanelController::cancelPasswordSubmit() { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); *box = show(Box( tr::lng_passport_stop_password_sure(tr::now), tr::lng_passport_stop(tr::now), @@ -926,7 +891,7 @@ void PanelController::deleteValueSure(bool withDetails) { } void PanelController::suggestReset(Fn callback) { - _resetBox = BoxPointer(show(Box( + _resetBox = Ui::BoxPointer(show(Box( Lang::Hard::PassportCorrupted(), Lang::Hard::PassportCorruptedReset(), [=] { resetPassport(callback); }, @@ -940,7 +905,7 @@ void PanelController::resetPassport(Fn callback) { st::attentionBoxButton, [=] { base::take(_resetBox); callback(); }, [=] { suggestReset(callback); })); - _resetBox = BoxPointer(box.data()); + _resetBox = Ui::BoxPointer(box.data()); } void PanelController::cancelReset() { @@ -986,7 +951,7 @@ void PanelController::showUpdateAppBox() { tr::lng_menu_update(tr::now), callback, [=] { _form->cancelSure(); }), - LayerOption::KeepOther, + Ui::LayerOption::KeepOther, anim::type::instant); } @@ -1104,7 +1069,7 @@ void PanelController::editWithUpload(int index, int documentIndex) { const auto widget = _panel->widget(); EditScans::ChooseScan(widget.get(), type, [=](QByteArray &&content) { if (_scopeDocumentTypeBox) { - _scopeDocumentTypeBox = BoxPointer(); + _scopeDocumentTypeBox = Ui::BoxPointer(); } if (!_editScope || !_editDocument) { startScopeEdit(index, documentIndex); @@ -1462,8 +1427,8 @@ void PanelController::cancelAuthSure() { } void PanelController::showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) { _panel->showBox(std::move(box), options, animated); } diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index 7f0e2ce415..beb3b103f2 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -9,6 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "passport/passport_form_view_controller.h" #include "passport/passport_form_controller.h" +#include "ui/layers/layer_widget.h" + +namespace Ui { +class BoxContent; +} // namespace Ui namespace Passport { @@ -63,23 +68,6 @@ struct ScopeError { QString text; }; -class BoxPointer { -public: - BoxPointer(QPointer value = nullptr); - BoxPointer(BoxPointer &&other); - BoxPointer &operator=(BoxPointer &&other); - ~BoxPointer(); - - BoxContent *get() const; - operator BoxContent*() const; - explicit operator bool() const; - BoxContent *operator->() const; - -private: - QPointer _value; - -}; - class PanelController : public ViewController { public: PanelController(not_null form); @@ -132,8 +120,8 @@ public: void cancelEditScope(); void showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) override; void showToast(const QString &text) override; void suggestReset(Fn callback) override; @@ -182,15 +170,15 @@ private: std::unique_ptr _panel; Fn _panelHasUnsavedChanges; - QPointer _confirmForgetChangesBox; - std::vector _editScopeBoxes; + QPointer _confirmForgetChangesBox; + std::vector _editScopeBoxes; Scope *_editScope = nullptr; const Value *_editValue = nullptr; const Value *_editDocument = nullptr; - BoxPointer _scopeDocumentTypeBox; - std::map, BoxPointer> _verificationBoxes; + Ui::BoxPointer _scopeDocumentTypeBox; + std::map, Ui::BoxPointer> _verificationBoxes; - BoxPointer _resetBox; + Ui::BoxPointer _resetBox; rpl::lifetime _lifetime; diff --git a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp index 2a42af8529..eb00b371f2 100644 --- a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp @@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "data/data_user.h" #include "data/data_countries.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_passport.h" namespace Passport { diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index d02e76c847..f328dbb623 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/fade_wrap.h" @@ -26,12 +27,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "app.h" #include "styles/style_passport.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Passport { namespace { -class VerifyBox : public BoxContent { +class VerifyBox : public Ui::BoxContent { public: VerifyBox( QWidget*, @@ -231,7 +232,7 @@ void PanelEditContact::setupControls( _content->resizeToWidth(width); }, _content->lifetime()); - _content->add(object_ptr( + _content->add(object_ptr( _content, st::passportFormDividerHeight)); if (!existing.isEmpty()) { @@ -389,7 +390,7 @@ void PanelEditContact::save(const QString &value) { _controller->saveScope(std::move(data), {}); } -object_ptr VerifyPhoneBox( +object_ptr VerifyPhoneBox( const QString &phone, int codeLength, Fn submit, @@ -409,7 +410,7 @@ object_ptr VerifyPhoneBox( nullptr); } -object_ptr VerifyEmailBox( +object_ptr VerifyEmailBox( const QString &email, int codeLength, Fn submit, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.h b/Telegram/SourceFiles/passport/passport_panel_edit_contact.h index cd58420b24..f911dac894 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.h +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.h @@ -10,13 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/object_ptr.h" -class BoxContent; - namespace Ui { class MaskedInputField; class PlainShadow; class RoundButton; class VerticalLayout; +class BoxContent; } // namespace Ui namespace Passport { @@ -76,13 +75,13 @@ private: }; -object_ptr VerifyPhoneBox( +object_ptr VerifyPhoneBox( const QString &phone, int codeLength, Fn submit, rpl::producer call, rpl::producer error); -object_ptr VerifyEmailBox( +object_ptr VerifyEmailBox( const QString &email, int codeLength, Fn submit, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index bcdbcdfeec..4d54bafafe 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -25,13 +25,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/confirm_box.h" #include "lang/lang_keys.h" #include "styles/style_widgets.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_passport.h" namespace Passport { namespace { -class RequestTypeBox : public BoxContent { +class RequestTypeBox : public Ui::BoxContent { public: RequestTypeBox( QWidget*, @@ -55,7 +55,7 @@ private: }; -class DeleteDocumentBox : public BoxContent { +class DeleteDocumentBox : public Ui::BoxContent { public: DeleteDocumentBox( QWidget*, @@ -676,7 +676,7 @@ void PanelEditDocument::save() { std::move(result.filesData)); } -object_ptr RequestIdentityType( +object_ptr RequestIdentityType( Fn submit, std::vector labels) { return Box( @@ -686,7 +686,7 @@ object_ptr RequestIdentityType( submit); } -object_ptr RequestAddressType( +object_ptr RequestAddressType( Fn submit, std::vector labels) { return Box( @@ -696,7 +696,7 @@ object_ptr RequestAddressType( submit); } -object_ptr ConfirmDeleteDocument( +object_ptr ConfirmDeleteDocument( Fn submit, const QString &text, const QString &detailsCheckbox) { diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.h b/Telegram/SourceFiles/passport/passport_panel_edit_document.h index fcf9aa2872..ce4ade6d21 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.h +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.h @@ -10,8 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/object_ptr.h" -class BoxContent; - namespace Ui { class InputField; class ScrollArea; @@ -20,6 +18,7 @@ class PlainShadow; class FlatLabel; class RoundButton; class VerticalLayout; +class BoxContent; template class SlideWrap; } // namespace Ui @@ -167,14 +166,14 @@ private: }; -object_ptr RequestIdentityType( +object_ptr RequestIdentityType( Fn submit, std::vector labels); -object_ptr RequestAddressType( +object_ptr RequestAddressType( Fn submit, std::vector labels); -object_ptr ConfirmDeleteDocument( +object_ptr ConfirmDeleteDocument( Fn submit, const QString &text, const QString &detailsCheckbox = QString()); diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp index eed9940901..bc57ac7a07 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_button.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/fade_wrap.h" #include "ui/wrap/slide_wrap.h" #include "ui/wrap/vertical_layout.h" @@ -23,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_media_prepare.h" #include "storage/file_upload.h" // For Storage::kUseBigFilesFrom. #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_passport.h" #include @@ -544,9 +545,9 @@ void EditScans::setupList( if (type == FileType::Scan) { list.divider = container->add( - object_ptr>( + object_ptr>( container, - object_ptr( + object_ptr( container, st::passportFormDividerHeight))); list.divider->toggle(list.files.empty(), anim::type::instant); @@ -591,7 +592,7 @@ void EditScans::setupList( chooseScan(type); }); - container->add(object_ptr( + container->add(object_ptr( container, st::passportFormDividerHeight)); } diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.h b/Telegram/SourceFiles/passport/passport_panel_edit_scans.h index b529db9632..6ec6783df4 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.h +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.h @@ -11,9 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" #include "base/object_ptr.h" -class BoxContentDivider; - namespace Ui { +class BoxContentDivider; class VerticalLayout; class FlatLabel; template @@ -96,7 +95,7 @@ private: std::vector files; std::optional initialCount; QString errorMissing; - QPointer> divider; + QPointer> divider; QPointer> header; QPointer> uploadMoreError; QPointer wrap; diff --git a/Telegram/SourceFiles/passport/passport_panel_form.cpp b/Telegram/SourceFiles/passport/passport_panel_form.cpp index 9db860a3c8..826851c742 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_form.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/fade_wrap.h" #include "ui/wrap/padding_wrap.h" @@ -24,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text_options.h" #include "ui/special_buttons.h" #include "styles/style_passport.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace Passport { @@ -245,7 +247,7 @@ not_null PanelForm::setupContent() { st::passportPasswordLabel)), st::passportFormAbout2Padding)->entity(); - inner->add(object_ptr( + inner->add(object_ptr( inner, st::passportFormDividerHeight)); inner->add( diff --git a/Telegram/SourceFiles/passport/passport_panel_form.h b/Telegram/SourceFiles/passport/passport_panel_form.h index a7fdd9f969..badc773f0f 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.h +++ b/Telegram/SourceFiles/passport/passport_panel_form.h @@ -10,9 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/object_ptr.h" -class BoxContentDivider; - namespace Ui { +class BoxContentDivider; class ScrollArea; class FadeShadow; class RoundButton; diff --git a/Telegram/SourceFiles/passport/passport_panel_password.cpp b/Telegram/SourceFiles/passport/passport_panel_password.cpp index 7b75f9f05e..d0c9abacc8 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_password.cpp @@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "info/profile/info_profile_icon.h" #include "styles/style_passport.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Passport { diff --git a/Telegram/SourceFiles/profile/profile.style b/Telegram/SourceFiles/profile/profile.style index 0869bbc6af..8546229f72 100644 --- a/Telegram/SourceFiles/profile/profile.style +++ b/Telegram/SourceFiles/profile/profile.style @@ -61,12 +61,6 @@ profileDropAreaBorderFg: profileDropAreaFg; profileDropAreaBorderWidth: 3px; profileDropAreaDuration: 200; -profileDividerBg: windowBgOver; -profileDividerFg: windowShadowFg; -profileDividerLeft: icon {{ "profile_divider_left", profileDividerFg }}; -profileDividerTop: icon {{ "profile_divider_top", profileDividerFg }}; -profileDividerBottom: icon {{ "profile_divider_bottom", profileDividerFg }}; - profileBlocksTop: 7px; profileBlocksBottom: 20px; profileBlockLeftMin: 8px; diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 01e6b17029..29c5fbbed5 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/stickers_box.h" #include "boxes/confirm_box.h" #include "boxes/background_box.h" -#include "boxes/generic_box.h" #include "boxes/background_preview_box.h" #include "boxes/download_path_box.h" #include "boxes/local_storage_box.h" @@ -23,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" +#include "ui/layers/generic_box.h" #include "ui/effects/radial_animation.h" #include "ui/toast/toast.h" #include "ui/image/image.h" @@ -50,7 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "facades.h" #include "app.h" #include "styles/style_settings.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Settings { namespace { diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 8fdd2cde5f..124cb7c8a4 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/padding_wrap.h" #include "ui/wrap/vertical_layout.h" #include "ui/widgets/labels.h" +#include "ui/widgets/box_content_divider.h" #include "info/profile/info_profile_button.h" #include "boxes/abstract_box.h" #include "window/themes/window_theme_editor_box.h" @@ -25,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "mainwindow.h" #include "main/main_session.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_settings.h" namespace Settings { @@ -64,7 +65,7 @@ void AddSkip(not_null container, int skip) { } void AddDivider(not_null container) { - container->add(object_ptr(container)); + container->add(object_ptr(container)); } void AddDividerText( diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 6522ef459a..dc83420086 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/popup_menu.h" +#include "ui/widgets/box_content_divider.h" #include "ui/special_buttons.h" #include "chat_helpers/emoji_suggestions_widget.h" #include "boxes/add_contact_box.h" @@ -31,7 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/file_utilities.h" #include "facades.h" #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_settings.h" #include @@ -46,7 +47,7 @@ void SetupPhoto( not_null container, not_null controller, not_null self) { - const auto wrap = container->add(object_ptr( + const auto wrap = container->add(object_ptr( container, st::settingsInfoPhotoHeight)); const auto photo = Ui::CreateChild( diff --git a/Telegram/SourceFiles/settings/settings_intro.cpp b/Telegram/SourceFiles/settings/settings_intro.cpp index d373256f52..276c998e08 100644 --- a/Telegram/SourceFiles/settings/settings_intro.cpp +++ b/Telegram/SourceFiles/settings/settings_intro.cpp @@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "app.h" #include "styles/style_settings.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_info.h" namespace Settings { diff --git a/Telegram/SourceFiles/settings/settings_intro.h b/Telegram/SourceFiles/settings/settings_intro.h index 7fccf37e2a..1213be7a3e 100644 --- a/Telegram/SourceFiles/settings/settings_intro.h +++ b/Telegram/SourceFiles/settings/settings_intro.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "window/layer_widget.h" +#include "ui/layers/layer_widget.h" namespace Ui { class VerticalLayout; @@ -21,7 +21,7 @@ namespace Settings { class IntroWidget; -class LayerWidget : public Window::LayerWidget { +class LayerWidget : public Ui::LayerWidget { public: LayerWidget(QWidget*); diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 5477c78e7c..1aaae0be26 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -300,7 +300,7 @@ void BlockedBoxController::BlockNewUser( }; Ui::show( Box(std::move(controller), std::move(initBox)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool BlockedBoxController::appendRow(not_null user) { @@ -521,7 +521,7 @@ void LastSeenPrivacyController::confirmSave( tr::lng_continue(tr::now), tr::lng_cancel(tr::now), std::move(callback)); - *weakBox = Ui::show(std::move(box), LayerOption::KeepOther); + *weakBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); } else { saveCallback(); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index 6ac954edef..284d588de3 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -504,7 +504,7 @@ bool CheckEditCloudPassword(not_null<::Main::Session*> session) { return false; } -object_ptr EditCloudPasswordBox(not_null session) { +object_ptr EditCloudPasswordBox(not_null session) { const auto current = session->api().passwordStateCurrent(); Assert(current.has_value()); @@ -554,8 +554,8 @@ void RemoveCloudPassword(not_null<::Main::Session*> session) { }, box->lifetime()); } -object_ptr CloudPasswordAppOutdatedBox() { - auto box = std::make_shared>(); +object_ptr CloudPasswordAppOutdatedBox() { + auto box = std::make_shared>(); const auto callback = [=] { Core::UpdateApplication(); if (*box) (*box)->closeBox(); @@ -589,7 +589,7 @@ void AddPrivacyButton( ) | rpl::start_with_next([=](const Privacy &value) { Ui::show( Box(controller, controllerFactory(), value), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); }); }); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.h b/Telegram/SourceFiles/settings/settings_privacy_security.h index 4853e88bc7..09ea6361bc 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.h +++ b/Telegram/SourceFiles/settings/settings_privacy_security.h @@ -11,17 +11,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" class EditPrivacyController; + +namespace Ui { class BoxContent; +} // namespace Ui namespace Settings { int ExceptionUsersCount(const std::vector> &exceptions); bool CheckEditCloudPassword(not_null<::Main::Session*> session); -object_ptr EditCloudPasswordBox( +object_ptr EditCloudPasswordBox( not_null<::Main::Session*> session); void RemoveCloudPassword(not_null<::Main::Session*> session); -object_ptr CloudPasswordAppOutdatedBox(); +object_ptr CloudPasswordAppOutdatedBox(); void AddPrivacyButton( not_null controller, diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index 67754d1fd6..2eca96d024 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -953,13 +953,13 @@ void FileLoadTask::finish() { Ui::show( Box( tr::lng_send_image_empty(tr::now, lt_name, _filepath)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); removeFromAlbum(); } else if (_result->filesize > App::kFileSizeLimit) { Ui::show( Box( tr::lng_send_image_too_large(tr::now, lt_name, _filepath)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); removeFromAlbum(); } else if (App::main()) { const auto fullId = _msgIdToEdit diff --git a/Telegram/SourceFiles/support/support_autocomplete.cpp b/Telegram/SourceFiles/support/support_autocomplete.cpp index 2e4e166d0f..844b025936 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.cpp +++ b/Telegram/SourceFiles/support/support_autocomplete.cpp @@ -24,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "facades.h" #include "styles/style_chat_helpers.h" #include "styles/style_window.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" namespace Support { namespace { diff --git a/Telegram/SourceFiles/support/support_autocomplete.h b/Telegram/SourceFiles/support/support_autocomplete.h index 4f552d11f6..903c460834 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.h +++ b/Telegram/SourceFiles/support/support_autocomplete.h @@ -60,7 +60,7 @@ private: }; class ConfirmContactBox - : public BoxContent + : public Ui::BoxContent , public HistoryView::SimpleElementDelegate { public: ConfirmContactBox( diff --git a/Telegram/SourceFiles/support/support_helper.cpp b/Telegram/SourceFiles/support/support_helper.cpp index 4b2afed2d0..56e2d717d9 100644 --- a/Telegram/SourceFiles/support/support_helper.cpp +++ b/Telegram/SourceFiles/support/support_helper.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "observer_peer.h" #include "apiwrap.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace Main { @@ -43,7 +44,7 @@ constexpr auto kOccupyFor = TimeId(60); constexpr auto kReoccupyEach = 30 * crl::time(1000); constexpr auto kMaxSupportInfoLength = MaxMessageSize * 4; -class EditInfoBox : public BoxContent { +class EditInfoBox : public Ui::BoxContent { public: EditInfoBox( QWidget*, @@ -517,7 +518,7 @@ void Helper::showEditInfoBox(not_null user) { }; Ui::show( Box(&user->session(), editData, save), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } void Helper::saveInfo( diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index a95a70d216..d26302a99f 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/multi_select.h" #include "ui/effects/ripple_animation.h" #include "data/data_countries.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_intro.h" diff --git a/Telegram/SourceFiles/ui/countryinput.h b/Telegram/SourceFiles/ui/countryinput.h index 33648c0c05..c8255115cc 100644 --- a/Telegram/SourceFiles/ui/countryinput.h +++ b/Telegram/SourceFiles/ui/countryinput.h @@ -54,7 +54,7 @@ private: }; -class CountrySelectBox : public BoxContent { +class CountrySelectBox : public Ui::BoxContent { Q_OBJECT public: diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.cpp b/Telegram/SourceFiles/ui/effects/radial_animation.cpp deleted file mode 100644 index ca0e2729e6..0000000000 --- a/Telegram/SourceFiles/ui/effects/radial_animation.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "ui/effects/radial_animation.h" - -#include "styles/style_widgets.h" - -namespace Ui { - -void RadialAnimation::start(float64 prg) { - _firstStart = _lastStart = _lastTime = crl::now(); - const auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength); - const auto iprgstrict = qRound(prg * AlmostFullArcLength); - _arcEnd = anim::value(iprgstrict, iprg); - _animation.start(); -} - -bool RadialAnimation::update(float64 prg, bool finished, crl::time ms) { - const auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength); - const auto result = (iprg != qRound(_arcEnd.to())); - if (_finished != finished) { - _arcEnd.start(iprg); - _finished = finished; - _lastStart = _lastTime; - } else if (result) { - _arcEnd.start(iprg); - _lastStart = _lastTime; - } - _lastTime = ms; - - const auto dt = float64(ms - _lastStart); - const auto fulldt = float64(ms - _firstStart); - const auto opacitydt = _finished - ? (_lastStart - _firstStart) - : fulldt; - _opacity = qMin(opacitydt / st::radialDuration, 1.); - if (anim::Disabled()) { - _arcEnd.update(1., anim::linear); - if (finished) { - stop(); - } - } else if (!finished) { - _arcEnd.update(1. - (st::radialDuration / (st::radialDuration + dt)), anim::linear); - } else if (dt >= st::radialDuration) { - _arcEnd.update(1., anim::linear); - stop(); - } else { - auto r = dt / st::radialDuration; - _arcEnd.update(r, anim::linear); - _opacity *= 1 - r; - } - auto fromstart = fulldt / st::radialPeriod; - _arcStart.update(fromstart - std::floor(fromstart), anim::linear); - return result; -} - -void RadialAnimation::stop() { - _firstStart = _lastStart = _lastTime = 0; - _arcEnd = anim::value(); - _animation.stop(); -} - -void RadialAnimation::draw( - Painter &p, - const QRect &inner, - int32 thickness, - style::color color) const { - const auto state = computeState(); - - auto o = p.opacity(); - p.setOpacity(o * state.shown); - - auto pen = color->p; - auto was = p.pen(); - pen.setWidth(thickness); - pen.setCapStyle(Qt::RoundCap); - p.setPen(pen); - - { - PainterHighQualityEnabler hq(p); - p.drawArc(inner, state.arcFrom, state.arcLength); - } - - p.setPen(was); - p.setOpacity(o); -} - -RadialState RadialAnimation::computeState() const { - auto length = MinArcLength + qRound(_arcEnd.current()); - auto from = QuarterArcLength - - length - - (anim::Disabled() ? 0 : qRound(_arcStart.current())); - if (rtl()) { - from = QuarterArcLength - (from - QuarterArcLength) - length; - if (from < 0) from += FullArcLength; - } - return { _opacity, from, length }; -} - -void InfiniteRadialAnimation::start(crl::time skip) { - const auto now = crl::now(); - if (_workFinished <= now && (_workFinished || !_workStarted)) { - _workStarted = std::max(now + _st.sineDuration - skip, crl::time(1)); - _workFinished = 0; - } - if (!_animation.animating()) { - _animation.start(); - } -} - -void InfiniteRadialAnimation::stop(anim::type animated) { - const auto now = crl::now(); - if (anim::Disabled() || animated == anim::type::instant) { - _workFinished = now; - } - if (!_workFinished) { - const auto zero = _workStarted - _st.sineDuration; - const auto index = (now - zero + _st.sinePeriod - _st.sineShift) - / _st.sinePeriod; - _workFinished = zero - + _st.sineShift - + (index * _st.sinePeriod) - + _st.sineDuration; - } else if (_workFinished <= now) { - _animation.stop(); - } -} - -void InfiniteRadialAnimation::draw( - Painter &p, - QPoint position, - int outerWidth) { - draw(p, position, _st.size, outerWidth); -} - -void InfiniteRadialAnimation::draw( - Painter &p, - QPoint position, - QSize size, - int outerWidth) { - const auto state = computeState(); - - auto o = p.opacity(); - p.setOpacity(o * state.shown); - - const auto rect = style::rtlrect( - position.x(), - position.y(), - size.width(), - size.height(), - outerWidth); - const auto was = p.pen(); - const auto brush = p.brush(); - if (anim::Disabled()) { - anim::DrawStaticLoading(p, rect, _st.thickness, _st.color); - } else { - auto pen = _st.color->p; - pen.setWidth(_st.thickness); - pen.setCapStyle(Qt::RoundCap); - p.setPen(pen); - - { - PainterHighQualityEnabler hq(p); - p.drawArc( - rect, - state.arcFrom, - state.arcLength); - } - } - p.setPen(was); - p.setBrush(brush); - p.setOpacity(o); -} - -RadialState InfiniteRadialAnimation::computeState() { - const auto now = crl::now(); - const auto linear = FullArcLength - - int(((now * FullArcLength) / _st.linearPeriod) % FullArcLength); - if (!_workStarted || (_workFinished && _workFinished <= now)) { - const auto shown = 0.; - _animation.stop(); - return { - shown, - linear, - FullArcLength }; - } - if (anim::Disabled()) { - const auto shown = 1.; - return { 1., 0, FullArcLength }; - } - const auto min = int(std::round(FullArcLength * _st.arcMin)); - const auto max = int(std::round(FullArcLength * _st.arcMax)); - if (now <= _workStarted) { - // zero .. _workStarted - const auto zero = _workStarted - _st.sineDuration; - const auto shown = (now - zero) / float64(_st.sineDuration); - const auto length = anim::interpolate( - FullArcLength, - min, - anim::sineInOut(1., snap(shown, 0., 1.))); - return { - shown, - linear, - length }; - } else if (!_workFinished || now <= _workFinished - _st.sineDuration) { - // _workStared .. _workFinished - _st.sineDuration - const auto shown = 1.; - const auto cycles = (now - _workStarted) / _st.sinePeriod; - const auto relative = (now - _workStarted) % _st.sinePeriod; - const auto smallDuration = _st.sineShift - _st.sineDuration; - const auto largeDuration = _st.sinePeriod - - _st.sineShift - - _st.sineDuration; - const auto basic = int((linear - + min - + (cycles * (FullArcLength + min - max))) % FullArcLength); - if (relative <= smallDuration) { - // localZero .. growStart - return { - shown, - basic - min, - min }; - } else if (relative <= smallDuration + _st.sineDuration) { - // growStart .. growEnd - const auto growLinear = (relative - smallDuration) / - float64(_st.sineDuration); - const auto growProgress = anim::sineInOut(1., growLinear); - const auto length = anim::interpolate(min, max, growProgress); - return { - shown, - basic - length, - length }; - } else if (relative <= _st.sinePeriod - _st.sineDuration) { - // growEnd .. shrinkStart - return { - shown, - basic - max, - max }; - } else { - // shrinkStart .. shrinkEnd - const auto shrinkLinear = (relative - - (_st.sinePeriod - _st.sineDuration)) - / float64(_st.sineDuration); - const auto shrinkProgress = anim::sineInOut(1., shrinkLinear); - const auto shrink = anim::interpolate( - 0, - max - min, - shrinkProgress); - return { - shown, - basic - max, - max - shrink }; // interpolate(max, min, shrinkProgress) - } - } else { - // _workFinished - _st.sineDuration .. _workFinished - const auto hidden = (now - (_workFinished - _st.sineDuration)) - / float64(_st.sineDuration); - const auto cycles = (_workFinished - _workStarted) / _st.sinePeriod; - const auto basic = int((linear - + min - + cycles * (FullArcLength + min - max)) % FullArcLength); - const auto length = anim::interpolate( - min, - FullArcLength, - anim::sineInOut(1., snap(hidden, 0., 1.))); - return { - 1. - hidden, - basic - length, - length }; - } - //const auto frontPeriods = time / st.sinePeriod; - //const auto frontCurrent = time % st.sinePeriod; - //const auto frontProgress = anim::sineInOut( - // st.arcMax - st.arcMin, - // std::min(frontCurrent, crl::time(st.sineDuration)) - // / float64(st.sineDuration)); - //const auto backTime = std::max(time - st.sineShift, 0LL); - //const auto backPeriods = backTime / st.sinePeriod; - //const auto backCurrent = backTime % st.sinePeriod; - //const auto backProgress = anim::sineInOut( - // st.arcMax - st.arcMin, - // std::min(backCurrent, crl::time(st.sineDuration)) - // / float64(st.sineDuration)); - //const auto front = linear + std::round((st.arcMin + frontProgress + frontPeriods * (st.arcMax - st.arcMin)) * FullArcLength); - //const auto from = linear + std::round((backProgress + backPeriods * (st.arcMax - st.arcMin)) * FullArcLength); - //const auto length = (front - from); - - //return { - // _opacity, - // from, - // length - //}; -} - -} // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.h b/Telegram/SourceFiles/ui/effects/radial_animation.h deleted file mode 100644 index be5b389e24..0000000000 --- a/Telegram/SourceFiles/ui/effects/radial_animation.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -#include "ui/effects/animations.h" - -namespace style { -struct InfiniteRadialAnimation; -} // namespace style - -namespace Ui { - -struct RadialState { - float64 shown = 0.; - int arcFrom = 0; - int arcLength = FullArcLength; -}; - -class RadialAnimation { -public: - template - RadialAnimation(Callback &&callback); - - float64 opacity() const { - return _opacity; - } - bool animating() const { - return _animation.animating(); - } - - void start(float64 prg); - bool update(float64 prg, bool finished, crl::time ms); - void stop(); - - void draw( - Painter &p, - const QRect &inner, - int32 thickness, - style::color color) const; - - RadialState computeState() const; - -private: - crl::time _firstStart = 0; - crl::time _lastStart = 0; - crl::time _lastTime = 0; - float64 _opacity = 0.; - anim::value _arcEnd; - anim::value _arcStart; - Ui::Animations::Basic _animation; - bool _finished = false; - -}; - -template -inline RadialAnimation::RadialAnimation(Callback &&callback) -: _arcStart(0, FullArcLength) -, _animation(std::forward(callback)) { -} - - -class InfiniteRadialAnimation { -public: - template - InfiniteRadialAnimation( - Callback &&callback, - const style::InfiniteRadialAnimation &st); - - bool animating() const { - return _animation.animating(); - } - - void start(crl::time skip = 0); - void stop(anim::type animated = anim::type::normal); - - void draw( - Painter &p, - QPoint position, - int outerWidth); - void draw( - Painter &p, - QPoint position, - QSize size, - int outerWidth); - - RadialState computeState(); - -private: - const style::InfiniteRadialAnimation &_st; - crl::time _workStarted = 0; - crl::time _workFinished = 0; - Ui::Animations::Basic _animation; - -}; - -template -inline InfiniteRadialAnimation::InfiniteRadialAnimation( - Callback &&callback, - const style::InfiniteRadialAnimation &st) -: _st(st) -, _animation(std::forward(callback)) { -} - -} // namespace Ui diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 90da8b8447..7a77374332 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -74,13 +74,13 @@ void SuggestPhoto( || badAspect(image.height(), image.width())) { Ui::show( Box(tr::lng_bad_photo(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } const auto box = Ui::show( Box(image, title), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); box->ready( ) | rpl::start_with_next( std::forward(callback), diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp index fab73dc979..77afdb0ff7 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp @@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/widgets/tooltip.h" #include "ui/platform/ui_platform_utility.h" -#include "window/layer_widget.h" +#include "ui/layers/layer_widget.h" #include "window/themes/window_theme.h" #include "core/application.h" #include "app.h" @@ -265,8 +265,8 @@ int SeparatePanel::hideGetDuration() { } void SeparatePanel::showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated) { ensureLayerCreated(); _layer->showBox(std::move(box), options, animated); @@ -282,7 +282,7 @@ void SeparatePanel::ensureLayerCreated() { if (_layer) { return; } - _layer = base::make_unique_q(_body); + _layer = base::make_unique_q(_body); _layer->setHideByBackgroundClick(false); _layer->move(0, 0); _body->sizeValue( diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.h b/Telegram/SourceFiles/ui/widgets/separate_panel.h index cdf439ae5f..92608fac1c 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.h +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.h @@ -9,19 +9,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "ui/effects/animations.h" -#include "boxes/abstract_box.h" +#include "ui/layers/layer_widget.h" namespace Ui { +class BoxContent; class IconButton; +class LayerStackWidget; class FlatLabel; template class FadeWrapScaled; } // namespace Ui -namespace Window { -class LayerStackWidget; -} // namespace Window - namespace Ui { class SeparatePanel : public Ui::RpWidget, private base::Subscriber { @@ -37,8 +35,8 @@ public: void showInner(base::unique_qptr inner); void showBox( - object_ptr box, - LayerOptions options, + object_ptr box, + Ui::LayerOptions options, anim::type animated); void showToast(const QString &text); void destroyLayer(); @@ -86,7 +84,7 @@ private: object_ptr> _back; object_ptr _body; base::unique_qptr _inner; - base::unique_qptr _layer = { nullptr }; + base::unique_qptr _layer = { nullptr }; rpl::event_stream<> _synteticBackRequests; rpl::event_stream<> _userCloseRequests; rpl::event_stream<> _closeEvents; diff --git a/Telegram/SourceFiles/window/layer_widget.cpp b/Telegram/SourceFiles/window/layer_widget.cpp deleted file mode 100644 index ff0d601d5e..0000000000 --- a/Telegram/SourceFiles/window/layer_widget.cpp +++ /dev/null @@ -1,847 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "window/layer_widget.h" - -#include "boxes/abstract_box.h" -#include "ui/widgets/shadow.h" -#include "ui/ui_utility.h" -#include "window/window_main_menu.h" -#include "app.h" -#include "styles/style_boxes.h" -#include "styles/style_widgets.h" - -namespace Window { - -class LayerStackWidget::BackgroundWidget : public TWidget { -public: - BackgroundWidget(QWidget *parent) : TWidget(parent) { - } - - void setDoneCallback(Fn callback) { - _doneCallback = std::move(callback); - } - - void setLayerBoxes(const QRect &specialLayerBox, const QRect &layerBox); - void setCacheImages( - QPixmap &&bodyCache, - QPixmap &&mainMenuCache, - QPixmap &&specialLayerCache, - QPixmap &&layerCache); - void removeBodyCache(); - void startAnimation(Action action); - void skipAnimation(Action action); - void finishAnimating(); - - bool animating() const { - return _a_mainMenuShown.animating() || _a_specialLayerShown.animating() || _a_layerShown.animating(); - } - -protected: - void paintEvent(QPaintEvent *e) override; - -private: - bool isShown() const { - return _mainMenuShown || _specialLayerShown || _layerShown; - } - void checkIfDone(); - void setMainMenuShown(bool shown); - void setSpecialLayerShown(bool shown); - void setLayerShown(bool shown); - void checkWasShown(bool wasShown); - void animationCallback(); - - QPixmap _bodyCache; - QPixmap _mainMenuCache; - int _mainMenuCacheWidth = 0; - QPixmap _specialLayerCache; - QPixmap _layerCache; - - Fn _doneCallback; - - bool _wasAnimating = false; - bool _inPaintEvent = false; - Ui::Animations::Simple _a_shown; - Ui::Animations::Simple _a_mainMenuShown; - Ui::Animations::Simple _a_specialLayerShown; - Ui::Animations::Simple _a_layerShown; - - QRect _specialLayerBox, _specialLayerCacheBox; - QRect _layerBox, _layerCacheBox; - int _mainMenuRight = 0; - - bool _mainMenuShown = false; - bool _specialLayerShown = false; - bool _layerShown = false; - -}; - -void LayerStackWidget::BackgroundWidget::setCacheImages( - QPixmap &&bodyCache, - QPixmap &&mainMenuCache, - QPixmap &&specialLayerCache, - QPixmap &&layerCache) { - _bodyCache = std::move(bodyCache); - _mainMenuCache = std::move(mainMenuCache); - _specialLayerCache = std::move(specialLayerCache); - _layerCache = std::move(layerCache); - _specialLayerCacheBox = _specialLayerBox; - _layerCacheBox = _layerBox; - setAttribute(Qt::WA_OpaquePaintEvent, !_bodyCache.isNull()); -} - -void LayerStackWidget::BackgroundWidget::removeBodyCache() { - if (!_bodyCache.isNull()) { - _bodyCache = {}; - setAttribute(Qt::WA_OpaquePaintEvent, false); - } -} - -void LayerStackWidget::BackgroundWidget::startAnimation(Action action) { - if (action == Action::ShowMainMenu) { - setMainMenuShown(true); - } else if (action != Action::HideLayer - && action != Action::HideSpecialLayer) { - setMainMenuShown(false); - } - if (action == Action::ShowSpecialLayer) { - setSpecialLayerShown(true); - } else if (action == Action::ShowMainMenu - || action == Action::HideAll - || action == Action::HideSpecialLayer) { - setSpecialLayerShown(false); - } - if (action == Action::ShowLayer) { - setLayerShown(true); - } else if (action != Action::ShowSpecialLayer - && action != Action::HideSpecialLayer) { - setLayerShown(false); - } - _wasAnimating = true; - checkIfDone(); -} - -void LayerStackWidget::BackgroundWidget::skipAnimation(Action action) { - startAnimation(action); - finishAnimating(); -} - -void LayerStackWidget::BackgroundWidget::checkIfDone() { - if (!_wasAnimating || _inPaintEvent || animating()) { - return; - } - _wasAnimating = false; - _mainMenuCache = _specialLayerCache = _layerCache = QPixmap(); - removeBodyCache(); - if (_doneCallback) { - _doneCallback(); - } -} - -void LayerStackWidget::BackgroundWidget::setMainMenuShown(bool shown) { - auto wasShown = isShown(); - if (_mainMenuShown != shown) { - _mainMenuShown = shown; - _a_mainMenuShown.start([this] { animationCallback(); }, _mainMenuShown ? 0. : 1., _mainMenuShown ? 1. : 0., st::boxDuration, anim::easeOutCirc); - } - _mainMenuCacheWidth = (_mainMenuCache.width() / cIntRetinaFactor()) - st::boxRoundShadow.extend.right(); - _mainMenuRight = _mainMenuShown ? _mainMenuCacheWidth : 0; - checkWasShown(wasShown); -} - -void LayerStackWidget::BackgroundWidget::setSpecialLayerShown(bool shown) { - auto wasShown = isShown(); - if (_specialLayerShown != shown) { - _specialLayerShown = shown; - _a_specialLayerShown.start([this] { animationCallback(); }, _specialLayerShown ? 0. : 1., _specialLayerShown ? 1. : 0., st::boxDuration); - } - checkWasShown(wasShown); -} - -void LayerStackWidget::BackgroundWidget::setLayerShown(bool shown) { - auto wasShown = isShown(); - if (_layerShown != shown) { - _layerShown = shown; - _a_layerShown.start([this] { animationCallback(); }, _layerShown ? 0. : 1., _layerShown ? 1. : 0., st::boxDuration); - } - checkWasShown(wasShown); -} - -void LayerStackWidget::BackgroundWidget::checkWasShown(bool wasShown) { - if (isShown() != wasShown) { - _a_shown.start([this] { animationCallback(); }, wasShown ? 1. : 0., wasShown ? 0. : 1., st::boxDuration, anim::easeOutCirc); - } -} - -void LayerStackWidget::BackgroundWidget::setLayerBoxes(const QRect &specialLayerBox, const QRect &layerBox) { - _specialLayerBox = specialLayerBox; - _layerBox = layerBox; - update(); -} - -void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) { - Painter p(this); - - _inPaintEvent = true; - auto guard = gsl::finally([this] { - _inPaintEvent = false; - crl::on_main(this, [=] { checkIfDone(); }); - }); - - if (!_bodyCache.isNull()) { - p.drawPixmap(0, 0, _bodyCache); - } - - auto specialLayerBox = _specialLayerCache.isNull() ? _specialLayerBox : _specialLayerCacheBox; - auto layerBox = _layerCache.isNull() ? _layerBox : _layerCacheBox; - - auto mainMenuProgress = _a_mainMenuShown.value(-1); - auto mainMenuRight = (_mainMenuCache.isNull() || mainMenuProgress < 0) ? _mainMenuRight : (mainMenuProgress < 0) ? _mainMenuRight : anim::interpolate(0, _mainMenuCacheWidth, mainMenuProgress); - if (mainMenuRight) { - // Move showing boxes to the right while main menu is hiding. - if (!_specialLayerCache.isNull()) { - specialLayerBox.moveLeft(specialLayerBox.left() + mainMenuRight / 2); - } - if (!_layerCache.isNull()) { - layerBox.moveLeft(layerBox.left() + mainMenuRight / 2); - } - } - auto bgOpacity = _a_shown.value(isShown() ? 1. : 0.); - auto specialLayerOpacity = _a_specialLayerShown.value(_specialLayerShown ? 1. : 0.); - auto layerOpacity = _a_layerShown.value(_layerShown ? 1. : 0.); - if (bgOpacity == 0.) { - return; - } - - p.setOpacity(bgOpacity); - auto overSpecialOpacity = (layerOpacity * specialLayerOpacity); - auto bg = myrtlrect(mainMenuRight, 0, width() - mainMenuRight, height()); - - if (_mainMenuCache.isNull() && mainMenuRight > 0) { - // All cache images are taken together with their shadows, - // so we paint shadow only when there is no cache. - Ui::Shadow::paint(p, myrtlrect(0, 0, mainMenuRight, height()), width(), st::boxRoundShadow, RectPart::Right); - } - - if (_specialLayerCache.isNull() && !specialLayerBox.isEmpty()) { - // All cache images are taken together with their shadows, - // so we paint shadow only when there is no cache. - auto sides = RectPart::Left | RectPart::Right; - auto topCorners = (specialLayerBox.y() > 0); - auto bottomCorners = (specialLayerBox.y() + specialLayerBox.height() < height()); - if (topCorners) { - sides |= RectPart::Top; - } - if (bottomCorners) { - sides |= RectPart::Bottom; - } - if (topCorners || bottomCorners) { - p.setClipRegion(QRegion(rect()) - specialLayerBox.marginsRemoved(QMargins(st::boxRadius, 0, st::boxRadius, 0)) - specialLayerBox.marginsRemoved(QMargins(0, st::boxRadius, 0, st::boxRadius))); - } - Ui::Shadow::paint(p, specialLayerBox, width(), st::boxRoundShadow, sides); - - if (topCorners || bottomCorners) { - // In case of painting the shadow above the special layer we get - // glitches in the corners, so we need to paint the corners once more. - p.setClipping(false); - auto parts = (topCorners ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None) - | (bottomCorners ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None); - App::roundRect(p, specialLayerBox, st::boxBg, BoxCorners, nullptr, parts); - } - } - - if (!layerBox.isEmpty() && !_specialLayerCache.isNull() && overSpecialOpacity < bgOpacity) { - // In case of moving special layer below the background while showing a box - // we need to fill special layer rect below its cache with a complex opacity - // (alpha_final - alpha_current) / (1 - alpha_current) so we won't get glitches - // in the transparent special layer cache corners after filling special layer - // rect above its cache with alpha_current opacity. - auto region = QRegion(bg) - specialLayerBox; - for (auto rect : region.rects()) { - p.fillRect(rect, st::layerBg); - } - p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF()))); - p.fillRect(specialLayerBox, st::layerBg); - p.setOpacity(bgOpacity); - } else { - p.fillRect(bg, st::layerBg); - } - - if (!_specialLayerCache.isNull() && specialLayerOpacity > 0) { - p.setOpacity(specialLayerOpacity); - auto cacheLeft = specialLayerBox.x() - st::boxRoundShadow.extend.left(); - auto cacheTop = specialLayerBox.y() - (specialLayerBox.y() > 0 ? st::boxRoundShadow.extend.top() : 0); - p.drawPixmapLeft(cacheLeft, cacheTop, width(), _specialLayerCache); - } - if (!layerBox.isEmpty()) { - if (!_specialLayerCache.isNull()) { - p.setOpacity(overSpecialOpacity); - p.fillRect(specialLayerBox, st::layerBg); - } - if (_layerCache.isNull()) { - p.setOpacity(layerOpacity); - Ui::Shadow::paint(p, layerBox, width(), st::boxRoundShadow); - } - } - if (!_layerCache.isNull() && layerOpacity > 0) { - p.setOpacity(layerOpacity); - p.drawPixmapLeft(layerBox.topLeft() - QPoint(st::boxRoundShadow.extend.left(), st::boxRoundShadow.extend.top()), width(), _layerCache); - } - if (!_mainMenuCache.isNull() && mainMenuRight > 0) { - p.setOpacity(1.); - auto shownWidth = mainMenuRight + st::boxRoundShadow.extend.right(); - auto sourceWidth = shownWidth * cIntRetinaFactor(); - auto sourceRect = style::rtlrect(_mainMenuCache.width() - sourceWidth, 0, sourceWidth, _mainMenuCache.height(), _mainMenuCache.width()); - p.drawPixmapLeft(0, 0, shownWidth, height(), width(), _mainMenuCache, sourceRect); - } -} - -void LayerStackWidget::BackgroundWidget::finishAnimating() { - _a_shown.stop(); - _a_mainMenuShown.stop(); - _a_specialLayerShown.stop(); - _a_layerShown.stop(); - checkIfDone(); -} - -void LayerStackWidget::BackgroundWidget::animationCallback() { - update(); - checkIfDone(); -} - -LayerStackWidget::LayerStackWidget(QWidget *parent) -: RpWidget(parent) -, _background(this) { - setGeometry(parentWidget()->rect()); - hide(); - _background->setDoneCallback([this] { animationDone(); }); -} - -void LayerWidget::setInnerFocus() { - if (!isAncestorOf(window()->focusWidget())) { - doSetInnerFocus(); - } -} - -bool LayerWidget::overlaps(const QRect &globalRect) { - if (isHidden()) { - return false; - } - auto testRect = QRect(mapFromGlobal(globalRect.topLeft()), globalRect.size()); - if (testAttribute(Qt::WA_OpaquePaintEvent)) { - return rect().contains(testRect); - } - if (QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius).contains(testRect)) { - return true; - } - if (QRect(st::boxRadius, 0, width() - 2 * st::boxRadius, height()).contains(testRect)) { - return true; - } - return false; -} - -void LayerWidget::mousePressEvent(QMouseEvent *e) { - e->accept(); -} - -void LayerWidget::resizeEvent(QResizeEvent *e) { - if (_resizedCallback) { - _resizedCallback(); - } -} - -void LayerStackWidget::setHideByBackgroundClick(bool hide) { - _hideByBackgroundClick = hide; -} - -void LayerStackWidget::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Escape) { - hideCurrent(anim::type::normal); - } -} - -void LayerStackWidget::mousePressEvent(QMouseEvent *e) { - Ui::PostponeCall(this, [=] { backgroundClicked(); }); -} - -void LayerStackWidget::backgroundClicked() { - if (!_hideByBackgroundClick) { - return; - } - if (const auto layer = currentLayer()) { - if (!layer->closeByOutsideClick()) { - return; - } - } else if (const auto special = _specialLayer.data()) { - if (!special->closeByOutsideClick()) { - return; - } - } - hideCurrent(anim::type::normal); -} - -void LayerStackWidget::hideCurrent(anim::type animated) { - return currentLayer() ? hideLayers(animated) : hideAll(animated); -} - -void LayerStackWidget::hideLayers(anim::type animated) { - startAnimation([] {}, [&] { - clearLayers(); - }, Action::HideLayer, animated); -} - -void LayerStackWidget::hideAll(anim::type animated) { - startAnimation([] {}, [&] { - clearLayers(); - clearSpecialLayer(); - _mainMenu.destroy(); - }, Action::HideAll, animated); -} - -void LayerStackWidget::hideTopLayer(anim::type animated) { - if (_specialLayer || _mainMenu) { - hideLayers(animated); - } else { - hideAll(animated); - } -} - -void LayerStackWidget::removeBodyCache() { - _background->removeBodyCache(); - setAttribute(Qt::WA_OpaquePaintEvent, false); -} - -bool LayerStackWidget::layerShown() const { - return _specialLayer || currentLayer() || _mainMenu; -} - -void LayerStackWidget::setCacheImages() { - auto bodyCache = QPixmap(), mainMenuCache = QPixmap(); - auto specialLayerCache = QPixmap(); - if (_specialLayer) { - Ui::SendPendingMoveResizeEvents(_specialLayer); - auto sides = RectPart::Left | RectPart::Right; - if (_specialLayer->y() > 0) { - sides |= RectPart::Top; - } - if (_specialLayer->y() + _specialLayer->height() < height()) { - sides |= RectPart::Bottom; - } - specialLayerCache = Ui::Shadow::grab(_specialLayer, st::boxRoundShadow, sides); - } - auto layerCache = QPixmap(); - if (auto layer = currentLayer()) { - layerCache = Ui::Shadow::grab(layer, st::boxRoundShadow); - } - if (isAncestorOf(window()->focusWidget())) { - setFocus(); - } - if (_mainMenu) { - removeBodyCache(); - hideChildren(); - bodyCache = Ui::GrabWidget(parentWidget()); - showChildren(); - mainMenuCache = Ui::Shadow::grab(_mainMenu, st::boxRoundShadow, RectPart::Right); - } - setAttribute(Qt::WA_OpaquePaintEvent, !bodyCache.isNull()); - updateLayerBoxes(); - _background->setCacheImages(std::move(bodyCache), std::move(mainMenuCache), std::move(specialLayerCache), std::move(layerCache)); -} - -void LayerStackWidget::closeLayer(not_null layer) { - const auto weak = Ui::MakeWeak(layer.get()); - if (weak->inFocusChain()) { - setFocus(); - } - if (!weak || !weak->setClosing()) { - // This layer is already closing. - return; - } else if (!weak) { - // setClosing() could've killed the layer. - return; - } - - if (layer == _specialLayer) { - hideAll(anim::type::normal); - } else if (layer == currentLayer()) { - if (_layers.size() == 1) { - hideCurrent(anim::type::normal); - } else { - const auto taken = std::move(_layers.back()); - _layers.pop_back(); - - layer = currentLayer(); - layer->parentResized(); - if (!_background->animating()) { - layer->show(); - showFinished(); - } - } - } else { - for (auto i = _layers.begin(), e = _layers.end(); i != e; ++i) { - if (layer == i->get()) { - const auto taken = std::move(*i); - _layers.erase(i); - break; - } - } - } -} - -void LayerStackWidget::updateLayerBoxes() { - const auto layerBox = [&] { - if (const auto layer = currentLayer()) { - return layer->geometry(); - } - return QRect(); - }(); - const auto specialLayerBox = _specialLayer - ? _specialLayer->geometry() - : QRect(); - _background->setLayerBoxes(specialLayerBox, layerBox); - update(); -} - -void LayerStackWidget::finishAnimating() { - _background->finishAnimating(); -} - -bool LayerStackWidget::canSetFocus() const { - return (currentLayer() || _specialLayer || _mainMenu); -} - -void LayerStackWidget::setInnerFocus() { - if (_background->animating()) { - setFocus(); - } else if (auto l = currentLayer()) { - l->setInnerFocus(); - } else if (_specialLayer) { - _specialLayer->setInnerFocus(); - } else if (_mainMenu) { - _mainMenu->setInnerFocus(); - } -} - -bool LayerStackWidget::contentOverlapped(const QRect &globalRect) { - if (isHidden()) { - return false; - } - if (_specialLayer && _specialLayer->overlaps(globalRect)) { - return true; - } - if (auto layer = currentLayer()) { - return layer->overlaps(globalRect); - } - return false; -} - -template -void LayerStackWidget::startAnimation( - SetupNew setupNewWidgets, - ClearOld clearOldWidgets, - Action action, - anim::type animated) { - if (animated == anim::type::instant) { - setupNewWidgets(); - clearOldWidgets(); - prepareForAnimation(); - _background->skipAnimation(action); - } else { - setupNewWidgets(); - setCacheImages(); - const auto weak = Ui::MakeWeak(this); - clearOldWidgets(); - if (weak) { - prepareForAnimation(); - _background->startAnimation(action); - } - } -} - -void LayerStackWidget::resizeEvent(QResizeEvent *e) { - const auto weak = Ui::MakeWeak(this); - _background->setGeometry(rect()); - if (!weak) { - return; - } - if (_specialLayer) { - _specialLayer->parentResized(); - if (!weak) { - return; - } - } - if (const auto layer = currentLayer()) { - layer->parentResized(); - if (!weak) { - return; - } - } - if (_mainMenu) { - _mainMenu->resize(_mainMenu->width(), height()); - if (!weak) { - return; - } - } - updateLayerBoxes(); -} - -void LayerStackWidget::showBox( - object_ptr box, - LayerOptions options, - anim::type animated) { - if (options & LayerOption::KeepOther) { - if (options & LayerOption::ShowAfterOther) { - prependBox(std::move(box), animated); - } else { - appendBox(std::move(box), animated); - } - } else { - replaceBox(std::move(box), animated); - } -} - -void LayerStackWidget::replaceBox( - object_ptr box, - anim::type animated) { - const auto pointer = pushBox(std::move(box), animated); - const auto removeTill = ranges::find( - _layers, - pointer, - &std::unique_ptr::get); - _closingLayers.insert( - end(_closingLayers), - std::make_move_iterator(begin(_layers)), - std::make_move_iterator(removeTill)); - _layers.erase(begin(_layers), removeTill); - clearClosingLayers(); -} - -void LayerStackWidget::prepareForAnimation() { - if (isHidden()) { - show(); - } - if (_mainMenu) { - _mainMenu->hide(); - } - if (_specialLayer) { - _specialLayer->hide(); - } - if (const auto layer = currentLayer()) { - layer->hide(); - } -} - -void LayerStackWidget::animationDone() { - bool hidden = true; - if (_mainMenu) { - _mainMenu->show(); - hidden = false; - } - if (_specialLayer) { - _specialLayer->show(); - hidden = false; - } - if (auto layer = currentLayer()) { - layer->show(); - hidden = false; - } - setAttribute(Qt::WA_OpaquePaintEvent, false); - if (hidden) { - _hideFinishStream.fire({}); - } else { - showFinished(); - } -} - -rpl::producer<> LayerStackWidget::hideFinishEvents() const { - return _hideFinishStream.events(); -} - -void LayerStackWidget::showFinished() { - fixOrder(); - sendFakeMouseEvent(); - updateLayerBoxes(); - if (_specialLayer) { - _specialLayer->showFinished(); - } - if (auto layer = currentLayer()) { - layer->showFinished(); - } - if (canSetFocus()) { - setInnerFocus(); - } -} - -void LayerStackWidget::showSpecialLayer( - object_ptr layer, - anim::type animated) { - startAnimation([&] { - _specialLayer.destroy(); - _specialLayer = std::move(layer); - initChildLayer(_specialLayer); - }, [&] { - _mainMenu.destroy(); - }, Action::ShowSpecialLayer, animated); -} - -bool LayerStackWidget::showSectionInternal( - not_null memento, - const SectionShow ¶ms) { - if (_specialLayer) { - return _specialLayer->showSectionInternal(memento, params); - } - return false; -} - -void LayerStackWidget::hideSpecialLayer(anim::type animated) { - startAnimation([] {}, [&] { - clearSpecialLayer(); - _mainMenu.destroy(); - }, Action::HideSpecialLayer, animated); -} - -void LayerStackWidget::showMainMenu( - not_null controller, - anim::type animated) { - startAnimation([&] { - _mainMenu.create(this, controller); - _mainMenu->setGeometryToLeft(0, 0, _mainMenu->width(), height()); - _mainMenu->setParent(this); - }, [&] { - clearLayers(); - _specialLayer.destroy(); - }, Action::ShowMainMenu, animated); -} - -void LayerStackWidget::appendBox( - object_ptr box, - anim::type animated) { - pushBox(std::move(box), animated); -} - -LayerWidget *LayerStackWidget::pushBox( - object_ptr box, - anim::type animated) { - auto oldLayer = currentLayer(); - if (oldLayer) { - if (oldLayer->inFocusChain()) setFocus(); - oldLayer->hide(); - } - _layers.push_back(std::make_unique(this, std::move(box))); - const auto raw = _layers.back().get(); - initChildLayer(raw); - - if (_layers.size() > 1) { - if (!_background->animating()) { - raw->setVisible(true); - showFinished(); - } - } else { - startAnimation([] {}, [&] { - _mainMenu.destroy(); - }, Action::ShowLayer, animated); - } - - return raw; -} - -void LayerStackWidget::prependBox( - object_ptr box, - anim::type animated) { - if (_layers.empty()) { - replaceBox(std::move(box), animated); - return; - } - _layers.insert( - begin(_layers), - std::make_unique(this, std::move(box))); - const auto raw = _layers.front().get(); - raw->hide(); - initChildLayer(raw); -} - -bool LayerStackWidget::takeToThirdSection() { - return _specialLayer - ? _specialLayer->takeToThirdSection() - : false; -} - -void LayerStackWidget::clearLayers() { - _closingLayers.insert( - end(_closingLayers), - std::make_move_iterator(begin(_layers)), - std::make_move_iterator(end(_layers))); - _layers.clear(); - clearClosingLayers(); -} - -void LayerStackWidget::clearClosingLayers() { - const auto weak = Ui::MakeWeak(this); - while (!_closingLayers.empty()) { - const auto index = _closingLayers.size() - 1; - const auto layer = _closingLayers.back().get(); - if (layer->inFocusChain()) { - setFocus(); - } - - // This may destroy LayerStackWidget (by calling Ui::hideLayer). - // So each time we check a weak pointer (if we are still alive). - layer->setClosing(); - - // setClosing() could destroy 'this' or could call clearLayers(). - if (weak && !_closingLayers.empty()) { - // We could enqueue more closing layers, so we remove by index. - Assert(index < _closingLayers.size()); - Assert(_closingLayers[index].get() == layer); - _closingLayers.erase(begin(_closingLayers) + index); - } else { - // Everything was destroyed in clearLayers or ~LayerStackWidget. - break; - } - } -} - -void LayerStackWidget::clearSpecialLayer() { - if (_specialLayer) { - _specialLayer->setClosing(); - _specialLayer.destroy(); - } -} - -void LayerStackWidget::initChildLayer(LayerWidget *layer) { - layer->setParent(this); - layer->setClosedCallback([=] { closeLayer(layer); }); - layer->setResizedCallback([=] { updateLayerBoxes(); }); - Ui::SendPendingMoveResizeEvents(layer); - layer->parentResized(); -} - -void LayerStackWidget::fixOrder() { - if (auto layer = currentLayer()) { - _background->raise(); - layer->raise(); - } else if (_specialLayer) { - _specialLayer->raise(); - } - if (_mainMenu) { - _mainMenu->raise(); - } -} - -void LayerStackWidget::sendFakeMouseEvent() { - SendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton); -} - -LayerStackWidget::~LayerStackWidget() { - // Some layer destructors call back into LayerStackWidget. - while (!_layers.empty() || !_closingLayers.empty()) { - hideAll(anim::type::instant); - clearClosingLayers(); - } -} - -} // namespace Window diff --git a/Telegram/SourceFiles/window/layer_widget.h b/Telegram/SourceFiles/window/layer_widget.h deleted file mode 100644 index 3d41806f26..0000000000 --- a/Telegram/SourceFiles/window/layer_widget.h +++ /dev/null @@ -1,213 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -#include "ui/rp_widget.h" -#include "ui/effects/animations.h" -#include "base/object_ptr.h" -#include "base/flags.h" - -namespace Lottie { -class SinglePlayer; -} // namespace Lottie - -class BoxContent; - -enum class LayerOption { - CloseOther = (1 << 0), - KeepOther = (1 << 1), - ShowAfterOther = (1 << 2), -}; -using LayerOptions = base::flags; -inline constexpr auto is_flag_type(LayerOption) { return true; }; - -namespace Window { - -class MainMenu; -class SessionController; -class SectionMemento; -struct SectionShow; - -class LayerWidget : public Ui::RpWidget { -public: - using RpWidget::RpWidget; - - virtual void parentResized() = 0; - virtual void showFinished() { - } - void setInnerFocus(); - bool setClosing() { - if (!_closing) { - _closing = true; - closeHook(); - return true; - } - return false; - } - - bool overlaps(const QRect &globalRect); - - void setClosedCallback(Fn callback) { - _closedCallback = std::move(callback); - } - void setResizedCallback(Fn callback) { - _resizedCallback = std::move(callback); - } - virtual bool takeToThirdSection() { - return false; - } - virtual bool showSectionInternal( - not_null memento, - const SectionShow ¶ms) { - return false; - } - virtual bool closeByOutsideClick() const { - return true; - } - -protected: - void closeLayer() { - if (const auto callback = base::take(_closedCallback)) { - callback(); - } - } - void mousePressEvent(QMouseEvent *e) override; - void resizeEvent(QResizeEvent *e) override; - virtual void doSetInnerFocus() { - setFocus(); - } - virtual void closeHook() { - } - -private: - bool _closing = false; - Fn _closedCallback; - Fn _resizedCallback; - -}; - -class LayerStackWidget : public Ui::RpWidget { -public: - LayerStackWidget(QWidget *parent); - - void finishAnimating(); - rpl::producer<> hideFinishEvents() const; - - void showBox( - object_ptr box, - LayerOptions options, - anim::type animated); - void showSpecialLayer( - object_ptr layer, - anim::type animated); - void showMainMenu( - not_null controller, - anim::type animated); - bool takeToThirdSection(); - - bool canSetFocus() const; - void setInnerFocus(); - - bool contentOverlapped(const QRect &globalRect); - - void hideSpecialLayer(anim::type animated); - void hideLayers(anim::type animated); - void hideAll(anim::type animated); - void hideTopLayer(anim::type animated); - void setHideByBackgroundClick(bool hide); - void removeBodyCache(); - - bool showSectionInternal( - not_null memento, - const SectionShow ¶ms); - - bool layerShown() const; - - ~LayerStackWidget(); - -protected: - void keyPressEvent(QKeyEvent *e) override; - void mousePressEvent(QMouseEvent *e) override; - void resizeEvent(QResizeEvent *e) override; - -private: - void appendBox( - object_ptr box, - anim::type animated); - void prependBox( - object_ptr box, - anim::type animated); - void replaceBox( - object_ptr box, - anim::type animated); - void backgroundClicked(); - - LayerWidget *pushBox( - object_ptr box, - anim::type animated); - void showFinished(); - void hideCurrent(anim::type animated); - void closeLayer(not_null layer); - - enum class Action { - ShowMainMenu, - ShowSpecialLayer, - ShowLayer, - HideSpecialLayer, - HideLayer, - HideAll, - }; - template - void startAnimation( - SetupNew setupNewWidgets, - ClearOld clearOldWidgets, - Action action, - anim::type animated); - - void prepareForAnimation(); - void animationDone(); - - void setCacheImages(); - void clearLayers(); - void clearSpecialLayer(); - void initChildLayer(LayerWidget *layer); - void updateLayerBoxes(); - void fixOrder(); - void sendFakeMouseEvent(); - void clearClosingLayers(); - - LayerWidget *currentLayer() { - return _layers.empty() ? nullptr : _layers.back().get(); - } - const LayerWidget *currentLayer() const { - return const_cast(this)->currentLayer(); - } - - std::vector> _layers; - std::vector> _closingLayers; - - object_ptr _specialLayer = { nullptr }; - object_ptr _mainMenu = { nullptr }; - - class BackgroundWidget; - object_ptr _background; - bool _hideByBackgroundClick = true; - - rpl::event_stream<> _hideFinishStream; - -}; - -} // namespace Window - -class GenericBox; - -template -inline object_ptr Box(Args&&... args) { - const auto parent = static_cast(nullptr); - return object_ptr(parent, std::forward(args)...); -} diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 583198ce45..58c9a18247 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "facades.h" #include "app.h" #include "styles/style_window.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include #include @@ -217,7 +217,7 @@ void MainWindow::showTermsDecline() { tr::lng_terms_decline_and_delete(), tr::lng_terms_back(), true), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); box->agreeClicks( ) | rpl::start_with_next([=] { @@ -236,7 +236,7 @@ void MainWindow::showTermsDecline() { } void MainWindow::showTermsDelete() { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto deleteByTerms = [=] { if (account().sessionExists()) { account().session().termsDeleteNow(); @@ -251,7 +251,7 @@ void MainWindow::showTermsDelete() { st::attentionBoxButton, deleteByTerms, [=] { if (*box) (*box)->closeBox(); }), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); } bool MainWindow::hideNoQuit() { diff --git a/Telegram/SourceFiles/window/main_window.h b/Telegram/SourceFiles/window/main_window.h index 7395203299..a8eedea572 100644 --- a/Telegram/SourceFiles/window/main_window.h +++ b/Telegram/SourceFiles/window/main_window.h @@ -14,12 +14,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include -class BoxContent; - namespace Main { class Account; } // namespace Main +namespace Ui { +class BoxContent; +} // namespace Ui + namespace Window { class Controller; @@ -175,7 +177,7 @@ private: object_ptr _outdated; object_ptr _body; object_ptr _rightColumn = { nullptr }; - QPointer _termsBox; + QPointer _termsBox; QIcon _icon; bool _usingSupportIcon = false; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 54ddca477a..e0ba399a11 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -19,9 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/ui_utility.h" #include "dialogs/dialogs_layout.h" #include "window/themes/window_theme.h" -#include "styles/style_dialogs.h" -#include "styles/style_boxes.h" -#include "styles/style_window.h" #include "storage/file_download.h" #include "main/main_session.h" #include "history/history.h" @@ -29,6 +26,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "facades.h" #include "app.h" +#include "styles/style_dialogs.h" +#include "styles/style_layers.h" +#include "styles/style_window.h" #include diff --git a/Telegram/SourceFiles/window/section_memento.h b/Telegram/SourceFiles/window/section_memento.h index 3bf78f478c..628c27c64e 100644 --- a/Telegram/SourceFiles/window/section_memento.h +++ b/Telegram/SourceFiles/window/section_memento.h @@ -7,11 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +namespace Ui { +class LayerWidget; +} // namespace Ui + namespace Window { class SessionController; class SectionWidget; -class LayerWidget; enum class Column; class SectionMemento { @@ -22,7 +25,7 @@ public: Column column, const QRect &geometry) = 0; - virtual object_ptr createLayer( + virtual object_ptr createLayer( not_null controller, const QRect &geometry) { return nullptr; diff --git a/Telegram/SourceFiles/window/section_widget.h b/Telegram/SourceFiles/window/section_widget.h index 5962ef8ba2..0c755a9ee8 100644 --- a/Telegram/SourceFiles/window/section_widget.h +++ b/Telegram/SourceFiles/window/section_widget.h @@ -15,10 +15,13 @@ namespace Main { class Session; } // namespace Main +namespace Ui { +class LayerWidget; +} // namespace Ui + namespace Window { class SessionController; -class LayerWidget; class SlideAnimation; struct SectionShow; enum class SlideDirection; @@ -130,7 +133,7 @@ public: virtual rpl::producer desiredHeight() const; // Some sections convert to layers on some geometry sizes. - virtual object_ptr moveContentToLayer( + virtual object_ptr moveContentToLayer( QRect bodyGeometry) { return nullptr; } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 4fbf73e89d..769698566f 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "app.h" #include "styles/style_window.h" #include "styles/style_dialogs.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" namespace Window { @@ -888,7 +889,7 @@ void Editor::closeWithConfirmation() { closeEditor(); return; } - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto close = crl::guard(this, [=] { Background()->clearEditingTheme(ClearEditing::RevertChanges); closeEditor(); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index 2b7c2b55c0..60cf874412 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_widgets.h" #include "styles/style_window.h" #include "styles/style_settings.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include @@ -673,13 +674,13 @@ void StartEditor( } void CreateBox( - not_null box, + not_null box, not_null window) { CreateForExistingBox(box, window, Data::CloudTheme()); } void CreateForExistingBox( - not_null box, + not_null box, not_null window, const Data::CloudTheme &cloud) { const auto userId = window->account().sessionExists() @@ -807,7 +808,7 @@ QByteArray CollectForExport(const QByteArray &palette) { } void SaveThemeBox( - not_null box, + not_null box, not_null window, const Data::CloudTheme &cloud, const QByteArray &palette) { diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.h b/Telegram/SourceFiles/window/themes/window_theme_editor_box.h index 6accd30056..5d526c9052 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/generic_box.h" +#include "ui/layers/generic_box.h" namespace Data { struct CloudTheme; @@ -26,10 +26,10 @@ void StartEditor( not_null window, const Data::CloudTheme &cloud); void CreateBox( - not_null box, + not_null box, not_null window); void CreateForExistingBox( - not_null box, + not_null box, not_null window, const Data::CloudTheme &cloud); void SaveTheme( @@ -38,7 +38,7 @@ void SaveTheme( const QByteArray &palette, Fn unlock); void SaveThemeBox( - not_null box, + not_null box, not_null window, const Data::CloudTheme &cloud, const QByteArray &palette); diff --git a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp index 84a4649e85..ccdfe12f53 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp @@ -7,13 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/themes/window_theme_warning.h" -#include "styles/style_boxes.h" #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" #include "ui/ui_utility.h" #include "window/themes/window_theme.h" #include "lang/lang_keys.h" #include "app.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" namespace Window { namespace Theme { diff --git a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp index c3abbecef2..fb33bb12be 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp +++ b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp @@ -595,7 +595,7 @@ void CloudList::showMenu(Element &element) { } const auto id = cloud.id; _contextMenu->addAction(tr::lng_theme_delete(tr::now), [=] { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto remove = [=] { if (*box) { (*box)->closeBox(); diff --git a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h index b9b0cf1373..10fd9ade3e 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h +++ b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h @@ -7,8 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/generic_box.h" #include "data/data_cloud_themes.h" +#include "ui/layers/generic_box.h" #include "ui/widgets/checkbox.h" #include "base/unique_qptr.h" #include "base/binary_guard.h" diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index c15bc2b556..718b17ba51 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/ui_utility.h" #include "window/themes/window_theme.h" #include "boxes/connection_box.h" +#include "boxes/abstract_box.h" #include "lang/lang_keys.h" #include "facades.h" #include "app.h" diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 7ee034bd7e..d281aff339 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -9,7 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "main/main_account.h" -#include "window/layer_widget.h" +#include "ui/layers/box_content.h" +#include "ui/layers/layer_widget.h" #include "window/window_session_controller.h" #include "window/themes/window_theme.h" #include "window/themes/window_theme_editor.h" @@ -75,8 +76,8 @@ void Controller::showSettings() { } void Controller::showBox( - object_ptr content, - LayerOptions options, + object_ptr content, + Ui::LayerOptions options, anim::type animated) { _widget.ui_showBox(std::move(content), options, animated); } diff --git a/Telegram/SourceFiles/window/window_controller.h b/Telegram/SourceFiles/window/window_controller.h index eae0f4670c..d8adfc2e69 100644 --- a/Telegram/SourceFiles/window/window_controller.h +++ b/Telegram/SourceFiles/window/window_controller.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "mainwindow.h" +#include "ui/layers/layer_widget.h" namespace Main { class Account; @@ -45,7 +46,7 @@ public: template QPointer show( object_ptr content, - LayerOptions options = LayerOption::KeepOther, + Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type::normal) { const auto result = QPointer(content.data()); showBox(std::move(content), options, animated); @@ -66,8 +67,8 @@ public: private: void showBox( - object_ptr content, - LayerOptions options, + object_ptr content, + Ui::LayerOptions options, anim::type animated); void checkThemeEditor(); diff --git a/Telegram/SourceFiles/window/window_history_hider.cpp b/Telegram/SourceFiles/window/window_history_hider.cpp index 677e781cba..583541e42f 100644 --- a/Telegram/SourceFiles/window/window_history_hider.cpp +++ b/Telegram/SourceFiles/window/window_history_hider.cpp @@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "facades.h" #include "app.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_history.h" namespace Window { diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index 96109def0f..8f3af9398e 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -19,12 +19,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/wrap/vertical_layout.h" #include "ui/toast/toast.h" -#include "styles/style_boxes.h" #include "window/window_controller.h" #include "window/window_slide_animation.h" #include "window/window_session_controller.h" #include "main/main_account.h" #include "facades.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" namespace Window { diff --git a/Telegram/SourceFiles/window/window_lock_widgets.h b/Telegram/SourceFiles/window/window_lock_widgets.h index 9795e9fd24..9e6d834005 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.h +++ b/Telegram/SourceFiles/window/window_lock_widgets.h @@ -86,7 +86,7 @@ struct TermsLock { }; -class TermsBox : public BoxContent { +class TermsBox : public Ui::BoxContent { public: TermsBox( QWidget*, diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 9638ee822a..1e5b6bb94c 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -126,7 +126,7 @@ void MainMenu::ResetScaleButton::paintEvent(QPaintEvent *e) { MainMenu::MainMenu( QWidget *parent, not_null controller) -: RpWidget(parent) +: LayerWidget(parent) , _controller(controller) , _menu(this, st::mainMenu) , _telegram(this, st::mainMenuTelegramLabel) @@ -196,7 +196,7 @@ MainMenu::MainMenu( } }); - resize(st::mainMenuWidth, parentWidget()->height()); + parentResized(); _menu->setTriggeredCallback([](QAction *action, int actionTop, Ui::Menu::TriggeredSource source) { emit action->triggered(); }); @@ -237,6 +237,10 @@ MainMenu::MainMenu( initResetScaleButton(); } +void MainMenu::parentResized() { + resize(st::mainMenuWidth, parentWidget()->height()); +} + void MainMenu::refreshMenu() { _menu->clearActions(); if (!_controller->session().supportMode()) { diff --git a/Telegram/SourceFiles/window/window_main_menu.h b/Telegram/SourceFiles/window/window_main_menu.h index 44f43dcbf8..cd6406ed7a 100644 --- a/Telegram/SourceFiles/window/window_main_menu.h +++ b/Telegram/SourceFiles/window/window_main_menu.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "base/object_ptr.h" #include "ui/rp_widget.h" +#include "ui/layers/layer_widget.h" namespace Ui { class IconButton; @@ -23,18 +24,20 @@ namespace Window { class SessionController; -class MainMenu : public Ui::RpWidget, private base::Subscriber { +class MainMenu : public Ui::LayerWidget, private base::Subscriber { public: MainMenu(QWidget *parent, not_null controller); - void setInnerFocus() { - setFocus(); - } + void parentResized() override; protected: void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; + void doSetInnerFocus() override { + setFocus(); + } + private: void updateControlsGeometry(); void updatePhone(); diff --git a/Telegram/SourceFiles/window/window_media_preview.cpp b/Telegram/SourceFiles/window/window_media_preview.cpp index 9270d61e08..c2affbe9e9 100644 --- a/Telegram/SourceFiles/window/window_media_preview.cpp +++ b/Telegram/SourceFiles/window/window_media_preview.cpp @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "chat_helpers/stickers.h" #include "window/window_session_controller.h" -#include "styles/style_boxes.h" +#include "styles/style_layers.h" #include "styles/style_chat_helpers.h" #include "styles/style_history.h" diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index ac4ece8497..90e8ff9068 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/mute_settings_box.h" #include "boxes/add_contact_box.h" #include "boxes/report_box.h" -#include "boxes/generic_box.h" #include "boxes/create_poll_box.h" #include "boxes/peers/add_participants_box.h" #include "boxes/peers/edit_contact_box.h" @@ -20,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_utilities.h" #include "ui/widgets/labels.h" #include "ui/widgets/checkbox.h" +#include "ui/layers/generic_box.h" #include "main/main_session.h" #include "apiwrap.h" #include "mainwidget.h" @@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_key.h" #include "boxes/peers/edit_peer_info_box.h" #include "facades.h" +#include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_window.h" // st::windowMinWidth @@ -669,7 +670,7 @@ void PeerMenuShareContactBox( if (!peer->canWrite()) { Ui::show(Box( tr::lng_forward_share_cant(tr::now)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } else if (peer->isSelf()) { auto action = Api::SendAction(peer->owner().history(peer)); @@ -693,7 +694,7 @@ void PeerMenuShareContactBox( auto action = Api::SendAction(history); action.clearDraft = false; user->session().api().shareContact(user, action); - }), LayerOption::KeepOther); + }), Ui::LayerOption::KeepOther); }; *weak = Ui::show(Box( std::make_unique( @@ -736,7 +737,7 @@ void PeerMenuCreatePoll(not_null peer) { } void PeerMenuBlockUserBox( - not_null box, + not_null box, not_null window, not_null user, bool suggestClearChat) { @@ -859,7 +860,7 @@ QPointer ShowForwardMessagesBox( std::make_unique( navigation, std::move(callback)), - std::move(initBox)), LayerOption::KeepOther); + std::move(initBox)), Ui::LayerOption::KeepOther); return weak->data(); } @@ -885,7 +886,7 @@ QPointer ShowSendNowMessagesBox( Ui::Toast::Show(config); return { nullptr }; } - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); auto done = [ =, list = std::move(items), @@ -915,7 +916,7 @@ QPointer ShowSendNowMessagesBox( }; *box = Ui::show( Box(text, tr::lng_send_button(tr::now), std::move(done)), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return box->data(); } @@ -926,7 +927,7 @@ void PeerMenuAddChannelMembers( && channel->membersCount() >= Global::ChatSizeMax()) { Ui::show( Box(channel), - LayerOption::KeepOther); + Ui::LayerOption::KeepOther); return; } const auto api = &channel->session().api(); @@ -1008,13 +1009,17 @@ void ToggleHistoryArchived(not_null history, bool archived) { Fn ClearHistoryHandler(not_null peer) { return [=] { - Ui::show(Box(peer, true), LayerOption::KeepOther); + Ui::show( + Box(peer, true), + Ui::LayerOption::KeepOther); }; } Fn DeleteAndLeaveHandler(not_null peer) { return [=] { - Ui::show(Box(peer, false), LayerOption::KeepOther); + Ui::show( + Box(peer, false), + Ui::LayerOption::KeepOther); }; } diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index ffb99ace08..0d893ff07d 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -7,11 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -class GenericBox; class History; namespace Ui { class RpWidget; +class GenericBox; } // namespace Ui namespace Data { @@ -60,7 +60,7 @@ void PeerMenuAddChannelMembers( //void PeerMenuUngroupFeed(not_null feed); // #feed void PeerMenuCreatePoll(not_null peer); void PeerMenuBlockUserBox( - not_null box, + not_null box, not_null window, not_null user, bool suggestClearChat); diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 14146faa15..34ee9a7add 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -660,7 +660,7 @@ void SessionController::showBackFromStack(const SectionShow ¶ms) { } void SessionController::showSpecialLayer( - object_ptr &&layer, + object_ptr &&layer, anim::type animated) { App::wnd()->showSpecialLayer(std::move(layer), animated); } diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 41790c8e79..2673dacecb 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -47,9 +47,12 @@ struct FormRequest; class FormController; } // namespace Passport +namespace Ui { +class LayerWidget; +} // namespace Ui + namespace Window { -class LayerWidget; class MainWindow; class SectionMemento; class Controller; @@ -244,7 +247,7 @@ public: } void showSpecialLayer( - object_ptr &&layer, + object_ptr &&layer, anim::type animated = anim::type::normal); void hideSpecialLayer( anim::type animated = anim::type::normal) { diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index 4dedbfc4c3..3ee5fbd0b0 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -36,6 +36,7 @@ 'dependent_style_files': [ '<(submodules_loc)/lib_ui/ui/colors.palette', '<(submodules_loc)/lib_ui/ui/basic.style', + '<(submodules_loc)/lib_ui/ui/layers/layers.style', '<(submodules_loc)/lib_ui/ui/widgets/widgets.style', ], 'style_timestamp': '<(SHARED_INTERMEDIATE_DIR)/update_dependent_styles.timestamp', diff --git a/Telegram/gyp/telegram/sources.txt b/Telegram/gyp/telegram/sources.txt index 5780b9171f..1a7fecd2ba 100644 --- a/Telegram/gyp/telegram/sources.txt +++ b/Telegram/gyp/telegram/sources.txt @@ -58,8 +58,6 @@ <(src_loc)/boxes/edit_color_box.h <(src_loc)/boxes/edit_privacy_box.cpp <(src_loc)/boxes/edit_privacy_box.h -<(src_loc)/boxes/generic_box.cpp -<(src_loc)/boxes/generic_box.h <(src_loc)/boxes/language_box.cpp <(src_loc)/boxes/language_box.h <(src_loc)/boxes/local_storage_box.cpp @@ -728,8 +726,6 @@ <(src_loc)/support/support_helper.h <(src_loc)/support/support_templates.cpp <(src_loc)/support/support_templates.h -<(src_loc)/ui/effects/radial_animation.cpp -<(src_loc)/ui/effects/radial_animation.h <(src_loc)/ui/effects/round_checkbox.cpp <(src_loc)/ui/effects/round_checkbox.h <(src_loc)/ui/effects/send_action_animations.cpp @@ -775,8 +771,6 @@ <(src_loc)/ui/text_options.h <(src_loc)/ui/unread_badge.cpp <(src_loc)/ui/unread_badge.h -<(src_loc)/window/layer_widget.cpp -<(src_loc)/window/layer_widget.h <(src_loc)/window/main_window.cpp <(src_loc)/window/main_window.h <(src_loc)/window/notifications_manager.cpp diff --git a/Telegram/lib_base b/Telegram/lib_base index c1b1450dc1..ec7852a1cc 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit c1b1450dc165bcdea96a99e3341ac29539022511 +Subproject commit ec7852a1cc36c45550074cd98f292f61f056ecf2 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 946c33ef25..f4904e5ec4 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 946c33ef251ea5a46340e72ae903487576baf9b4 +Subproject commit f4904e5ec4f6596c445fbec295cedcdb69dd90b7