Extract controls side deduction code
This commit is contained in:
parent
b9aa8a17d4
commit
6419b54383
2 changed files with 15 additions and 8 deletions
|
|
@ -56,6 +56,17 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
||||||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutValue();
|
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutValue();
|
||||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged();
|
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged();
|
||||||
|
[[nodiscard]] bool TitleControlsOnLeft(
|
||||||
|
const TitleControls::Layout &layout = TitleControlsLayout()) {
|
||||||
|
if (ranges::contains(layout.left, TitleControl::Close)) {
|
||||||
|
return true;
|
||||||
|
} else if (ranges::contains(layout.right, TitleControl::Close)) {
|
||||||
|
return false;
|
||||||
|
} else if (layout.left.size() > layout.right.size()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,9 +340,9 @@ AbstractButton *TitleControls::controlWidget(Control control) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleControls::updateControlsPosition() {
|
void TitleControls::updateControlsPosition() {
|
||||||
const auto controlsLayout = TitleControlsLayout();
|
auto controlsLayout = TitleControlsLayout();
|
||||||
auto controlsLeft = controlsLayout.left;
|
auto &controlsLeft = controlsLayout.left;
|
||||||
auto controlsRight = controlsLayout.right;
|
auto &controlsRight = controlsLayout.right;
|
||||||
const auto moveFromTo = [&](auto &from, auto &to) {
|
const auto moveFromTo = [&](auto &from, auto &to) {
|
||||||
for (const auto control : from) {
|
for (const auto control : from) {
|
||||||
if (!ranges::contains(to, control)) {
|
if (!ranges::contains(to, control)) {
|
||||||
|
|
@ -351,11 +351,7 @@ void TitleControls::updateControlsPosition() {
|
||||||
}
|
}
|
||||||
from.clear();
|
from.clear();
|
||||||
};
|
};
|
||||||
if (ranges::contains(controlsLeft, Control::Close)) {
|
if (TitleControlsOnLeft(controlsLayout)) {
|
||||||
moveFromTo(controlsRight, controlsLeft);
|
|
||||||
} else if (ranges::contains(controlsRight, Control::Close)) {
|
|
||||||
moveFromTo(controlsLeft, controlsRight);
|
|
||||||
} else if (controlsLeft.size() > controlsRight.size()) {
|
|
||||||
moveFromTo(controlsRight, controlsLeft);
|
moveFromTo(controlsRight, controlsLeft);
|
||||||
} else {
|
} else {
|
||||||
moveFromTo(controlsLeft, controlsRight);
|
moveFromTo(controlsLeft, controlsRight);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue