lib_ui/ui/platform/ui_platform_utility.cpp
Ilya Fedin b9aa8a17d4 Allow to pass new title controls layout value to notifier
In case the getter is trivial (has only one implementation)
2023-07-19 14:42:06 +04:00

42 lines
1.1 KiB
C++

// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include "ui/platform/ui_platform_utility.h"
namespace Ui {
namespace Platform {
namespace internal {
namespace {
auto &CachedTitleControlsLayout() {
using Layout = TitleControls::Layout;
static rpl::variable<Layout> Result = TitleControlsLayout();
return Result;
};
} // namespace
void NotifyTitleControlsLayoutChanged(
const std::optional<TitleControls::Layout> &layout) {
CachedTitleControlsLayout() = layout ? *layout : TitleControlsLayout();
}
} // namespace internal
TitleControls::Layout TitleControlsLayout() {
return internal::CachedTitleControlsLayout().current();
}
rpl::producer<TitleControls::Layout> TitleControlsLayoutValue() {
return internal::CachedTitleControlsLayout().value();
}
rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged() {
return internal::CachedTitleControlsLayout().changes();
}
} // namespace Platform
} // namespace Ui