2017-03-27 12:24:38 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-20 18:40:23 +00:00
|
|
|
#include <rpl/variable.h>
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
class MainWidget;
|
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
namespace Window {
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
enum class GifPauseReason {
|
2017-09-03 18:36:06 +00:00
|
|
|
Any = 0,
|
2017-04-07 18:10:49 +00:00
|
|
|
InlineResults = (1 << 0),
|
2017-09-03 18:36:06 +00:00
|
|
|
SavedGifs = (1 << 1),
|
|
|
|
Layer = (1 << 2),
|
|
|
|
RoundPlaying = (1 << 3),
|
|
|
|
MediaPreview = (1 << 4),
|
2017-04-07 18:10:49 +00:00
|
|
|
};
|
2017-08-31 16:28:58 +00:00
|
|
|
using GifPauseReasons = base::flags<GifPauseReason>;
|
|
|
|
inline constexpr bool is_flag_type(GifPauseReason) { return true; };
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
struct SectionShow {
|
|
|
|
enum class Way {
|
|
|
|
Forward,
|
|
|
|
Backward,
|
|
|
|
ClearStack,
|
|
|
|
};
|
|
|
|
SectionShow(
|
2017-10-03 17:41:44 +00:00
|
|
|
Way way = Way::Forward,
|
2017-10-03 13:05:58 +00:00
|
|
|
anim::type animated = anim::type::normal,
|
|
|
|
anim::activation activation = anim::activation::normal)
|
|
|
|
: way(way)
|
|
|
|
, animated(animated)
|
|
|
|
, activation(activation) {
|
|
|
|
}
|
|
|
|
SectionShow(
|
|
|
|
anim::type animated,
|
|
|
|
anim::activation activation = anim::activation::normal)
|
|
|
|
: animated(animated)
|
|
|
|
, activation(activation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionShow withWay(Way newWay) const {
|
|
|
|
return SectionShow(newWay, animated, activation);
|
|
|
|
}
|
|
|
|
|
|
|
|
Way way = Way::Forward;
|
|
|
|
anim::type animated = anim::type::normal;
|
|
|
|
anim::activation activation = anim::activation::normal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
class MainWindow;
|
2017-09-15 17:34:41 +00:00
|
|
|
class SectionMemento;
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
class Controller {
|
|
|
|
public:
|
2017-04-09 18:06:06 +00:00
|
|
|
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
Controller(not_null<MainWindow*> window) : _window(window) {
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<MainWindow*> window() const {
|
2017-04-07 18:10:49 +00:00
|
|
|
return _window;
|
2017-03-27 12:24:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is needed for History TopBar updating when searchInPeer
|
|
|
|
// is changed in the DialogsWidget of the current window.
|
2017-09-20 18:40:23 +00:00
|
|
|
rpl::variable<PeerData*> searchInPeer;
|
2017-03-27 12:24:38 +00:00
|
|
|
|
|
|
|
// This is needed while we have one HistoryWidget and one TopBarWidget
|
|
|
|
// for all histories we show in a window. Once each history is shown
|
|
|
|
// in its own HistoryWidget with its own TopBarWidget this can be removed.
|
2017-09-20 18:40:23 +00:00
|
|
|
rpl::variable<PeerData*> historyPeer;
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
void enableGifPauseReason(GifPauseReason reason);
|
|
|
|
void disableGifPauseReason(GifPauseReason reason);
|
|
|
|
base::Observable<void> &gifPauseLevelChanged() {
|
|
|
|
return _gifPauseLevelChanged;
|
|
|
|
}
|
|
|
|
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
2017-05-23 14:04:59 +00:00
|
|
|
base::Observable<void> &floatPlayerAreaUpdated() {
|
|
|
|
return _floatPlayerAreaUpdated;
|
|
|
|
}
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
struct ColumnLayout {
|
|
|
|
int bodyWidth;
|
|
|
|
int dialogsWidth;
|
2017-05-17 11:50:00 +00:00
|
|
|
int chatWidth;
|
2017-09-16 16:53:41 +00:00
|
|
|
int thirdWidth;
|
2017-04-09 18:06:06 +00:00
|
|
|
Adaptive::WindowLayout windowLayout;
|
|
|
|
};
|
2017-05-17 11:50:00 +00:00
|
|
|
ColumnLayout computeColumnLayout() const;
|
2017-05-13 12:02:07 +00:00
|
|
|
int dialogsSmallColumnWidth() const;
|
2017-09-19 18:59:10 +00:00
|
|
|
bool forceWideDialogs() const;
|
2017-09-16 16:53:41 +00:00
|
|
|
void updateColumnLayout();
|
|
|
|
bool canShowThirdSection() const;
|
2017-09-19 10:32:34 +00:00
|
|
|
bool canShowThirdSectionWithoutResize() const;
|
|
|
|
bool takeThirdSectionFromLayer();
|
2017-09-16 16:53:41 +00:00
|
|
|
void resizeForThirdSection();
|
|
|
|
void closeThirdSection();
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void showSection(
|
|
|
|
SectionMemento &&memento,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms = SectionShow());
|
2017-09-20 10:23:57 +00:00
|
|
|
void showBackFromStack(
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms = SectionShow());
|
2017-09-16 16:53:41 +00:00
|
|
|
|
|
|
|
void showPeerHistory(
|
|
|
|
PeerId peerId,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
2017-10-03 13:05:58 +00:00
|
|
|
MsgId msgId = ShowAtUnreadMsgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
void showPeerHistory(
|
|
|
|
not_null<PeerData*> peer,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
2017-10-03 13:05:58 +00:00
|
|
|
MsgId msgId = ShowAtUnreadMsgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
void showPeerHistory(
|
|
|
|
not_null<History*> history,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
2017-10-03 13:05:58 +00:00
|
|
|
MsgId msgId = ShowAtUnreadMsgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
|
|
|
|
void showPeerInfo(
|
|
|
|
PeerId peerId,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow());
|
2017-09-16 16:53:41 +00:00
|
|
|
void showPeerInfo(
|
|
|
|
not_null<PeerData*> peer,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow());
|
2017-09-16 16:53:41 +00:00
|
|
|
void showPeerInfo(
|
|
|
|
not_null<History*> history,
|
2017-10-03 17:41:44 +00:00
|
|
|
const SectionShow ¶ms = SectionShow());
|
2017-09-20 10:23:57 +00:00
|
|
|
|
|
|
|
void clearSectionStack(
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms = SectionShow::Way::ClearStack) {
|
2017-09-20 10:23:57 +00:00
|
|
|
showPeerHistory(
|
|
|
|
PeerId(0),
|
2017-10-03 13:05:58 +00:00
|
|
|
params,
|
|
|
|
ShowAtUnreadMsgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void showSpecialLayer(
|
|
|
|
object_ptr<LayerWidget> &&layer,
|
|
|
|
anim::type animated = anim::type::normal);
|
|
|
|
void hideSpecialLayer(
|
|
|
|
anim::type animated = anim::type::normal) {
|
|
|
|
showSpecialLayer(nullptr, animated);
|
2017-09-20 10:23:57 +00:00
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
void showJumpToDate(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
QDate requestedDate);
|
2017-08-01 11:43:50 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
base::Variable<float64> &dialogsWidthRatio() {
|
|
|
|
return _dialogsWidthRatio;
|
|
|
|
}
|
2017-05-17 11:50:00 +00:00
|
|
|
const base::Variable<float64> &dialogsWidthRatio() const {
|
|
|
|
return _dialogsWidthRatio;
|
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
base::Variable<bool> &dialogsListFocused() {
|
|
|
|
return _dialogsListFocused;
|
|
|
|
}
|
2017-05-17 11:50:00 +00:00
|
|
|
const base::Variable<bool> &dialogsListFocused() const {
|
|
|
|
return _dialogsListFocused;
|
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
base::Variable<bool> &dialogsListDisplayForced() {
|
|
|
|
return _dialogsListDisplayForced;
|
|
|
|
}
|
2017-05-17 11:50:00 +00:00
|
|
|
const base::Variable<bool> &dialogsListDisplayForced() const {
|
|
|
|
return _dialogsListDisplayForced;
|
|
|
|
}
|
2017-04-09 18:06:06 +00:00
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
private:
|
2017-09-16 16:53:41 +00:00
|
|
|
int minimalThreeColumnWidth() const;
|
2017-09-15 17:34:41 +00:00
|
|
|
not_null<MainWidget*> chats() const;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<MainWindow*> _window;
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2017-08-31 16:28:58 +00:00
|
|
|
GifPauseReasons _gifPauseReasons = 0;
|
2017-04-07 18:10:49 +00:00
|
|
|
base::Observable<void> _gifPauseLevelChanged;
|
2017-05-23 14:04:59 +00:00
|
|
|
base::Observable<void> _floatPlayerAreaUpdated;
|
2017-04-07 18:10:49 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
base::Variable<float64> _dialogsWidthRatio = { kDefaultDialogsWidthRatio };
|
|
|
|
base::Variable<bool> _dialogsListFocused = { false };
|
|
|
|
base::Variable<bool> _dialogsListDisplayForced = { false };
|
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|