2021-05-26 23:16: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
|
|
|
|
*/
|
|
|
|
#include "window/window_adaptive.h"
|
|
|
|
|
|
|
|
#include "history/history_item.h"
|
|
|
|
#include "data/data_media_types.h"
|
|
|
|
#include "data/data_session.h"
|
2021-05-27 00:44:12 +00:00
|
|
|
#include "core/application.h"
|
|
|
|
#include "core/core_settings.h"
|
2021-05-26 23:16:12 +00:00
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
Adaptive::Adaptive() = default;
|
2021-05-26 23:16:12 +00:00
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
void Adaptive::setWindowLayout(WindowLayout value) {
|
2021-05-26 23:16:12 +00:00
|
|
|
_layout = value;
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
void Adaptive::setChatLayout(ChatLayout value) {
|
2021-05-26 23:16:12 +00:00
|
|
|
_chatLayout = value;
|
|
|
|
}
|
|
|
|
|
2021-06-24 05:33:52 +00:00
|
|
|
rpl::producer<> Adaptive::value() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return rpl::merge(
|
2021-05-27 00:44:12 +00:00
|
|
|
Core::App().settings().adaptiveForWideValue() | rpl::to_empty,
|
2021-05-26 23:16:12 +00:00
|
|
|
_chatLayout.changes() | rpl::to_empty,
|
2021-06-24 05:33:52 +00:00
|
|
|
_layout.changes() | rpl::to_empty);
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<> Adaptive::changes() const {
|
|
|
|
return rpl::merge(
|
|
|
|
Core::App().settings().adaptiveForWideChanges() | rpl::to_empty,
|
|
|
|
_chatLayout.changes() | rpl::to_empty,
|
2021-05-26 23:16:12 +00:00
|
|
|
_layout.changes() | rpl::to_empty);
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
rpl::producer<bool> Adaptive::oneColumnValue() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return _layout.value(
|
|
|
|
) | rpl::map([=] {
|
|
|
|
return isOneColumn();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
rpl::producer<Adaptive::ChatLayout> Adaptive::chatLayoutValue() const {
|
2021-05-26 23:20:00 +00:00
|
|
|
return _chatLayout.value();
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
bool Adaptive::isOneColumn() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return _layout.current() == WindowLayout::OneColumn;
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
bool Adaptive::isNormal() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return _layout.current() == WindowLayout::Normal;
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
bool Adaptive::isThreeColumn() const {
|
2021-05-26 23:16:12 +00:00
|
|
|
return _layout.current() == WindowLayout::ThreeColumn;
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
rpl::producer<bool> Adaptive::chatWideValue() const {
|
2021-05-27 00:44:12 +00:00
|
|
|
return rpl::combine(
|
|
|
|
_chatLayout.value(
|
2021-05-27 13:54:24 +00:00
|
|
|
) | rpl::map(rpl::mappers::_1 == Adaptive::ChatLayout::Wide),
|
2021-05-27 00:44:12 +00:00
|
|
|
Core::App().settings().adaptiveForWideValue()
|
|
|
|
) | rpl::map(rpl::mappers::_1 && rpl::mappers::_2);
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
bool Adaptive::isChatWide() const {
|
2021-05-27 00:44:12 +00:00
|
|
|
return Core::App().settings().adaptiveForWide()
|
2021-05-27 13:54:24 +00:00
|
|
|
&& (_chatLayout.current() == Adaptive::ChatLayout::Wide);
|
2021-05-27 00:44:12 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 23:16:12 +00:00
|
|
|
} // namespace Window
|