Reuse lib_ui's title control side deduction code

This commit is contained in:
Ilya Fedin 2023-07-19 14:20:14 +04:00 committed by John Preston
parent f817df9d7f
commit d60d80ba63
2 changed files with 2 additions and 20 deletions

View File

@ -49,14 +49,6 @@ namespace {
constexpr auto kPipLoaderPriority = 2;
constexpr auto kMsInSecond = 1000;
[[nodiscard]] bool IsWindowControlsOnLeft() {
using Control = Ui::Platform::TitleControls::Control;
const auto controlsLayout = Ui::Platform::TitleControlsLayout();
return ranges::contains(controlsLayout.left, Control::Close)
|| (controlsLayout.left.size() > controlsLayout.right.size()
&& !ranges::contains(controlsLayout.right, Control::Close));
}
[[nodiscard]] QRect ScreenFromPosition(QPoint point) {
const auto screen = QGuiApplication::screenAt(point);
const auto use = screen ? screen : QGuiApplication::primaryScreen();
@ -1266,7 +1258,7 @@ void Pip::setupButtons() {
rect.y(),
volumeToggleWidth,
volumeToggleHeight);
if (!IsWindowControlsOnLeft()) {
if (!Ui::Platform::TitleControlsOnLeft()) {
_close.area.moveLeft(rect.x()
+ rect.width()
- (_close.area.x() - rect.x())

View File

@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/platform/ui_platform_window_title.h"
#include "ui/platform/ui_platform_utility.h"
#include "ui/widgets/rp_window.h"
#include "ui/abstract_button.h"
#include "styles/style_media_view.h"
@ -228,16 +227,7 @@ rpl::producer<bool> DefaultOverlayWidgetHelper::controlsSideRightValue() {
return TitleControlsLayoutValue(
) | rpl::map([=](const TitleControls::Layout &layout) {
// See TitleControls::updateControlsPosition.
if (ranges::contains(layout.left, TitleControl::Close)) {
return false;
} else if (ranges::contains(layout.right, TitleControl::Close)) {
return true;
} else if (layout.left.size() > layout.right.size()) {
return false;
} else {
return true;
}
return !TitleControlsOnLeft(layout);
}) | rpl::distinct_until_changed();
}