Move filters side bar inside bodyWidget.

This commit is contained in:
John Preston 2020-03-06 15:37:48 +04:00
parent 2cefccc6eb
commit c279986493
6 changed files with 33 additions and 20 deletions

View File

@ -799,7 +799,21 @@ void MainWindow::updateControlsGeometry() {
auto body = bodyWidget()->rect(); auto body = bodyWidget()->rect();
if (_passcodeLock) _passcodeLock->setGeometry(body); if (_passcodeLock) _passcodeLock->setGeometry(body);
if (_main) _main->setGeometry(body); auto mainLeft = 0;
auto mainWidth = body.width();
if (const auto session = sessionController()) {
if (const auto skip = session->filtersWidth()) {
mainLeft += skip;
mainWidth -= skip;
}
}
if (_main) {
_main->setGeometry({
body.x() + mainLeft,
body.y(),
mainWidth,
body.height() });
}
if (_intro) _intro->setGeometry(body); if (_intro) _intro->setGeometry(body);
if (_layer) _layer->setGeometry(body); if (_layer) _layer->setGeometry(body);
if (_mediaPreview) _mediaPreview->setGeometry(body); if (_mediaPreview) _mediaPreview->setGeometry(body);

View File

@ -522,12 +522,6 @@ void MainWindow::updateControlsGeometry() {
bodyWidth -= _rightColumn->width(); bodyWidth -= _rightColumn->width();
_rightColumn->setGeometry(bodyWidth, bodyTop, width() - bodyWidth, height() - bodyTop); _rightColumn->setGeometry(bodyWidth, bodyTop, width() - bodyWidth, height() - bodyTop);
} }
if (const auto session = _controller->sessionController()) {
if (const auto skip = session->filtersWidth()) {
bodyLeft += skip;
bodyWidth -= skip;
}
}
_body->setGeometry(bodyLeft, bodyTop, bodyWidth, height() - bodyTop); _body->setGeometry(bodyLeft, bodyTop, bodyWidth, height() - bodyTop);
} }

View File

@ -17,19 +17,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Window { namespace Window {
FiltersMenu::FiltersMenu(not_null<SessionController*> session) FiltersMenu::FiltersMenu(
not_null<Ui::RpWidget*> parent,
not_null<SessionController*> session)
: _session(session) : _session(session)
, _widget(session->widget(), st::defaultSideBarMenu) { , _parent(parent)
, _widget(_parent, st::defaultSideBarMenu) {
setup(); setup();
} }
void FiltersMenu::setup() { void FiltersMenu::setup() {
const auto body = _session->widget()->bodyWidget(); _parent->heightValue(
rpl::combine( ) | rpl::start_with_next([=](int height) {
body->topValue(), _widget.setGeometry({ 0, 0, st::windowFiltersWidth, height });
body->heightValue()
) | rpl::start_with_next([=](int top, int height) {
_widget.setGeometry({ 0, top, st::windowFiltersWidth, height });
}, _widget.lifetime()); }, _widget.lifetime());
const auto filters = &_session->session().data().chatsFilters(); const auto filters = &_session->session().data().chatsFilters();

View File

@ -15,13 +15,16 @@ class SessionController;
class FiltersMenu final { class FiltersMenu final {
public: public:
explicit FiltersMenu(not_null<SessionController*> session); FiltersMenu(
not_null<Ui::RpWidget*> parent,
not_null<SessionController*> session);
private: private:
void setup(); void setup();
void refresh(); void refresh();
const not_null<SessionController*> _session; const not_null<SessionController*> _session;
const not_null<Ui::RpWidget*> _parent;
Ui::SideBarMenu _widget; Ui::SideBarMenu _widget;
}; };

View File

@ -194,7 +194,9 @@ void SessionController::toggleFiltersMenu(bool enabled) {
if (!enabled == !_filters) { if (!enabled == !_filters) {
return; return;
} else if (enabled) { } else if (enabled) {
_filters = std::make_unique<FiltersMenu>(this); _filters = std::make_unique<FiltersMenu>(
widget()->bodyWidget(),
this);
} else { } else {
_filters = nullptr; _filters = nullptr;
} }
@ -346,10 +348,10 @@ bool SessionController::forceWideDialogs() const {
return !App::main()->isMainSectionShown(); return !App::main()->isMainSectionShown();
} }
SessionController::ColumnLayout SessionController::computeColumnLayout() const { auto SessionController::computeColumnLayout() const -> ColumnLayout {
auto layout = Adaptive::WindowLayout::OneColumn; auto layout = Adaptive::WindowLayout::OneColumn;
auto bodyWidth = widget()->bodyWidget()->width(); auto bodyWidth = widget()->bodyWidget()->width() - filtersWidth();
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0; auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
auto useOneColumnLayout = [&] { auto useOneColumnLayout = [&] {

View File

@ -215,7 +215,7 @@ public:
int thirdWidth; int thirdWidth;
Adaptive::WindowLayout windowLayout; Adaptive::WindowLayout windowLayout;
}; };
ColumnLayout computeColumnLayout() const; [[nodiscard]] ColumnLayout computeColumnLayout() const;
int dialogsSmallColumnWidth() const; int dialogsSmallColumnWidth() const;
bool forceWideDialogs() const; bool forceWideDialogs() const;
void updateColumnLayout(); void updateColumnLayout();