mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-01 03:22:10 +00:00
Fix enabling emoji sidebar from a small window.
Extend the window size after the tabbedSelectorSectionEnabled flag is already set to true. Otherwise we extend the window and switch to a normal from single column layout before showing the sidebar.
This commit is contained in:
parent
966dcd5509
commit
9f7c45e35c
@ -3787,11 +3787,12 @@ void HistoryWidget::toggleTabbedSelectorMode() {
|
||||
updateTabbedSelectorSectionShown();
|
||||
recountChatWidth();
|
||||
updateControlsGeometry();
|
||||
} else if (_controller->provideChatWidth(minimalWidthForTabbedSelectorSection())) {
|
||||
} else if (_controller->canProvideChatWidth(minimalWidthForTabbedSelectorSection())) {
|
||||
if (!AuthSession::Current().data().tabbedSelectorSectionEnabled()) {
|
||||
AuthSession::Current().data().setTabbedSelectorSectionEnabled(true);
|
||||
AuthSession::Current().saveDataDelayed(kSaveTabbedSelectorSectionTimeoutMs);
|
||||
}
|
||||
_controller->provideChatWidth(minimalWidthForTabbedSelectorSection());
|
||||
updateTabbedSelectorSectionShown();
|
||||
recountChatWidth();
|
||||
updateControlsGeometry();
|
||||
|
@ -3192,6 +3192,9 @@ void MainWidget::handleAdaptiveLayoutUpdate() {
|
||||
|
||||
void MainWidget::updateWindowAdaptiveLayout() {
|
||||
auto layout = _controller->computeColumnLayout();
|
||||
|
||||
// Check if we are in a single-column layout in a wide enough window
|
||||
// for the normal layout. If so, switch to the normal layout.
|
||||
if (layout.windowLayout == Adaptive::WindowLayout::OneColumn) {
|
||||
auto chatWidth = layout.dialogsWidth;
|
||||
if (AuthSession::Current().data().tabbedSelectorSectionEnabled()
|
||||
@ -3205,6 +3208,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||
_controller->dialogsWidthRatio().set(float64(layout.dialogsWidth) / layout.bodyWidth, true);
|
||||
}
|
||||
}
|
||||
|
||||
_dialogsWidth = layout.dialogsWidth;
|
||||
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
|
||||
Global::SetAdaptiveWindowLayout(layout.windowLayout);
|
||||
|
@ -57,14 +57,14 @@ int Controller::dialogsSmallColumnWidth() const {
|
||||
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
||||
}
|
||||
|
||||
Controller::ColumnLayout Controller::computeColumnLayout() {
|
||||
Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||
auto layout = Adaptive::WindowLayout::OneColumn;
|
||||
|
||||
auto bodyWidth = window()->bodyWidget()->width();
|
||||
auto dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
||||
auto historyWidth = bodyWidth - dialogsWidth;
|
||||
accumulate_max(historyWidth, st::windowMinWidth);
|
||||
dialogsWidth = bodyWidth - historyWidth;
|
||||
auto chatWidth = bodyWidth - dialogsWidth;
|
||||
accumulate_max(chatWidth, st::windowMinWidth);
|
||||
dialogsWidth = bodyWidth - chatWidth;
|
||||
|
||||
auto useOneColumnLayout = [this, bodyWidth, dialogsWidth] {
|
||||
auto someSectionShown = !App::main()->selectingPeer() && App::main()->isSectionShown();
|
||||
@ -76,15 +76,17 @@ Controller::ColumnLayout Controller::computeColumnLayout() {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto useSmallColumnLayout = [this, dialogsWidth] {
|
||||
// used if useOneColumnLayout() == false.
|
||||
// Used if useOneColumnLayout() == false.
|
||||
if (dialogsWidth < st::dialogsWidthMin / 2) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (useOneColumnLayout()) {
|
||||
dialogsWidth = bodyWidth;
|
||||
dialogsWidth = chatWidth = bodyWidth;
|
||||
} else if (useSmallColumnLayout()) {
|
||||
layout = Adaptive::WindowLayout::SmallColumn;
|
||||
auto forceWideDialogs = [this] {
|
||||
@ -100,31 +102,35 @@ Controller::ColumnLayout Controller::computeColumnLayout() {
|
||||
} else {
|
||||
dialogsWidth = dialogsSmallColumnWidth();
|
||||
}
|
||||
chatWidth = bodyWidth - dialogsWidth;
|
||||
} else {
|
||||
layout = Adaptive::WindowLayout::Normal;
|
||||
accumulate_max(dialogsWidth, st::dialogsWidthMin);
|
||||
chatWidth = bodyWidth - dialogsWidth;
|
||||
}
|
||||
return { bodyWidth, dialogsWidth, layout };
|
||||
return { bodyWidth, dialogsWidth, chatWidth, layout };
|
||||
}
|
||||
|
||||
bool Controller::provideChatWidth(int requestedWidth) {
|
||||
bool Controller::canProvideChatWidth(int requestedWidth) const {
|
||||
auto currentLayout = computeColumnLayout();
|
||||
auto chatWidth = currentLayout.bodyWidth - currentLayout.dialogsWidth;
|
||||
if (currentLayout.windowLayout == Adaptive::WindowLayout::OneColumn) {
|
||||
chatWidth = currentLayout.bodyWidth;
|
||||
}
|
||||
if (chatWidth >= requestedWidth) {
|
||||
auto extendBy = requestedWidth - currentLayout.chatWidth;
|
||||
if (extendBy <= 0) {
|
||||
return true;
|
||||
}
|
||||
if (!window()->canExtendWidthBy(requestedWidth - chatWidth)) {
|
||||
return false;
|
||||
return window()->canExtendWidthBy(extendBy);
|
||||
}
|
||||
|
||||
void Controller::provideChatWidth(int requestedWidth) {
|
||||
auto currentLayout = computeColumnLayout();
|
||||
auto extendBy = requestedWidth - currentLayout.chatWidth;
|
||||
if (extendBy <= 0) {
|
||||
return;
|
||||
}
|
||||
window()->tryToExtendWidthBy(requestedWidth - chatWidth);
|
||||
window()->tryToExtendWidthBy(extendBy);
|
||||
auto newLayout = computeColumnLayout();
|
||||
if (newLayout.windowLayout != Adaptive::WindowLayout::OneColumn) {
|
||||
dialogsWidthRatio().set(float64(newLayout.bodyWidth - requestedWidth) / newLayout.bodyWidth, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
@ -69,21 +69,32 @@ public:
|
||||
struct ColumnLayout {
|
||||
int bodyWidth;
|
||||
int dialogsWidth;
|
||||
int chatWidth;
|
||||
Adaptive::WindowLayout windowLayout;
|
||||
};
|
||||
ColumnLayout computeColumnLayout();
|
||||
ColumnLayout computeColumnLayout() const;
|
||||
int dialogsSmallColumnWidth() const;
|
||||
bool provideChatWidth(int requestedWidth);
|
||||
bool canProvideChatWidth(int requestedWidth) const;
|
||||
void provideChatWidth(int requestedWidth);
|
||||
|
||||
base::Variable<float64> &dialogsWidthRatio() {
|
||||
return _dialogsWidthRatio;
|
||||
}
|
||||
const base::Variable<float64> &dialogsWidthRatio() const {
|
||||
return _dialogsWidthRatio;
|
||||
}
|
||||
base::Variable<bool> &dialogsListFocused() {
|
||||
return _dialogsListFocused;
|
||||
}
|
||||
const base::Variable<bool> &dialogsListFocused() const {
|
||||
return _dialogsListFocused;
|
||||
}
|
||||
base::Variable<bool> &dialogsListDisplayForced() {
|
||||
return _dialogsListDisplayForced;
|
||||
}
|
||||
const base::Variable<bool> &dialogsListDisplayForced() const {
|
||||
return _dialogsListDisplayForced;
|
||||
}
|
||||
|
||||
private:
|
||||
gsl::not_null<MainWindow*> _window;
|
||||
|
Loading…
Reference in New Issue
Block a user