From 6b5e06de50296f62afc8e7045d2bf6d7ded284c9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 20 Oct 2017 20:54:51 +0300 Subject: [PATCH] Removed collapsing of shared media. --- Telegram/Resources/icons/info_media_file.png | Bin 0 -> 225 bytes .../Resources/icons/info_media_file@2x.png | Bin 0 -> 424 bytes Telegram/Resources/icons/info_media_video.png | Bin 0 -> 234 bytes .../Resources/icons/info_media_video@2x.png | Bin 0 -> 458 bytes Telegram/Resources/langs/lang.strings | 14 +++ Telegram/SourceFiles/info/info.style | 2 + .../SourceFiles/info/info_content_widget.h | 2 + .../info/info_top_bar_override.cpp | 14 +-- .../SourceFiles/info/info_wrap_widget.cpp | 1 + .../profile/info_profile_inner_widget.cpp | 100 ++++++++++++------ .../info/profile/info_profile_inner_widget.h | 11 +- .../info/profile/info_profile_widget.cpp | 4 + .../info/profile/info_profile_widget.h | 1 + 13 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 Telegram/Resources/icons/info_media_file.png create mode 100644 Telegram/Resources/icons/info_media_file@2x.png create mode 100644 Telegram/Resources/icons/info_media_video.png create mode 100644 Telegram/Resources/icons/info_media_video@2x.png diff --git a/Telegram/Resources/icons/info_media_file.png b/Telegram/Resources/icons/info_media_file.png new file mode 100644 index 0000000000000000000000000000000000000000..b8840c6ebf2649a6752d5df2962d317ae0cd902d GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ6`n4RArY-_uLW`)R^VZKaQ~w8 zQ;}ySazR4*6K!*v4Oa!LZ|480sBq(zyT&bs0~-vt&z)_3fblx}5eY>lgU#=h7A3Y^ z^>WEka|wz4yyVs7^*>U6 z_naox^1bqW#q?;dQ`7HRu9s~UeE4H${d&1gF6CnPjOpzfvN9bWFAmi#WW7+qu!TX2 zzd_95G2;cM3>$_hhF*3D?gbwiG8j$TnS3t0obg#IA~f-`yVuJ#wRWy1$}I|(>6yM> zo=?9Yy5O7g?AdJdt_8CrybQT7STyB5nx`yO{j73Z&xLpfrA<8-(iskO{ADxfx=_y0 z%<-2!L*}6^lS$79JH~mgJA4}UD`i}ldnX$AblWri!v-08i}ziNd|kgf%`|QQ&S^g? zfo?hbl)2<1&jp(U=c@c-{_%YPxk`>fx8WG`0(7Te`OlWU)}-(8lnKIPA*(@J6!3E&epKcz1O2!XR5Xoyzq#t n)%m9x^H28yW>CN_{ll=fi@7`dl~*A!1{geD{an^LB{Ts5sX(zl literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/info_media_video.png b/Telegram/Resources/icons/info_media_video.png new file mode 100644 index 0000000000000000000000000000000000000000..e252c92f97fd89186084ba5a451064d29d0dd5d3 GIT binary patch literal 234 zcmVX3EfG0*q?7;vwbp6IOY;e>lZ~hAHQeBHJ-~bTtpNM*Qp)`R z`*5Sr^#B@f@p111ME`aL?vIej`5Wq3A;uVM04uGy_kQsBsueRcdhh1&)*6`Ed}69i kDZI+P4+KB}1b{oh6Hqb&-y5W7jQ{`u07*qoM6N<$f)h($u>b%7 literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/info_media_video@2x.png b/Telegram/Resources/icons/info_media_video@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..20295c958ff485d6be4e52d99242718dc3b4ed5a GIT binary patch literal 458 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEV4Udb;uumf=k3g!y@wS7-RN^h+2_lo(_g zdN~}}9h8|aFka|jz%I0$C1b6q;7WleFU?e0MHW{Vuk5+IUu$(5_ZXh6p1g zH96|+`AmYbadmASWuI;2`k#N_y>54$1II%%#>*zMdiKRT8+fGCBL9c}%wkzHb-mMp zu%C}u-%QnyIxz9mQLYH>_j9!4fnq+D_o9K67V96~`O5yr(H5u9%k4MuJv{SVT>Z(S z{r{g$Je^p=pm%QPo9wzPh6$B2Cnh}K%Np|Ed_~Apb*In2L+5i9tBB}6=x70&?zzJ0 zz_gartW(N@r_`!h@GzI3%KWwO{+}8d_p969el``Hd#gS5OjPylX2I;-Z}V?-ADo}k zMdiW createMemento() = 0; virtual rpl::producer
sectionRequest() const; + virtual void setIsStackBottom(bool isStackBottom) { + } virtual Section section() const = 0; not_null peer() const { diff --git a/Telegram/SourceFiles/info/info_top_bar_override.cpp b/Telegram/SourceFiles/info/info_top_bar_override.cpp index 148586e187..7cd1518663 100644 --- a/Telegram/SourceFiles/info/info_top_bar_override.cpp +++ b/Telegram/SourceFiles/info/info_top_bar_override.cpp @@ -77,13 +77,13 @@ QString TopBarOverride::generateText() const { using Type = Storage::SharedMediaType; auto phrase = [&] { switch (_items.type) { - case Type::Photo: return lng_profile_photos; - case Type::Video: return lng_profile_videos; - case Type::File: return lng_profile_files; - case Type::MusicFile: return lng_profile_songs; - case Type::Link: return lng_profile_shared_links; - case Type::VoiceFile: return lng_profile_audios; - case Type::RoundFile: return lng_profile_rounds; + case Type::Photo: return lng_media_selected_photo; + case Type::Video: return lng_media_selected_video; + case Type::File: return lng_media_selected_file; + case Type::MusicFile: return lng_media_selected_song; + case Type::Link: return lng_media_selected_link; + case Type::VoiceFile: return lng_media_selected_audio; + case Type::RoundFile: return lng_media_selected_round; } Unexpected("Type in TopBarOverride::generateText()"); }(); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 2800328ccb..d3762efd51 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -300,6 +300,7 @@ void WrapWidget::showContent(object_ptr content) { } void WrapWidget::finishShowContent() { + _content->setIsStackBottom(_historyStack.empty()); updateContentGeometry(); _desiredHeights.fire(desiredHeightForContent()); _desiredShadowVisibilities.fire(_content->desiredShadowVisibility()); diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index b9010a5abe..ed0f784709 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "info/profile/info_profile_inner_widget.h" #include +#include #include #include "info/info_memento.h" #include "info/profile/info_profile_button.h" @@ -100,7 +101,7 @@ object_ptr InnerWidget::setupContent( } else { result->add(std::move(details)); } - result->add(setupSharedMedia(result)); + result->add(setupSharedMedia(result, rpl::duplicate(wrapValue))); result->add(object_ptr(result)); if (auto user = _peer->asUser()) { result->add(setupUserActions(result, user)); @@ -264,66 +265,100 @@ void InnerWidget::setupUserButtons( } object_ptr InnerWidget::setupSharedMedia( - RpWidget *parent) { + RpWidget *parent, + rpl::producer &&wrapValue) { using namespace rpl::mappers; using MediaType = Media::Type; auto content = object_ptr(parent); auto tracker = Ui::MultiSlideTracker(); - auto addMediaButton = [&](MediaType type) { - return Media::AddButton( + auto addMediaButton = [&]( + MediaType type, + const style::icon &icon) { + auto result = Media::AddButton( content, _controller, peer(), type, tracker); + object_ptr( + result, + icon, + st::infoSharedMediaButtonIconPosition); }; - auto addCommonGroupsButton = [&](not_null user) { - return Media::AddCommonGroupsButton( + auto addCommonGroupsButton = [&]( + not_null user, + const style::icon &icon) { + auto result = Media::AddCommonGroupsButton( content, _controller, user, tracker); + object_ptr( + result, + icon, + st::infoSharedMediaButtonIconPosition); }; - addMediaButton(MediaType::Photo); - addMediaButton(MediaType::Video); - addMediaButton(MediaType::File); - addMediaButton(MediaType::MusicFile); - addMediaButton(MediaType::Link); - if (auto user = _peer->asUser()) { - addCommonGroupsButton(user); + addMediaButton(MediaType::Photo, st::infoIconMediaPhoto); + addMediaButton(MediaType::Video, st::infoIconMediaVideo); + addMediaButton(MediaType::File, st::infoIconMediaFile); + addMediaButton(MediaType::MusicFile, st::infoIconMediaAudio); + addMediaButton(MediaType::Link, st::infoIconMediaLink); + if (auto user = peer()->asUser()) { + addCommonGroupsButton(user, st::infoIconMediaGroup); } - addMediaButton(MediaType::VoiceFile); -// addMediaButton(MediaType::RoundFile); + addMediaButton(MediaType::VoiceFile, st::infoIconMediaVoice); +// addMediaButton(MediaType::RoundFile, st::infoIconMediaRound); auto result = object_ptr>( parent, object_ptr(parent) ); - result->toggleOn(tracker.atLeastOneShownValue()); + + //result->toggleOn(rpl::combine( + // tracker.atLeastOneShownValue(), + // std::move(wrapValue), + // _isStackBottom.events(), + // $1 && ($2 != Wrap::Side || !$3))); + + using ToggledData = std::tuple; + rpl::combine( + tracker.atLeastOneShownValue(), + std::move(wrapValue), + _isStackBottom.events()) + | rpl::combine_previous(ToggledData()) + | rpl::start_with_next([wrap = result.data()]( + const ToggledData &was, + const ToggledData &now) { + bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom; + Wrap wasWrap, nowWrap; + std::tie(wasOneShown, wasWrap, wasStackBottom) = was; + std::tie(nowOneShown, nowWrap, nowStackBottom) = now; + // MSVC Internal Compiler Error + //auto [wasOneShown, wasWrap, wasStackBottom] = was; + //auto [nowOneShown, nowWrap, nowStackBottom] = now; + wrap->toggle( + nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom), + (wasOneShown == nowOneShown && wasWrap == nowWrap) + ? anim::type::normal + : anim::type::instant); + }, result->lifetime()); + auto layout = result->entity(); layout->add(object_ptr(layout)); - _sharedMediaCover = layout->add( - object_ptr(layout)); - if (canHideDetailsEver()) { - _sharedMediaCover->setToggleShown(canHideDetails()); - _sharedMediaWrap = layout->add(object_ptr>( - layout, - std::move(content)) - )->toggleOn(_sharedMediaCover->toggledValue()); - } else { - layout->add(std::move(content)); - } layout->add(object_ptr( layout, st::infoSharedMediaBottomSkip) )->setAttribute(Qt::WA_TransparentForMouseEvents); - object_ptr( - result, - st::infoIconMediaPhoto, - st::infoSharedMediaIconPosition); + layout->add(std::move(content)); + layout->add(object_ptr( + layout, + st::infoSharedMediaBottomSkip) + )->setAttribute(Qt::WA_TransparentForMouseEvents); + + _sharedMediaWrap = result; return std::move(result); } @@ -477,7 +512,7 @@ void InnerWidget::visibleTopBottomUpdated( void InnerWidget::saveState(not_null memento) { memento->setInfoExpanded(_cover->toggled()); - memento->setMediaExpanded(_sharedMediaCover->toggled()); + memento->setMediaExpanded(true); } void InnerWidget::restoreState(not_null memento) { @@ -485,7 +520,6 @@ void InnerWidget::restoreState(not_null memento) { if (_infoWrap) { _infoWrap->finishAnimating(); } - _sharedMediaCover->toggle(memento->mediaExpanded()); if (_sharedMediaWrap) { _sharedMediaWrap->finishAnimating(); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h index b7b600d6c6..371c26ac15 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h @@ -43,7 +43,6 @@ namespace Profile { class Memento; class Members; class Cover; -class SharedMediaCover; class InnerWidget final : public Ui::RpWidget { public: @@ -60,6 +59,9 @@ public: void saveState(not_null memento); void restoreState(not_null memento); + void setIsStackBottom(bool isStackBottom) { + _isStackBottom.fire_copy(isStackBottom); + } rpl::producer scrollToRequests() const { return _scrollToRequests.events(); } @@ -79,7 +81,9 @@ private: RpWidget *parent, rpl::producer &&wrapValue); object_ptr setupDetails(RpWidget *parent) const; - object_ptr setupSharedMedia(RpWidget *parent); + object_ptr setupSharedMedia( + RpWidget *parent, + rpl::producer &&wrapValue); object_ptr setupMuteToggle(RpWidget *parent) const; object_ptr setupInfo(RpWidget *parent) const; void setupUserButtons( @@ -99,13 +103,14 @@ private: bool canHideDetailsEver() const; rpl::producer canHideDetails() const; + rpl::event_stream _isStackBottom; + not_null _controller; not_null _peer; Members *_members = nullptr; Cover *_cover = nullptr; Ui::SlideWrap *_infoWrap = nullptr; - SharedMediaCover *_sharedMediaCover = nullptr; Ui::SlideWrap *_sharedMediaWrap = nullptr; object_ptr _content; diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp index 2247f8b612..28b8b89d44 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp @@ -63,6 +63,10 @@ Widget::Widget( }, lifetime()); } +void Widget::setIsStackBottom(bool isStackBottom) { + _inner->setIsStackBottom(isStackBottom); +} + Section Widget::section() const { return Section(Section::Type::Profile); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.h b/Telegram/SourceFiles/info/profile/info_profile_widget.h index a46d2c1285..002ad92f61 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.h @@ -70,6 +70,7 @@ public: not_null controller, not_null peer); + void setIsStackBottom(bool isStackBottom) override; Section section() const override; bool showInternal(