From 903aa46e5c6f7c16fcfc6c11b465b5556bac74b4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 16 Nov 2017 13:13:17 +0400 Subject: [PATCH] Disable tabs in third column info. --- Telegram/SourceFiles/boxes/boxes.style | 2 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 4 + Telegram/SourceFiles/info/info.style | 5 +- Telegram/SourceFiles/info/info_top_bar.cpp | 23 +- Telegram/SourceFiles/info/info_top_bar.h | 4 + .../SourceFiles/info/info_wrap_widget.cpp | 450 ++++++++++-------- Telegram/SourceFiles/info/info_wrap_widget.h | 15 +- .../info/media/info_media_inner_widget.cpp | 374 ++++++++------- .../info/media/info_media_inner_widget.h | 27 +- .../profile/info_profile_inner_widget.cpp | 52 +- Telegram/SourceFiles/ui/widgets/widgets.style | 2 + 11 files changed, 540 insertions(+), 418 deletions(-) diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 0facbe3352..0b2bd626b0 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -394,7 +394,7 @@ notificationSampleSize: size(64px, 16px); membersAboutLimitPadding: margins(0px, 12px, 0px, 12px); membersAbout: FlatLabel(defaultFlatLabel) { - minWidth: 332px; + minWidth: 240px; textFg: membersAboutLimitFg; align: align(top); style: boxLabelStyle; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index dea2229352..d02f658911 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -883,15 +883,19 @@ int PeerListContent::resizeGetHeight(int newWidth) { } auto rowsCount = shownRowsCount(); auto labelTop = rowsTop() + qMax(1, shownRowsCount()) * _rowHeight; + auto labelWidth = newWidth - 2 * st::contactsPadding.left(); if (_description) { + _description->resizeToWidth(labelWidth); _description->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth); _description->setVisible(!showingSearch()); } if (_searchNoResults) { + _searchNoResults->resizeToWidth(labelWidth); _searchNoResults->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth); _searchNoResults->setVisible(showingSearch() && _filterResults.empty() && !_controller->isSearchLoading()); } if (_searchLoading) { + _searchLoading->resizeToWidth(labelWidth); _searchLoading->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth); _searchLoading->setVisible(showingSearch() && _filterResults.empty() && _controller->isSearchLoading()); } diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 42354fdc37..127b080dae 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -130,6 +130,7 @@ infoTopBarTitle: FlatLabel(defaultFlatLabel) { } } infoTopBarClose: IconButton(infoTopBarBack) { + width: infoTopBarHeight; icon: icon {{ "info_close", boxTitleCloseFg }}; iconOver: icon {{ "info_close", boxTitleCloseFgOver }}; } @@ -179,6 +180,8 @@ infoTopBar: InfoTopBar { mediaDelete: infoTopBarDelete; search: infoTopBarSearch; searchRow: infoTopBarSearchRow; + highlightBg: windowBgOver; + highlightDuration: 240; } infoLayerTopBarHeight: boxLayerTitleHeight; @@ -224,7 +227,7 @@ infoLayerTopBarDelete: IconButton(infoLayerTopBarForward) { icon: icon {{ "info_media_delete", boxTitleCloseFg }}; iconOver: icon {{ "info_media_delete", boxTitleCloseFgOver }}; } -infoLayerTopBar: InfoTopBar { +infoLayerTopBar: InfoTopBar(infoTopBar) { height: infoLayerTopBarHeight; back: infoLayerTopBarBack; title: boxTitle; diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index 8301a1b8b3..4576e3bd54 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -221,7 +221,28 @@ void TopBar::updateControlsGeometry(int newWidth) { void TopBar::paintEvent(QPaintEvent *e) { Painter p(this); - p.fillRect(e->rect(), _st.bg); + + auto ms = getms(); + auto highlight = _a_highlight.current(ms, _highlight ? 1. : 0.); + if (_highlight && !_a_highlight.animating()) { + _highlight = false; + startHighlightAnimation(); + } + auto brush = anim::brush(_st.bg, _st.highlightBg, highlight); + p.fillRect(e->rect(), brush); +} + +void TopBar::highlight() { + _highlight = true; + startHighlightAnimation(); +} + +void TopBar::startHighlightAnimation() { + _a_highlight.start( + [this] { update(); }, + _highlight ? 0. : 1., + _highlight ? 1. : 0., + _st.highlightDuration); } rpl::producer TitleValue( diff --git a/Telegram/SourceFiles/info/info_top_bar.h b/Telegram/SourceFiles/info/info_top_bar.h index 3ed3fb7240..24788d6ab3 100644 --- a/Telegram/SourceFiles/info/info_top_bar.h +++ b/Telegram/SourceFiles/info/info_top_bar.h @@ -51,6 +51,7 @@ public: void setTitle(rpl::producer &&title); void enableBackButton(bool enable); + void highlight(); template ButtonWidget *addButton(base::unique_qptr button) { @@ -71,6 +72,7 @@ private: void updateControlsGeometry(int newWidth); void pushButton(base::unique_qptr button); void removeButton(not_null button); + void startHighlightAnimation(); void setSearchField( base::unique_qptr field, @@ -80,6 +82,8 @@ private: rpl::producer &&shown); const style::InfoTopBar &_st; + Animation _a_highlight; + bool _highlight = false; object_ptr _back = { nullptr }; std::vector> _buttons; object_ptr _title = { nullptr }; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 251ce57b59..2c976412d3 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -119,133 +119,154 @@ not_null WrapWidget::peer() const { return _controller->peer(); } -void WrapWidget::createTabs() { - _topTabs.create(this, st::infoTabs); - auto sections = QStringList(); - sections.push_back(lang(lng_profile_info_section).toUpper()); - sections.push_back(lang(lng_info_tab_media).toUpper()); - _topTabs->setSections(sections); - _topTabs->setActiveSection(static_cast(_tab)); - _topTabs->finishAnimating(); - - _topTabs->sectionActivated() - | rpl::map([](int index) { return static_cast(index); }) - | rpl::start_with_next( - [this](Tab tab) { showTab(tab); }, - lifetime()); - - _topTabs->move(0, 0); - _topTabs->resizeToWidth(width()); - _topTabs->show(); - - _topTabsBackground.create(this, st::profileBg); - _topTabsBackground->setAttribute(Qt::WA_OpaquePaintEvent); - - _topTabsBackground->move(0, 0); - _topTabsBackground->resize( - width(), - _topTabs->height() - st::lineWidth); - _topTabsBackground->show(); -} +// This was done for tabs support. +// +//void WrapWidget::createTabs() { +// _topTabs.create(this, st::infoTabs); +// auto sections = QStringList(); +// sections.push_back(lang(lng_profile_info_section).toUpper()); +// sections.push_back(lang(lng_info_tab_media).toUpper()); +// _topTabs->setSections(sections); +// _topTabs->setActiveSection(static_cast(_tab)); +// _topTabs->finishAnimating(); +// +// _topTabs->sectionActivated() +// | rpl::map([](int index) { return static_cast(index); }) +// | rpl::start_with_next( +// [this](Tab tab) { showTab(tab); }, +// lifetime()); +// +// _topTabs->move(0, 0); +// _topTabs->resizeToWidth(width()); +// _topTabs->show(); +// +// _topTabsBackground.create(this, st::profileBg); +// _topTabsBackground->setAttribute(Qt::WA_OpaquePaintEvent); +// +// _topTabsBackground->move(0, 0); +// _topTabsBackground->resize( +// width(), +// _topTabs->height() - st::lineWidth); +// _topTabsBackground->show(); +//} void WrapWidget::forceContentRepaint() { // WA_OpaquePaintEvent on TopBar creates render glitches when // animating the LayerWidget's height :( Fixing by repainting. - if (_topTabs) { - _topTabsBackground->update(); - } else if (_topBar) { + + // This was done for tabs support. + // + //if (_topTabs) { + // _topTabsBackground->update(); + //} + + if (_topBar) { _topBar->update(); } _content->update(); } -void WrapWidget::showTab(Tab tab) { - if (_tab == tab) { - return; - } - Expects(_content != nullptr); - auto direction = (tab > _tab) - ? SlideDirection::FromRight - : SlideDirection::FromLeft; - auto newAnotherMemento = _content->createMemento(); - if (!_anotherTabMemento) { - _anotherTabMemento = createTabMemento(tab); - } - auto newController = createController( - _controller->window(), - _anotherTabMemento.get()); - auto newContent = createContent( - _anotherTabMemento.get(), - newController.get()); - auto animationParams = SectionSlideParams(); -// animationParams.withFade = (wrap() == Wrap::Layer); - animationParams.withTabs = true; - animationParams.withTopBarShadow = hasTopBarShadow() - && newContent->hasTopBarShadow(); - animationParams.oldContentCache = grabForShowAnimation( - animationParams); - - _controller = std::move(newController); - showContent(std::move(newContent)); - - showAnimated(direction, animationParams); - - _anotherTabMemento = std::move(newAnotherMemento); - _tab = tab; -} - -void WrapWidget::setupTabbedTop() { - auto section = _controller->section(); - switch (section.type()) { - case Section::Type::Profile: - setupTabs(Tab::Profile); - break; - case Section::Type::Media: - switch (section.mediaType()) { - case Section::MediaType::Photo: - case Section::MediaType::Video: - case Section::MediaType::File: - setupTabs(Tab::Media); - break; - default: - setupTabs(Tab::None); - break; - } - break; - case Section::Type::CommonGroups: - setupTabs(Tab::None); - break; - } -} +// This was done for tabs support. +// +//void WrapWidget::showTab(Tab tab) { +// if (_tab == tab) { +// return; +// } +// Expects(_content != nullptr); +// auto direction = (tab > _tab) +// ? SlideDirection::FromRight +// : SlideDirection::FromLeft; +// auto newAnotherMemento = _content->createMemento(); +// if (!_anotherTabMemento) { +// _anotherTabMemento = createTabMemento(tab); +// } +// auto newController = createController( +// _controller->window(), +// _anotherTabMemento.get()); +// auto newContent = createContent( +// _anotherTabMemento.get(), +// newController.get()); +// auto animationParams = SectionSlideParams(); +//// animationParams.withFade = (wrap() == Wrap::Layer); +// animationParams.withTabs = true; +// animationParams.withTopBarShadow = hasTopBarShadow() +// && newContent->hasTopBarShadow(); +// animationParams.oldContentCache = grabForShowAnimation( +// animationParams); +// +// _controller = std::move(newController); +// showContent(std::move(newContent)); +// +// showAnimated(direction, animationParams); +// +// _anotherTabMemento = std::move(newAnotherMemento); +// _tab = tab; +//} +// +//void WrapWidget::setupTabbedTop() { +// auto section = _controller->section(); +// switch (section.type()) { +// case Section::Type::Profile: +// setupTabs(Tab::Profile); +// break; +// case Section::Type::Media: +// switch (section.mediaType()) { +// case Section::MediaType::Photo: +// case Section::MediaType::Video: +// case Section::MediaType::File: +// setupTabs(Tab::Media); +// break; +// default: +// setupTabs(Tab::None); +// break; +// } +// break; +// case Section::Type::CommonGroups: +// setupTabs(Tab::None); +// break; +// } +//} void WrapWidget::setupTop() { - if (wrap() == Wrap::Side && _historyStack.empty()) { - setupTabbedTop(); - } else { - setupTabs(Tab::None); - } - if (_topTabs) { - _topBar.destroy(); - } else { - createTopBar(); - } + // This was done for tabs support. + // + //if (wrap() == Wrap::Side && _historyStack.empty()) { + // setupTabbedTop(); + //} else { + // setupTabs(Tab::None); + //} + //if (_topTabs) { + // _topBar.destroy(); + //} else { + // createTopBar(); + //} + createTopBar(); refreshTopBarOverride(); } void WrapWidget::createTopBar() { - _topBar.create(this, TopBarStyle(wrap())); + auto wrapValue = wrap(); + _topBar.create(this, TopBarStyle(wrapValue)); _topBar->setTitle(TitleValue( _controller->section(), _controller->peer())); - if (wrap() != Wrap::Layer || !_historyStack.empty()) { + if (wrapValue == Wrap::Narrow || hasStackHistory()) { _topBar->enableBackButton(true); _topBar->backRequest() | rpl::start_with_next([this] { showBackFromStack(); }, _topBar->lifetime()); + } else if (wrapValue == Wrap::Side) { + auto close = _topBar->addButton( + base::make_unique_q( + _topBar, + st::infoTopBarClose)); + close->addClickHandler([this] { + _controller->window()->closeThirdSection(); + }); } - if (wrap() == Wrap::Layer) { + if (wrapValue == Wrap::Layer) { auto close = _topBar->addButton( base::make_unique_q( _topBar, @@ -260,7 +281,8 @@ void WrapWidget::createTopBar() { search, _controller->searchEnabledByContent()); } - if (_controller->section().type() == Section::Type::Profile) { + if (_controller->section().type() == Section::Type::Profile + && (wrapValue != Wrap::Side || hasStackHistory())) { addProfileMenuButton(); // addProfileNotificationsButton(); } @@ -381,9 +403,14 @@ void WrapWidget::destroyTopBarOverride() { _topBarOverrideAnimation.start([this, handle] { }, 1., 0., st::slideWrapDuration); widget.destroy(); - if (_topTabs) { - _topTabs->show(); - } else if (_topBar) { + + // This was done for tabs support. + // + //if (_topTabs) { + // _topTabs->show(); + //} + + if (_topBar) { _topBar->show(); } } @@ -394,9 +421,14 @@ void WrapWidget::createTopBarOverride(SelectedItems &&items) { this, TopBarStyle(wrap()), std::move(items)); - if (_topTabs) { - _topTabs->hide(); - } else if (_topBar) { + + // This was done for tabs support. + // + //if (_topTabs) { + // _topTabs->hide(); + //} + + if (_topBar) { _topBar->hide(); } _topBarOverride->cancelRequests() @@ -416,9 +448,12 @@ bool WrapWidget::requireTopBarSearch() const { } else if (hasStackHistory()) { return true; } - auto section = _controller->section(); - return (section.type() != Section::Type::Media) - || !Media::TypeToTabIndex(section.mediaType()).has_value(); + // This was for top-level tabs support. + // + //auto section = _controller->section(); + //return (section.type() != Section::Type::Media) + // || !Media::TypeToTabIndex(section.mediaType()).has_value(); + return false; } void WrapWidget::showBackFromStack() { @@ -437,9 +472,11 @@ void WrapWidget::showBackFromStack() { } not_null WrapWidget::topWidget() const { - if (_topTabs) { - return _topTabsBackground; - } + // This was done for tabs support. + // + //if (_topTabs) { + // return _topTabsBackground; + //} return _topBar; } @@ -458,17 +495,25 @@ void WrapWidget::finishShowContent() { _selectedLists.fire(_content->selectedListValue()); _topShadow->raise(); _topShadow->finishAnimating(); - if (_topTabs) { - _topTabs->raise(); - } + + // This was done for tabs support. + // + //if (_topTabs) { + // _topTabs->raise(); + //} } rpl::producer WrapWidget::topShadowToggledValue() const { - using namespace rpl::mappers; - return rpl::combine( - _controller->wrapValue(), - _desiredShadowVisibilities.events() | rpl::flatten_latest(), - ($1 == Wrap::Side) || $2); + // Allows always showing shadow for specific wrap value. + // Was done for top level tabs support. + // + //using namespace rpl::mappers; + //return rpl::combine( + // _controller->wrapValue(), + // _desiredShadowVisibilities.events() | rpl::flatten_latest(), + // ($1 == Wrap::Side) || $2); + return _desiredShadowVisibilities.events() + | rpl::flatten_latest(); } rpl::producer WrapWidget::desiredHeightForContent() const { @@ -506,35 +551,39 @@ object_ptr WrapWidget::createContent( contentGeometry()); } -void WrapWidget::convertProfileFromStackToTab() { - if (_historyStack.empty()) { - return; - } - auto &entry = _historyStack[0]; - if (entry.section->section().type() != Section::Type::Profile) { - return; - } - auto convertInsideStack = (_historyStack.size() > 1); - auto checkSection = convertInsideStack - ? _historyStack[1].section->section() - : _controller->section(); - auto &anotherMemento = convertInsideStack - ? _historyStack[1].anotherTab - : _anotherTabMemento; - if (checkSection.type() != Section::Type::Media) { - return; - } - if (!Info::Media::TypeToTabIndex(checkSection.mediaType())) { - return; - } - anotherMemento = std::move(entry.section); - _historyStack.erase(_historyStack.begin()); -} +// Was done for top level tabs support. +// +//void WrapWidget::convertProfileFromStackToTab() { +// if (_historyStack.empty()) { +// return; +// } +// auto &entry = _historyStack[0]; +// if (entry.section->section().type() != Section::Type::Profile) { +// return; +// } +// auto convertInsideStack = (_historyStack.size() > 1); +// auto checkSection = convertInsideStack +// ? _historyStack[1].section->section() +// : _controller->section(); +// auto &anotherMemento = convertInsideStack +// ? _historyStack[1].anotherTab +// : _anotherTabMemento; +// if (checkSection.type() != Section::Type::Media) { +// return; +// } +// if (!Info::Media::TypeToTabIndex(checkSection.mediaType())) { +// return; +// } +// anotherMemento = std::move(entry.section); +// _historyStack.erase(_historyStack.begin()); +//} void WrapWidget::setWrap(Wrap wrap) { - if (_wrap.current() != Wrap::Side && wrap == Wrap::Side) { - convertProfileFromStackToTab(); - } + // Was done for top level tabs support. + // + //if (_wrap.current() != Wrap::Side && wrap == Wrap::Side) { + // convertProfileFromStackToTab(); + //} _wrap = wrap; } @@ -549,25 +598,25 @@ QPixmap WrapWidget::grabForShowAnimation( } else { _topShadow->setVisible(_topShadow->toggled()); } - if (params.withTabs && _topTabs) { - _topTabs->hide(); - } + //if (params.withTabs && _topTabs) { + // _topTabs->hide(); + //} auto result = myGrab(this); if (params.withTopBarShadow) { _topShadow->setVisible(true); } - if (params.withTabs && _topTabs) { - _topTabs->show(); - } + //if (params.withTabs && _topTabs) { + // _topTabs->show(); + //} return result; } void WrapWidget::showAnimatedHook( const Window::SectionSlideParams ¶ms) { - if (params.withTabs && _topTabs) { - _topTabs->show(); - _topTabsBackground->show(); - } + //if (params.withTabs && _topTabs) { + // _topTabs->show(); + // _topTabsBackground->show(); + //} if (params.withTopBarShadow) { _topShadow->setVisible(true); } @@ -595,23 +644,27 @@ bool WrapWidget::showInternal( if (_controller->validateMementoPeer(content) && infoMemento->stackSize() == 1) { if (!skipInternal && _content->showInternal(content)) { + highlightTopBar(); return true; - } else if (_topTabs) { - // If we open the profile being in the media tab. - // Just switch back to the profile tab. - auto type = content->section().type(); - if (type == Section::Type::Profile - && _tab != Tab::Profile) { - _anotherTabMemento = std::move(infoMemento->takeStack().back()); - _topTabs->setActiveSection(static_cast(Tab::Profile)); - return true; - } else if (type == Section::Type::Media - && _tab != Tab::Media - && Media::TypeToTabIndex(content->section().mediaType()).has_value()) { - _anotherTabMemento = std::move(infoMemento->takeStack().back()); - _topTabs->setActiveSection(static_cast(Tab::Media)); - return true; - } + + // This was done for tabs support. + // + //} else if (_topTabs) { + // // If we open the profile being in the media tab. + // // Just switch back to the profile tab. + // auto type = content->section().type(); + // if (type == Section::Type::Profile + // && _tab != Tab::Profile) { + // _anotherTabMemento = std::move(infoMemento->takeStack().back()); + // _topTabs->setActiveSection(static_cast(Tab::Profile)); + // return true; + // } else if (type == Section::Type::Media + // && _tab != Tab::Media + // && Media::TypeToTabIndex(content->section().mediaType()).has_value()) { + // _anotherTabMemento = std::move(infoMemento->takeStack().back()); + // _topTabs->setActiveSection(static_cast(Tab::Media)); + // return true; + // } } } showNewContent( @@ -622,6 +675,12 @@ bool WrapWidget::showInternal( return false; } +void WrapWidget::highlightTopBar() { + if (_topBar) { + _topBar->highlight(); + } +} + std::unique_ptr WrapWidget::createMemento() { auto stack = std::vector>(); stack.reserve(_historyStack.size() + 1); @@ -700,25 +759,30 @@ void WrapWidget::showNewContent(not_null memento) { showContent(createContent(memento, _controller.get())); } -void WrapWidget::setupTabs(Tab tab) { - _tab = tab; - if (_tab == Tab::None) { - _topTabs.destroy(); - _topTabsBackground.destroy(); - } else if (!_topTabs) { - createTabs(); - } else { - _topTabs->setActiveSection(static_cast(tab)); - } -} +// This was done for tabs support. +// +//void WrapWidget::setupTabs(Tab tab) { +// _tab = tab; +// if (_tab == Tab::None) { +// _topTabs.destroy(); +// _topTabsBackground.destroy(); +// } else if (!_topTabs) { +// createTabs(); +// } else { +// _topTabs->setActiveSection(static_cast(tab)); +// } +//} void WrapWidget::resizeEvent(QResizeEvent *e) { - if (_topTabs) { - _topTabs->resizeToWidth(width()); - _topTabsBackground->resize( - width(), - _topTabs->height() - st::lineWidth); - } else if (_topBar) { + // This was done for tabs support. + // + //if (_topTabs) { + // _topTabs->resizeToWidth(width()); + // _topTabsBackground->resize( + // width(), + // _topTabs->height() - st::lineWidth); + //} + if (_topBar) { _topBar->resizeToWidth(width()); } if (_topBarOverride) { diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index d0b7f1da02..fdb9e7267b 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -152,10 +152,11 @@ private: not_null memento, const Window::SectionShow ¶ms); void setupTop(); - void setupTabbedTop(); - void setupTabs(Tab tab); - void createTabs(); + //void setupTabbedTop(); + //void setupTabs(Tab tab); + //void createTabs(); void createTopBar(); + void highlightTopBar(); not_null topWidget() const; @@ -165,7 +166,7 @@ private: rpl::producer topShadowToggledValue() const; void updateContentGeometry(); - void showTab(Tab tab); + //void showTab(Tab tab); void showContent(object_ptr content); std::unique_ptr createTabMemento(Tab tab); object_ptr createContent( @@ -174,7 +175,7 @@ private: std::unique_ptr createController( not_null window, not_null memento); - void convertProfileFromStackToTab(); + //void convertProfileFromStackToTab(); rpl::producer selectedListValue() const; void refreshTopBarOverride(); @@ -190,8 +191,8 @@ private: rpl::variable _wrap; std::unique_ptr _controller; object_ptr _content = { nullptr }; - object_ptr _topTabsBackground = { nullptr }; - object_ptr _topTabs = { nullptr }; + //object_ptr _topTabsBackground = { nullptr }; + //object_ptr _topTabs = { nullptr }; object_ptr _topBar = { nullptr }; object_ptr _topBarOverride = { nullptr }; Animation _topBarOverrideAnimation; diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp index 3915dc2658..8c33ef8e63 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp @@ -49,128 +49,134 @@ InnerWidget::InnerWidget( [this] { refreshHeight(); }, _empty->lifetime()); _list = setupList(); - setupOtherTypes(); + // Allows showing additional shared media links and tabs. + // Was done for top level tabs support. + // + //setupOtherTypes(); } -void InnerWidget::setupOtherTypes() { - _controller->wrapValue() - | rpl::start_with_next([this](Wrap value) { - if (value == Wrap::Side - && !_controller->hasStackHistory() - && TypeToTabIndex(type())) { - createOtherTypes(); - } else { - _otherTabs = nullptr; - _otherTypes.destroy(); - refreshHeight(); - } - }, lifetime()); - rpl::combine( - _controller->wrapValue(), - _controller->searchEnabledByContent()) - | rpl::start_with_next([this](Wrap wrap, bool enabled) { - _searchEnabled = enabled; - refreshSearchField(); - }, lifetime()); -} - -void InnerWidget::createOtherTypes() { - _otherTabsShadow.create(this); - _otherTabsShadow->show(); - - _otherTabs = nullptr; - _otherTypes.create(this); - _otherTypes->show(); - - createTypeButtons(); - _otherTypes->add(object_ptr(_otherTypes)); - createTabs(); - - _otherTypes->heightValue() - | rpl::start_with_next( - [this] { refreshHeight(); }, - _otherTypes->lifetime()); -} - -void InnerWidget::createTypeButtons() { - auto wrap = _otherTypes->add(object_ptr>( - _otherTypes, - object_ptr(_otherTypes))); - auto content = wrap->entity(); - content->add(object_ptr( - content, - st::infoProfileSkip)); - - auto tracker = Ui::MultiSlideTracker(); - auto addMediaButton = [&]( - Type type, - const style::icon &icon) { - auto result = AddButton( - content, - _controller->window(), - _controller->peer(), - _controller->migrated(), - type, - tracker); - object_ptr( - result, - icon, - st::infoSharedMediaButtonIconPosition); - }; - auto addCommonGroupsButton = [&]( - not_null user, - const style::icon &icon) { - auto result = AddCommonGroupsButton( - content, - _controller->window(), - user, - tracker); - object_ptr( - result, - icon, - st::infoSharedMediaButtonIconPosition); - }; - - addMediaButton(Type::MusicFile, st::infoIconMediaAudio); - addMediaButton(Type::Link, st::infoIconMediaLink); - if (auto user = _controller->peer()->asUser()) { - addCommonGroupsButton(user, st::infoIconMediaGroup); - } - addMediaButton(Type::VoiceFile, st::infoIconMediaVoice); -// addMediaButton(Type::RoundFile, st::infoIconMediaRound); - - content->add(object_ptr( - content, - st::infoProfileSkip)); - wrap->toggleOn(tracker.atLeastOneShownValue()); - wrap->finishAnimating(); -} - -void InnerWidget::createTabs() { - _otherTabs = _otherTypes->add(object_ptr( - this, - st::infoTabs)); - auto sections = QStringList(); - sections.push_back(lang(lng_media_type_photos).toUpper()); - sections.push_back(lang(lng_media_type_videos).toUpper()); - sections.push_back(lang(lng_media_type_files).toUpper()); - _otherTabs->setSections(sections); - _otherTabs->setActiveSection(*TypeToTabIndex(type())); - _otherTabs->finishAnimating(); - - _otherTabs->sectionActivated() - | rpl::map([](int index) { return TabIndexToType(index); }) - | rpl::start_with_next( - [this](Type newType) { - if (type() != newType) { - switchToTab(Memento( - _controller->peerId(), - _controller->migratedPeerId(), - newType)); - } - }, - _otherTabs->lifetime()); -} +// Allows showing additional shared media links and tabs. +// Was done for top level tabs support. +// +//void InnerWidget::setupOtherTypes() { +// _controller->wrapValue() +// | rpl::start_with_next([this](Wrap value) { +// if (value == Wrap::Side +// && !_controller->hasStackHistory() +// && TypeToTabIndex(type())) { +// createOtherTypes(); +// } else { +// _otherTabs = nullptr; +// _otherTypes.destroy(); +// refreshHeight(); +// } +// }, lifetime()); +// rpl::combine( +// _controller->wrapValue(), +// _controller->searchEnabledByContent()) +// | rpl::start_with_next([this](Wrap wrap, bool enabled) { +// _searchEnabled = enabled; +// refreshSearchField(); +// }, lifetime()); +//} +// +//void InnerWidget::createOtherTypes() { +// _otherTabsShadow.create(this); +// _otherTabsShadow->show(); +// +// _otherTabs = nullptr; +// _otherTypes.create(this); +// _otherTypes->show(); +// +// createTypeButtons(); +// _otherTypes->add(object_ptr(_otherTypes)); +// createTabs(); +// +// _otherTypes->heightValue() +// | rpl::start_with_next( +// [this] { refreshHeight(); }, +// _otherTypes->lifetime()); +//} +// +//void InnerWidget::createTypeButtons() { +// auto wrap = _otherTypes->add(object_ptr>( +// _otherTypes, +// object_ptr(_otherTypes))); +// auto content = wrap->entity(); +// content->add(object_ptr( +// content, +// st::infoProfileSkip)); +// +// auto tracker = Ui::MultiSlideTracker(); +// auto addMediaButton = [&]( +// Type type, +// const style::icon &icon) { +// auto result = AddButton( +// content, +// _controller->window(), +// _controller->peer(), +// _controller->migrated(), +// type, +// tracker); +// object_ptr( +// result, +// icon, +// st::infoSharedMediaButtonIconPosition); +// }; +// auto addCommonGroupsButton = [&]( +// not_null user, +// const style::icon &icon) { +// auto result = AddCommonGroupsButton( +// content, +// _controller->window(), +// user, +// tracker); +// object_ptr( +// result, +// icon, +// st::infoSharedMediaButtonIconPosition); +// }; +// +// addMediaButton(Type::MusicFile, st::infoIconMediaAudio); +// addMediaButton(Type::Link, st::infoIconMediaLink); +// if (auto user = _controller->peer()->asUser()) { +// addCommonGroupsButton(user, st::infoIconMediaGroup); +// } +// addMediaButton(Type::VoiceFile, st::infoIconMediaVoice); +//// addMediaButton(Type::RoundFile, st::infoIconMediaRound); +// +// content->add(object_ptr( +// content, +// st::infoProfileSkip)); +// wrap->toggleOn(tracker.atLeastOneShownValue()); +// wrap->finishAnimating(); +//} +// +//void InnerWidget::createTabs() { +// _otherTabs = _otherTypes->add(object_ptr( +// this, +// st::infoTabs)); +// auto sections = QStringList(); +// sections.push_back(lang(lng_media_type_photos).toUpper()); +// sections.push_back(lang(lng_media_type_videos).toUpper()); +// sections.push_back(lang(lng_media_type_files).toUpper()); +// _otherTabs->setSections(sections); +// _otherTabs->setActiveSection(*TypeToTabIndex(type())); +// _otherTabs->finishAnimating(); +// +// _otherTabs->sectionActivated() +// | rpl::map([](int index) { return TabIndexToType(index); }) +// | rpl::start_with_next( +// [this](Type newType) { +// if (type() != newType) { +// switchToTab(Memento( +// _controller->peerId(), +// _controller->migratedPeerId(), +// newType)); +// } +// }, +// _otherTabs->lifetime()); +//} Type InnerWidget::type() const { return _controller->section().mediaType(); @@ -190,54 +196,62 @@ bool InnerWidget::showInternal(not_null memento) { if (mementoType == type()) { restoreState(memento); return true; - } else if (_otherTypes) { - if (TypeToTabIndex(mementoType)) { - switchToTab(std::move(*memento)); - return true; - } + + // Allows showing additional shared media links and tabs. + // Was done for top level tabs support. + // + //} else if (_otherTypes) { + // if (TypeToTabIndex(mementoType)) { + // switchToTab(std::move(*memento)); + // return true; + // } + } return false; } -void InnerWidget::switchToTab(Memento &&memento) { - // Save state of the tab before setSection() call. - _controller->setSection(&memento); - _list = setupList(); - restoreState(&memento); - _list->show(); - _list->resizeToWidth(width()); - refreshHeight(); - if (_otherTypes) { - _otherTabsShadow->raise(); - _otherTypes->raise(); - _otherTabs->setActiveSection(*TypeToTabIndex(type())); - } -} - -void InnerWidget::refreshSearchField() { - auto search = _controller->searchFieldController(); - if (search && _otherTabs && _searchEnabled) { - _searchField = search->createRowView( - this, - st::infoMediaSearch); - _searchField->resizeToWidth(width()); - _searchField->show(); - search->queryChanges() - | rpl::start_with_next([this] { - scrollToSearchField(); - }, _searchField->lifetime()); - } else { - _searchField = nullptr; - } -} - -void InnerWidget::scrollToSearchField() { - Expects(_searchField != nullptr); - - auto top = _searchField->y(); - auto bottom = top + _searchField->height(); - _scrollToRequests.fire({ top, bottom }); -} +// Allows showing additional shared media links and tabs. +// Was done for top level tabs support. +// +//void InnerWidget::switchToTab(Memento &&memento) { +// // Save state of the tab before setSection() call. +// _controller->setSection(&memento); +// _list = setupList(); +// restoreState(&memento); +// _list->show(); +// _list->resizeToWidth(width()); +// refreshHeight(); +// if (_otherTypes) { +// _otherTabsShadow->raise(); +// _otherTypes->raise(); +// _otherTabs->setActiveSection(*TypeToTabIndex(type())); +// } +//} +// +//void InnerWidget::refreshSearchField() { +// auto search = _controller->searchFieldController(); +// if (search && _otherTabs && _searchEnabled) { +// _searchField = search->createRowView( +// this, +// st::infoMediaSearch); +// _searchField->resizeToWidth(width()); +// _searchField->show(); +// search->queryChanges() +// | rpl::start_with_next([this] { +// scrollToSearchField(); +// }, _searchField->lifetime()); +// } else { +// _searchField = nullptr; +// } +//} +// +//void InnerWidget::scrollToSearchField() { +// Expects(_searchField != nullptr); +// +// auto top = _searchField->y(); +// auto bottom = top + _searchField->height(); +// _scrollToRequests.fire({ top, bottom }); +//} object_ptr InnerWidget::setupList() { auto result = object_ptr( @@ -291,13 +305,13 @@ int InnerWidget::resizeGetHeight(int newWidth) { _inResize = true; auto guard = gsl::finally([this] { _inResize = false; }); - if (_otherTypes) { - _otherTypes->resizeToWidth(newWidth); - _otherTabsShadow->resizeToWidth(newWidth); - } - if (_searchField) { - _searchField->resizeToWidth(newWidth); - } + //if (_otherTypes) { + // _otherTypes->resizeToWidth(newWidth); + // _otherTabsShadow->resizeToWidth(newWidth); + //} + //if (_searchField) { + // _searchField->resizeToWidth(newWidth); + //} _list->resizeToWidth(newWidth); _empty->resizeToWidth(newWidth); return recountHeight(); @@ -312,15 +326,15 @@ void InnerWidget::refreshHeight() { int InnerWidget::recountHeight() { auto top = 0; - if (_otherTypes) { - _otherTypes->moveToLeft(0, top); - top += _otherTypes->heightNoMargins() - st::lineWidth; - _otherTabsShadow->moveToLeft(0, top); - } - if (_searchField) { - _searchField->moveToLeft(0, top); - top += _searchField->heightNoMargins() - st::lineWidth; - } + //if (_otherTypes) { + // _otherTypes->moveToLeft(0, top); + // top += _otherTypes->heightNoMargins() - st::lineWidth; + // _otherTabsShadow->moveToLeft(0, top); + //} + //if (_searchField) { + // _searchField->moveToLeft(0, top); + // top += _searchField->heightNoMargins() - st::lineWidth; + //} auto listHeight = 0; if (_list) { _list->moveToLeft(0, top); diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.h b/Telegram/SourceFiles/info/media/info_media_inner_widget.h index 7d9cd2ae42..d154f29eb6 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.h @@ -72,27 +72,30 @@ protected: private: int recountHeight(); void refreshHeight(); - void setupOtherTypes(); - void createOtherTypes(); - void createTypeButtons(); - void createTabs(); - void switchToTab(Memento &&memento); + // Allows showing additional shared media links and tabs. + // Was done for top level tabs support. + // + //void setupOtherTypes(); + //void createOtherTypes(); + //void createTypeButtons(); + //void createTabs(); + //void switchToTab(Memento &&memento); + //void refreshSearchField(); + //void scrollToSearchField(); Type type() const; - void refreshSearchField(); - void scrollToSearchField(); object_ptr setupList(); const not_null _controller; - Ui::SettingsSlider *_otherTabs = nullptr; - object_ptr _otherTypes = { nullptr }; - object_ptr _otherTabsShadow = { nullptr }; - base::unique_qptr _searchField = nullptr; + //Ui::SettingsSlider *_otherTabs = nullptr; + //object_ptr _otherTypes = { nullptr }; + //object_ptr _otherTabsShadow = { nullptr }; + //base::unique_qptr _searchField = nullptr; object_ptr _list = { nullptr }; object_ptr _empty; - bool _searchEnabled = false; + //bool _searchEnabled = false; bool _inResize = false; diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index c55d33b663..b152e8d42a 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -77,7 +77,7 @@ InnerWidget::InnerWidget( } bool InnerWidget::canHideDetailsEver() const { - return (_peer->isChat() || _peer->isMegagroup()); + return false;// (_peer->isChat() || _peer->isMegagroup()); } rpl::producer InnerWidget::canHideDetails() const { @@ -188,28 +188,34 @@ object_ptr InnerWidget::setupSharedMedia( object_ptr(parent) ); - using ToggledData = std::tuple; - rpl::combine( - tracker.atLeastOneShownValue(), - _controller->wrapValue(), - _isStackBottom.value()) - | 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), - (wasStackBottom == nowStackBottom && wasWrap == nowWrap) - ? anim::type::normal - : anim::type::instant); - }, result->lifetime()); + // Allows removing shared media links in third column. + // Was done for tabs support. + // + //using ToggledData = std::tuple; + //rpl::combine( + // tracker.atLeastOneShownValue(), + // _controller->wrapValue(), + // _isStackBottom.value()) + // | 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), + // (wasStackBottom == nowStackBottom && wasWrap == nowWrap) + // ? anim::type::normal + // : anim::type::instant); + // }, result->lifetime()); + // + // Using that instead + result->toggleOn(tracker.atLeastOneShownValue()); auto layout = result->entity(); diff --git a/Telegram/SourceFiles/ui/widgets/widgets.style b/Telegram/SourceFiles/ui/widgets/widgets.style index 41b4bbcb94..5f19cd3e25 100644 --- a/Telegram/SourceFiles/ui/widgets/widgets.style +++ b/Telegram/SourceFiles/ui/widgets/widgets.style @@ -1158,4 +1158,6 @@ InfoTopBar { mediaDelete: IconButton; search: IconButton; searchRow: SearchFieldRow; + highlightBg: color; + highlightDuration: int; }