mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Added support of empty top bar to Info::WrapWidget.
This commit is contained in:
parent
3fde5b56a1
commit
001aba4791
1 changed files with 20 additions and 11 deletions
|
@ -90,7 +90,9 @@ WrapWidget::WrapWidget(
|
||||||
selectedListValue(
|
selectedListValue(
|
||||||
) | rpl::start_with_next([this](SelectedItems &&items) {
|
) | rpl::start_with_next([this](SelectedItems &&items) {
|
||||||
InvokeQueued(this, [this, items = std::move(items)]() mutable {
|
InvokeQueued(this, [this, items = std::move(items)]() mutable {
|
||||||
if (_topBar) _topBar->setSelectedItems(std::move(items));
|
if (_topBar) {
|
||||||
|
_topBar->setSelectedItems(std::move(items));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
restoreHistoryStack(memento->takeStack());
|
restoreHistoryStack(memento->takeStack());
|
||||||
|
@ -575,7 +577,7 @@ void WrapWidget::deleteAllDownloads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WrapWidget::requireTopBarSearch() const {
|
bool WrapWidget::requireTopBarSearch() const {
|
||||||
if (!_controller->searchFieldController()) {
|
if (!_topBar || !_controller->searchFieldController()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (_controller->wrap() == Wrap::Layer
|
} else if (_controller->wrap() == Wrap::Layer
|
||||||
|| _controller->section().type() == Section::Type::Profile) {
|
|| _controller->section().type() == Section::Type::Profile) {
|
||||||
|
@ -654,7 +656,9 @@ void WrapWidget::showContent(object_ptr<ContentWidget> content) {
|
||||||
void WrapWidget::finishShowContent() {
|
void WrapWidget::finishShowContent() {
|
||||||
updateContentGeometry();
|
updateContentGeometry();
|
||||||
_content->setIsStackBottom(!hasStackHistory());
|
_content->setIsStackBottom(!hasStackHistory());
|
||||||
|
if (_topBar) {
|
||||||
_topBar->setTitle(_content->title());
|
_topBar->setTitle(_content->title());
|
||||||
|
}
|
||||||
_desiredHeights.fire(desiredHeightForContent());
|
_desiredHeights.fire(desiredHeightForContent());
|
||||||
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility());
|
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility());
|
||||||
_desiredBottomShadowVisibilities.fire(
|
_desiredBottomShadowVisibilities.fire(
|
||||||
|
@ -684,14 +688,15 @@ rpl::producer<bool> WrapWidget::topShadowToggledValue() const {
|
||||||
// _desiredShadowVisibilities.events() | rpl::flatten_latest(),
|
// _desiredShadowVisibilities.events() | rpl::flatten_latest(),
|
||||||
// (_1 == Wrap::Side) || _2);
|
// (_1 == Wrap::Side) || _2);
|
||||||
return _desiredShadowVisibilities.events()
|
return _desiredShadowVisibilities.events()
|
||||||
| rpl::flatten_latest();
|
| rpl::flatten_latest(
|
||||||
|
) | rpl::map([=](bool v) { return v && (_topBar != nullptr); });
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> WrapWidget::desiredHeightForContent() const {
|
rpl::producer<int> WrapWidget::desiredHeightForContent() const {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
return rpl::single(0) | rpl::then(rpl::combine(
|
return rpl::single(0) | rpl::then(rpl::combine(
|
||||||
_content->desiredHeightValue(),
|
_content->desiredHeightValue(),
|
||||||
topWidget()->heightValue(),
|
(_topBar ? _topBar->heightValue() : rpl::single(0)),
|
||||||
_1 + _2));
|
_1 + _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +821,7 @@ void WrapWidget::showAnimatedHook(
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrapWidget::doSetInnerFocus() {
|
void WrapWidget::doSetInnerFocus() {
|
||||||
if (!_topBar->focusSearchField()) {
|
if (_topBar && !_topBar->focusSearchField()) {
|
||||||
_content->setInnerFocus();
|
_content->setInnerFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -906,7 +911,8 @@ rpl::producer<int> WrapWidget::desiredHeightValue() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect WrapWidget::contentGeometry() const {
|
QRect WrapWidget::contentGeometry() const {
|
||||||
return rect().marginsRemoved({ 0, topWidget()->height(), 0, 0 });
|
const auto top = _topBar ? _topBar->height() : 0;
|
||||||
|
return rect().marginsRemoved({ 0, top, 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WrapWidget::returnToFirstStackFrame(
|
bool WrapWidget::returnToFirstStackFrame(
|
||||||
|
@ -1035,8 +1041,10 @@ void WrapWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
|
|
||||||
void WrapWidget::updateContentGeometry() {
|
void WrapWidget::updateContentGeometry() {
|
||||||
if (_content) {
|
if (_content) {
|
||||||
|
if (_topBar) {
|
||||||
_topShadow->resizeToWidth(width());
|
_topShadow->resizeToWidth(width());
|
||||||
_topShadow->moveToLeft(0, topWidget()->height());
|
_topShadow->moveToLeft(0, _topBar->height());
|
||||||
|
}
|
||||||
_content->setGeometry(contentGeometry());
|
_content->setGeometry(contentGeometry());
|
||||||
_bottomShadow->resizeToWidth(width());
|
_bottomShadow->resizeToWidth(width());
|
||||||
_bottomShadow->moveToLeft(
|
_bottomShadow->moveToLeft(
|
||||||
|
@ -1057,7 +1065,7 @@ QRect WrapWidget::floatPlayerAvailableRect() {
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
|
object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
|
||||||
QWidget *parent) {
|
QWidget *parent) {
|
||||||
if (hasStackHistory() || wrap() == Wrap::Narrow) {
|
if (_topBar && (hasStackHistory() || wrap() == Wrap::Narrow)) {
|
||||||
Assert(_topBar != nullptr);
|
Assert(_topBar != nullptr);
|
||||||
|
|
||||||
auto result = object_ptr<Ui::AbstractButton>(parent);
|
auto result = object_ptr<Ui::AbstractButton>(parent);
|
||||||
|
@ -1099,7 +1107,8 @@ void WrapWidget::updateGeometry(
|
||||||
}
|
}
|
||||||
|
|
||||||
int WrapWidget::scrollTillBottom(int forHeight) const {
|
int WrapWidget::scrollTillBottom(int forHeight) const {
|
||||||
return _content->scrollTillBottom(forHeight - topWidget()->height());
|
return _content->scrollTillBottom(forHeight
|
||||||
|
- (_topBar ? _topBar->height() : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int WrapWidget::scrollBottomSkip() const {
|
int WrapWidget::scrollBottomSkip() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue