mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-11 04:01:18 +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();
|
updateTabbedSelectorSectionShown();
|
||||||
recountChatWidth();
|
recountChatWidth();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
} else if (_controller->provideChatWidth(minimalWidthForTabbedSelectorSection())) {
|
} else if (_controller->canProvideChatWidth(minimalWidthForTabbedSelectorSection())) {
|
||||||
if (!AuthSession::Current().data().tabbedSelectorSectionEnabled()) {
|
if (!AuthSession::Current().data().tabbedSelectorSectionEnabled()) {
|
||||||
AuthSession::Current().data().setTabbedSelectorSectionEnabled(true);
|
AuthSession::Current().data().setTabbedSelectorSectionEnabled(true);
|
||||||
AuthSession::Current().saveDataDelayed(kSaveTabbedSelectorSectionTimeoutMs);
|
AuthSession::Current().saveDataDelayed(kSaveTabbedSelectorSectionTimeoutMs);
|
||||||
}
|
}
|
||||||
|
_controller->provideChatWidth(minimalWidthForTabbedSelectorSection());
|
||||||
updateTabbedSelectorSectionShown();
|
updateTabbedSelectorSectionShown();
|
||||||
recountChatWidth();
|
recountChatWidth();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -3192,6 +3192,9 @@ void MainWidget::handleAdaptiveLayoutUpdate() {
|
|||||||
|
|
||||||
void MainWidget::updateWindowAdaptiveLayout() {
|
void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
auto layout = _controller->computeColumnLayout();
|
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) {
|
if (layout.windowLayout == Adaptive::WindowLayout::OneColumn) {
|
||||||
auto chatWidth = layout.dialogsWidth;
|
auto chatWidth = layout.dialogsWidth;
|
||||||
if (AuthSession::Current().data().tabbedSelectorSectionEnabled()
|
if (AuthSession::Current().data().tabbedSelectorSectionEnabled()
|
||||||
@ -3205,6 +3208,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
|||||||
_controller->dialogsWidthRatio().set(float64(layout.dialogsWidth) / layout.bodyWidth, true);
|
_controller->dialogsWidthRatio().set(float64(layout.dialogsWidth) / layout.bodyWidth, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_dialogsWidth = layout.dialogsWidth;
|
_dialogsWidth = layout.dialogsWidth;
|
||||||
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
|
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
|
||||||
Global::SetAdaptiveWindowLayout(layout.windowLayout);
|
Global::SetAdaptiveWindowLayout(layout.windowLayout);
|
||||||
|
@ -57,14 +57,14 @@ int Controller::dialogsSmallColumnWidth() const {
|
|||||||
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller::ColumnLayout Controller::computeColumnLayout() {
|
Controller::ColumnLayout Controller::computeColumnLayout() const {
|
||||||
auto layout = Adaptive::WindowLayout::OneColumn;
|
auto layout = Adaptive::WindowLayout::OneColumn;
|
||||||
|
|
||||||
auto bodyWidth = window()->bodyWidget()->width();
|
auto bodyWidth = window()->bodyWidget()->width();
|
||||||
auto dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
auto dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
|
||||||
auto historyWidth = bodyWidth - dialogsWidth;
|
auto chatWidth = bodyWidth - dialogsWidth;
|
||||||
accumulate_max(historyWidth, st::windowMinWidth);
|
accumulate_max(chatWidth, st::windowMinWidth);
|
||||||
dialogsWidth = bodyWidth - historyWidth;
|
dialogsWidth = bodyWidth - chatWidth;
|
||||||
|
|
||||||
auto useOneColumnLayout = [this, bodyWidth, dialogsWidth] {
|
auto useOneColumnLayout = [this, bodyWidth, dialogsWidth] {
|
||||||
auto someSectionShown = !App::main()->selectingPeer() && App::main()->isSectionShown();
|
auto someSectionShown = !App::main()->selectingPeer() && App::main()->isSectionShown();
|
||||||
@ -76,15 +76,17 @@ Controller::ColumnLayout Controller::computeColumnLayout() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto useSmallColumnLayout = [this, dialogsWidth] {
|
auto useSmallColumnLayout = [this, dialogsWidth] {
|
||||||
// used if useOneColumnLayout() == false.
|
// Used if useOneColumnLayout() == false.
|
||||||
if (dialogsWidth < st::dialogsWidthMin / 2) {
|
if (dialogsWidth < st::dialogsWidthMin / 2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (useOneColumnLayout()) {
|
if (useOneColumnLayout()) {
|
||||||
dialogsWidth = bodyWidth;
|
dialogsWidth = chatWidth = bodyWidth;
|
||||||
} else if (useSmallColumnLayout()) {
|
} else if (useSmallColumnLayout()) {
|
||||||
layout = Adaptive::WindowLayout::SmallColumn;
|
layout = Adaptive::WindowLayout::SmallColumn;
|
||||||
auto forceWideDialogs = [this] {
|
auto forceWideDialogs = [this] {
|
||||||
@ -100,31 +102,35 @@ Controller::ColumnLayout Controller::computeColumnLayout() {
|
|||||||
} else {
|
} else {
|
||||||
dialogsWidth = dialogsSmallColumnWidth();
|
dialogsWidth = dialogsSmallColumnWidth();
|
||||||
}
|
}
|
||||||
|
chatWidth = bodyWidth - dialogsWidth;
|
||||||
} else {
|
} else {
|
||||||
layout = Adaptive::WindowLayout::Normal;
|
layout = Adaptive::WindowLayout::Normal;
|
||||||
accumulate_max(dialogsWidth, st::dialogsWidthMin);
|
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 currentLayout = computeColumnLayout();
|
||||||
auto chatWidth = currentLayout.bodyWidth - currentLayout.dialogsWidth;
|
auto extendBy = requestedWidth - currentLayout.chatWidth;
|
||||||
if (currentLayout.windowLayout == Adaptive::WindowLayout::OneColumn) {
|
if (extendBy <= 0) {
|
||||||
chatWidth = currentLayout.bodyWidth;
|
|
||||||
}
|
|
||||||
if (chatWidth >= requestedWidth) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!window()->canExtendWidthBy(requestedWidth - chatWidth)) {
|
return window()->canExtendWidthBy(extendBy);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
window()->tryToExtendWidthBy(requestedWidth - chatWidth);
|
|
||||||
|
void Controller::provideChatWidth(int requestedWidth) {
|
||||||
|
auto currentLayout = computeColumnLayout();
|
||||||
|
auto extendBy = requestedWidth - currentLayout.chatWidth;
|
||||||
|
if (extendBy <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window()->tryToExtendWidthBy(extendBy);
|
||||||
auto newLayout = computeColumnLayout();
|
auto newLayout = computeColumnLayout();
|
||||||
if (newLayout.windowLayout != Adaptive::WindowLayout::OneColumn) {
|
if (newLayout.windowLayout != Adaptive::WindowLayout::OneColumn) {
|
||||||
dialogsWidthRatio().set(float64(newLayout.bodyWidth - requestedWidth) / newLayout.bodyWidth, true);
|
dialogsWidthRatio().set(float64(newLayout.bodyWidth - requestedWidth) / newLayout.bodyWidth, true);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
@ -69,21 +69,32 @@ public:
|
|||||||
struct ColumnLayout {
|
struct ColumnLayout {
|
||||||
int bodyWidth;
|
int bodyWidth;
|
||||||
int dialogsWidth;
|
int dialogsWidth;
|
||||||
|
int chatWidth;
|
||||||
Adaptive::WindowLayout windowLayout;
|
Adaptive::WindowLayout windowLayout;
|
||||||
};
|
};
|
||||||
ColumnLayout computeColumnLayout();
|
ColumnLayout computeColumnLayout() const;
|
||||||
int dialogsSmallColumnWidth() const;
|
int dialogsSmallColumnWidth() const;
|
||||||
bool provideChatWidth(int requestedWidth);
|
bool canProvideChatWidth(int requestedWidth) const;
|
||||||
|
void provideChatWidth(int requestedWidth);
|
||||||
|
|
||||||
base::Variable<float64> &dialogsWidthRatio() {
|
base::Variable<float64> &dialogsWidthRatio() {
|
||||||
return _dialogsWidthRatio;
|
return _dialogsWidthRatio;
|
||||||
}
|
}
|
||||||
|
const base::Variable<float64> &dialogsWidthRatio() const {
|
||||||
|
return _dialogsWidthRatio;
|
||||||
|
}
|
||||||
base::Variable<bool> &dialogsListFocused() {
|
base::Variable<bool> &dialogsListFocused() {
|
||||||
return _dialogsListFocused;
|
return _dialogsListFocused;
|
||||||
}
|
}
|
||||||
|
const base::Variable<bool> &dialogsListFocused() const {
|
||||||
|
return _dialogsListFocused;
|
||||||
|
}
|
||||||
base::Variable<bool> &dialogsListDisplayForced() {
|
base::Variable<bool> &dialogsListDisplayForced() {
|
||||||
return _dialogsListDisplayForced;
|
return _dialogsListDisplayForced;
|
||||||
}
|
}
|
||||||
|
const base::Variable<bool> &dialogsListDisplayForced() const {
|
||||||
|
return _dialogsListDisplayForced;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gsl::not_null<MainWindow*> _window;
|
gsl::not_null<MainWindow*> _window;
|
||||||
|
Loading…
Reference in New Issue
Block a user