lib_ui/ui/platform/ui_platform_utility.cpp
Ilya Fedin 6abad69ca6 Cache title controls layout value
So it's not requested on every window width change and etc...
2023-07-04 15:44:46 +04:00

41 lines
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() {
CachedTitleControlsLayout() = 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