From d1687ab9630e3e9c55a07403828963cd731da9c3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 30 Sep 2017 21:26:45 +0300 Subject: [PATCH] Improve info wrapping in section / layer. Also move layerwidget to window/layer_widget. Also replace ui/effects/widget_fade_wrap with ui/wrap/fade_wrap. --- Telegram/Resources/basic.style | 1 + Telegram/SourceFiles/auth_session.h | 4 +- Telegram/SourceFiles/boxes/abstract_box.cpp | 10 +- Telegram/SourceFiles/boxes/abstract_box.h | 28 +- Telegram/SourceFiles/boxes/add_contact_box.h | 1 + Telegram/SourceFiles/boxes/boxes.style | 1 - .../SourceFiles/boxes/change_phone_box.cpp | 36 +- Telegram/SourceFiles/boxes/peer_list_box.h | 1 + Telegram/SourceFiles/boxes/stickers_box.cpp | 1 + Telegram/SourceFiles/boxes/stickers_box.h | 4 +- Telegram/SourceFiles/calls/calls_panel.cpp | 13 +- Telegram/SourceFiles/calls/calls_panel.h | 6 +- .../chat_helpers/tabbed_selector.cpp | 11 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 10 +- Telegram/SourceFiles/dialogs/dialogs_widget.h | 6 +- Telegram/SourceFiles/facades.cpp | 2 +- Telegram/SourceFiles/facades.h | 3 + .../history/history_admin_log_section.cpp | 2 +- .../SourceFiles/history/history_drag_area.cpp | 1 + .../SourceFiles/history/history_widget.cpp | 8 +- Telegram/SourceFiles/info/info.style | 27 +- .../info/info_common_groups_widget.h | 2 +- .../SourceFiles/info/info_content_widget.cpp | 157 +++++++++ .../SourceFiles/info/info_content_widget.h | 150 ++++++++ ...o_layer_wrap.cpp => info_layer_widget.cpp} | 98 ++---- ...{info_layer_wrap.h => info_layer_widget.h} | 18 +- Telegram/SourceFiles/info/info_memento.cpp | 266 +++------------ Telegram/SourceFiles/info/info_memento.h | 185 +--------- .../SourceFiles/info/info_narrow_wrap.cpp | 208 ------------ .../SourceFiles/info/info_section_widget.cpp | 111 ++++++ ...fo_narrow_wrap.h => info_section_widget.h} | 59 +--- Telegram/SourceFiles/info/info_side_wrap.cpp | 270 --------------- Telegram/SourceFiles/info/info_top_bar.cpp | 55 ++- Telegram/SourceFiles/info/info_top_bar.h | 7 +- .../SourceFiles/info/info_wrap_widget.cpp | 319 ++++++++++++++++++ .../{info_side_wrap.h => info_wrap_widget.h} | 114 +++++-- .../{ => media}/info_media_inner_widget.cpp | 2 +- .../{ => media}/info_media_inner_widget.h | 2 +- .../info/{ => media}/info_media_widget.cpp | 4 +- .../info/{ => media}/info_media_widget.h | 2 +- .../profile/info_profile_inner_widget.cpp | 3 +- .../info/profile/info_profile_members.cpp | 2 +- .../info/profile/info_profile_widget.h | 6 +- Telegram/SourceFiles/intro/introphone.cpp | 4 +- Telegram/SourceFiles/intro/introphone.h | 2 +- Telegram/SourceFiles/intro/introwidget.cpp | 47 ++- Telegram/SourceFiles/intro/introwidget.h | 16 +- Telegram/SourceFiles/mainwidget.cpp | 14 +- Telegram/SourceFiles/mainwindow.cpp | 12 +- Telegram/SourceFiles/mainwindow.h | 10 +- .../media/player/media_player_widget.cpp | 2 +- .../media/view/media_clip_controller.cpp | 2 +- Telegram/SourceFiles/overviewwidget.cpp | 3 +- .../profile/profile_common_groups_section.cpp | 2 +- .../SourceFiles/profile/profile_widget.cpp | 8 +- Telegram/SourceFiles/profile/profile_widget.h | 6 +- .../SourceFiles/settings/settings_layer.cpp | 6 +- .../SourceFiles/settings/settings_layer.h | 11 +- .../SourceFiles/settings/settings_widget.cpp | 1 - .../storage/storage_shared_media.h | 3 +- .../SourceFiles/storage/storage_user_photos.h | 3 +- ...idget_fade_wrap.cpp => fade_animation.cpp} | 41 +-- .../SourceFiles/ui/effects/fade_animation.h | 78 +++++ .../SourceFiles/ui/effects/widget_fade_wrap.h | 203 ----------- Telegram/SourceFiles/ui/twidget.h | 3 +- Telegram/SourceFiles/ui/widgets/buttons.cpp | 7 +- Telegram/SourceFiles/ui/widgets/shadow.cpp | 17 + Telegram/SourceFiles/ui/widgets/shadow.h | 16 +- Telegram/SourceFiles/ui/wrap/fade_wrap.cpp | 98 ++++++ Telegram/SourceFiles/ui/wrap/fade_wrap.h | 152 +++++++++ Telegram/SourceFiles/ui/wrap/padding_wrap.cpp | 2 +- Telegram/SourceFiles/ui/wrap/padding_wrap.h | 4 +- Telegram/SourceFiles/ui/wrap/slide_wrap.cpp | 16 +- Telegram/SourceFiles/ui/wrap/slide_wrap.h | 12 +- Telegram/SourceFiles/ui/wrap/wrap.h | 6 +- .../layer_widget.cpp} | 13 +- .../{layerwidget.h => window/layer_widget.h} | 12 +- Telegram/SourceFiles/window/section_memento.h | 10 +- Telegram/SourceFiles/window/section_widget.h | 3 +- .../window/themes/window_theme_editor.h | 7 +- .../themes/window_theme_editor_block.cpp | 1 + .../SourceFiles/window/top_bar_widget.cpp | 7 +- .../SourceFiles/window/window_controller.cpp | 9 +- Telegram/gyp/telegram_sources.txt | 36 +- 84 files changed, 1631 insertions(+), 1490 deletions(-) create mode 100644 Telegram/SourceFiles/info/info_content_widget.cpp create mode 100644 Telegram/SourceFiles/info/info_content_widget.h rename Telegram/SourceFiles/info/{info_layer_wrap.cpp => info_layer_widget.cpp} (65%) rename Telegram/SourceFiles/info/{info_layer_wrap.h => info_layer_widget.h} (83%) delete mode 100644 Telegram/SourceFiles/info/info_narrow_wrap.cpp create mode 100644 Telegram/SourceFiles/info/info_section_widget.cpp rename Telegram/SourceFiles/info/{info_narrow_wrap.h => info_section_widget.h} (59%) delete mode 100644 Telegram/SourceFiles/info/info_side_wrap.cpp create mode 100644 Telegram/SourceFiles/info/info_wrap_widget.cpp rename Telegram/SourceFiles/info/{info_side_wrap.h => info_wrap_widget.h} (53%) rename Telegram/SourceFiles/info/{ => media}/info_media_inner_widget.cpp (96%) rename Telegram/SourceFiles/info/{ => media}/info_media_inner_widget.h (97%) rename Telegram/SourceFiles/info/{ => media}/info_media_widget.cpp (96%) rename Telegram/SourceFiles/info/{ => media}/info_media_widget.h (98%) rename Telegram/SourceFiles/ui/effects/{widget_fade_wrap.cpp => fade_animation.cpp} (77%) create mode 100644 Telegram/SourceFiles/ui/effects/fade_animation.h delete mode 100644 Telegram/SourceFiles/ui/effects/widget_fade_wrap.h create mode 100644 Telegram/SourceFiles/ui/wrap/fade_wrap.cpp create mode 100644 Telegram/SourceFiles/ui/wrap/fade_wrap.h rename Telegram/SourceFiles/{layerwidget.cpp => window/layer_widget.cpp} (99%) rename Telegram/SourceFiles/{layerwidget.h => window/layer_widget.h} (96%) diff --git a/Telegram/Resources/basic.style b/Telegram/Resources/basic.style index 0724ccd9a..9bcfcb0c6 100644 --- a/Telegram/Resources/basic.style +++ b/Telegram/Resources/basic.style @@ -79,6 +79,7 @@ slideShift: 100px; slideShadow: icon {{ "slide_shadow", slideFadeOutShadowFg }}; slideWrapDuration: 150; +fadeWrapDuration: 200; linkCropLimit: 360px; linkFont: normalFont; diff --git a/Telegram/SourceFiles/auth_session.h b/Telegram/SourceFiles/auth_session.h index e6228a536..39236e8c6 100644 --- a/Telegram/SourceFiles/auth_session.h +++ b/Telegram/SourceFiles/auth_session.h @@ -240,7 +240,7 @@ public: AuthSessionData &data() { return _data; } - void saveDataDelayed(TimeMs delay); + void saveDataDelayed(TimeMs delay = kDefaultSaveDelay); ApiWrap &api() { return *_api; @@ -259,6 +259,8 @@ public: ~AuthSession(); private: + static constexpr auto kDefaultSaveDelay = TimeMs(1000); + const UserId _userId = 0; AuthSessionData _data; base::Timer _saveDataTimer; diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index e90ce2ee6..16918e381 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -24,10 +24,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "styles/style_profile.h" #include "storage/localstorage.h" #include "lang/lang_keys.h" -#include "ui/effects/widget_fade_wrap.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 "mainwidget.h" #include "mainwindow.h" @@ -53,8 +54,8 @@ void BoxContent::setInner(object_ptr inner, const style::ScrollArea &st _topShadow->raise(); _bottomShadow->raise(); } else { - _topShadow.create(this, object_ptr(this)); - _bottomShadow.create(this, object_ptr(this)); + _topShadow.create(this); + _bottomShadow.create(this); } if (!_preparing) { // We didn't set dimensions yet, this will be called from finishPrepare(); @@ -421,9 +422,6 @@ void AbstractBox::keyPressEvent(QKeyEvent *e) { } } -BoxLayerTitleShadow::BoxLayerTitleShadow(QWidget *parent) : Ui::PlainShadow(parent, st::boxLayerTitleShadow) { -} - BoxContentDivider::BoxContentDivider(QWidget *parent) : RpWidget(parent) { } diff --git a/Telegram/SourceFiles/boxes/abstract_box.h b/Telegram/SourceFiles/boxes/abstract_box.h index 3ea435e8d..07d0fb7c3 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.h +++ b/Telegram/SourceFiles/boxes/abstract_box.h @@ -20,25 +20,26 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once -#include "layerwidget.h" +#include "window/layer_widget.h" #include "ui/rp_widget.h" -#include "ui/widgets/shadow.h" + +namespace style { +struct RoundButton; +struct ScrollArea; +} // namespace style namespace Ui { class RoundButton; class IconButton; class ScrollArea; class FlatLabel; -template -class WidgetFadeWrap; +class FadeShadow; } // namespace Ui namespace Window { class Controller; } // namespace Window -class BoxLayerTitleShadow; - class BoxContentDelegate { public: virtual Window::Controller *controller() const = 0; @@ -194,15 +195,18 @@ private: bool _noContentMargin = false; int _innerTopSkip = 0; object_ptr _scroll = { nullptr }; - object_ptr> _topShadow = { nullptr }; - object_ptr> _bottomShadow = { nullptr }; + object_ptr _topShadow = { nullptr }; + object_ptr _bottomShadow = { nullptr }; object_ptr _draggingScrollTimer = { nullptr }; int _draggingScrollDelta = 0; }; -class AbstractBox : public LayerWidget, public BoxContentDelegate, protected base::Subscriber { +class AbstractBox + : public Window::LayerWidget + , public BoxContentDelegate + , protected base::Subscriber { public: AbstractBox(QWidget *parent, Window::Controller *controller, object_ptr content); @@ -284,12 +288,6 @@ private: }; -class BoxLayerTitleShadow : public Ui::PlainShadow { -public: - BoxLayerTitleShadow(QWidget *parent); - -}; - class BoxContentDivider : public Ui::RpWidget { public: BoxContentDivider(QWidget *parent); diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index c49e8f14f..b4f8f0ca3 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "boxes/abstract_box.h" #include "mtproto/sender.h" +#include "styles/style_widgets.h" class ConfirmBox; class PeerListBox; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index dde60abd4..2fef37d8e 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -88,7 +88,6 @@ boxLayerTitlePosition: point(23px, 16px); boxLayerTitleHeight: 56px; boxLayerTitleAdditionalSkip: 9px; boxLayerTitleAdditionalFont: normalFont; -boxLayerTitleShadow: shadowFg; boxLayerScroll: defaultSolidScroll; boxTopMargin: 6px; diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 60d79194a..3a97b8988 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -24,25 +24,37 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "styles/style_boxes.h" #include "ui/widgets/labels.h" #include "ui/widgets/input_fields.h" -#include "ui/effects/widget_fade_wrap.h" +#include "ui/wrap/fade_wrap.h" #include "boxes/confirm_phone_box.h" #include "ui/toast/toast.h" #include "boxes/confirm_box.h" namespace { -void createErrorLabel(QWidget *parent, object_ptr> &label, const QString &text, int x, int y) { +void createErrorLabel( + QWidget *parent, + object_ptr> &label, + const QString &text, + int x, + int y) { if (label) { - auto errorFadeOut = std::move(label); - errorFadeOut->setUpdateCallback([label = errorFadeOut.data()] { - if (label->isHidden() || !label->animating()) { - label->deleteLater(); - } - }); - errorFadeOut->hideAnimated(); + label->hideAnimated(); + auto context = label.data(); + App::CallDelayed( + st::fadeWrapDuration, + context, + [old = std::move(label)]() mutable { + old.destroy(); + }); } if (!text.isEmpty()) { - label.create(parent, object_ptr(parent, text, Ui::FlatLabel::InitType::Simple, st::changePhoneError)); + label.create( + parent, + object_ptr( + parent, + text, + Ui::FlatLabel::InitType::Simple, + st::changePhoneError)); label->hideFast(); label->moveToLeft(x, y); label->showAnimated(); @@ -73,7 +85,7 @@ private: } object_ptr _phone = { nullptr }; - object_ptr> _error = { nullptr }; + object_ptr> _error = { nullptr }; mtpRequestId _requestId = 0; }; @@ -105,7 +117,7 @@ private: int _codeLength = 0; int _callTimeout = 0; object_ptr _code = { nullptr }; - object_ptr> _error = { nullptr }; + object_ptr> _error = { nullptr }; object_ptr _callLabel = { nullptr }; mtpRequestId _requestId = 0; SentCodeCall _call; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 79e432677..397749c52 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -28,6 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace style { struct PeerList; +struct PeerListItem; } // namespace style namespace Ui { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index b35792391..ccb720251 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -34,6 +34,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" #include "ui/widgets/scroll_area.h" +#include "ui/widgets/shadow.h" #include "ui/effects/ripple_animation.h" #include "ui/effects/slide_animation.h" #include "ui/widgets/discrete_sliders.h" diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index 010517303..31685deea 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -126,7 +126,7 @@ private: ChannelData *_megagroupSet = nullptr; std::unique_ptr _slideAnimation; - object_ptr _titleShadow = { nullptr }; + object_ptr _titleShadow = { nullptr }; mtpRequestId _archivedRequestId = 0; bool _archivedLoaded = false; @@ -303,7 +303,7 @@ private: MTPInputStickerSet _megagroupSetInput = MTP_inputStickerSetEmpty(); std::unique_ptr _megagroupSelectedSet; object_ptr _megagroupSetField = { nullptr }; - object_ptr _megagroupSelectedShadow = { nullptr }; + object_ptr _megagroupSelectedShadow = { nullptr }; object_ptr _megagroupSelectedRemove = { nullptr }; object_ptr _megagroupDivider = { nullptr }; object_ptr _megagroupSubTitle = { nullptr }; diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 507ba7d03..d4fa8f6ee 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -28,7 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/labels.h" #include "ui/widgets/shadow.h" #include "ui/effects/ripple_animation.h" -#include "ui/effects/widget_fade_wrap.h" +#include "ui/wrap/fade_wrap.h" #include "messenger.h" #include "mainwindow.h" #include "lang/lang_keys.h" @@ -245,11 +245,14 @@ Panel::Panel(not_null call) : _call(call) , _user(call->user()) , _answerHangupRedial(this, st::callAnswer, &st::callHangup) -, _decline(this, object_ptr