2021-05-26 21:29:12 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
2018-06-20 00:02:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/wrap/slide_wrap.h"
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
|
|
|
template <typename Inner>
|
|
|
|
class TopBarWrapWidget : public Ui::SlideWrap<Inner> {
|
|
|
|
using Parent = Ui::SlideWrap<Inner>;
|
|
|
|
|
|
|
|
public:
|
2021-05-26 21:29:12 +00:00
|
|
|
TopBarWrapWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<Inner> inner,
|
|
|
|
rpl::producer<bool> oneColumnValue)
|
2018-06-20 00:02:36 +00:00
|
|
|
: Parent(parent, std::move(inner)) {
|
|
|
|
this->sizeValue(
|
2021-05-26 21:29:12 +00:00
|
|
|
) | rpl::start_with_next([=](const QSize &size) {
|
2018-06-20 00:02:36 +00:00
|
|
|
updateShadowGeometry(size);
|
|
|
|
}, this->lifetime());
|
2021-05-26 21:29:12 +00:00
|
|
|
|
|
|
|
std::move(
|
|
|
|
oneColumnValue
|
|
|
|
) | rpl::start_with_next([=](bool oneColumn) {
|
|
|
|
_isOneColumn = oneColumn;
|
|
|
|
}, this->lifetime());
|
2018-06-20 00:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void updateAdaptiveLayout() {
|
|
|
|
updateShadowGeometry(this->size());
|
|
|
|
}
|
|
|
|
void showShadow() {
|
|
|
|
this->entity()->showShadow();
|
|
|
|
}
|
|
|
|
void hideShadow() {
|
|
|
|
this->entity()->hideShadow();
|
|
|
|
}
|
|
|
|
int contentHeight() const {
|
|
|
|
return qMax(this->height() - st::lineWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateShadowGeometry(const QSize &size) {
|
2021-05-26 21:29:12 +00:00
|
|
|
const auto skip = _isOneColumn ? 0 : st::lineWidth;
|
2018-06-20 00:02:36 +00:00
|
|
|
this->entity()->setShadowGeometryToLeft(
|
|
|
|
skip,
|
|
|
|
size.height() - st::lineWidth,
|
|
|
|
size.width() - skip,
|
|
|
|
st::lineWidth);
|
|
|
|
}
|
|
|
|
|
2021-05-26 21:29:12 +00:00
|
|
|
bool _isOneColumn = false;
|
|
|
|
|
2018-06-20 00:02:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|