tdlight/td/telegram/ThemeSettings.hpp

60 lines
1.6 KiB
C++
Raw Normal View History

2024-07-05 12:41:35 +02:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/ThemeSettings.h"
#include "td/telegram/BackgroundInfo.hpp"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void ThemeSettings::store(StorerT &storer) const {
2024-07-05 12:58:11 +02:00
bool has_message_accent_color = message_accent_color_ != accent_color_;
bool has_background = background_info_.is_valid();
2024-07-05 12:41:35 +02:00
BEGIN_STORE_FLAGS();
2024-07-05 12:58:11 +02:00
STORE_FLAG(animate_message_colors_);
2024-07-05 12:41:35 +02:00
STORE_FLAG(has_message_accent_color);
STORE_FLAG(has_background);
END_STORE_FLAGS();
2024-07-05 12:58:11 +02:00
td::store(accent_color_, storer);
2024-07-05 12:41:35 +02:00
if (has_message_accent_color) {
2024-07-05 12:58:11 +02:00
td::store(message_accent_color_, storer);
2024-07-05 12:41:35 +02:00
}
if (has_background) {
2024-07-05 12:58:11 +02:00
td::store(background_info_, storer);
2024-07-05 12:41:35 +02:00
}
2024-07-05 12:58:11 +02:00
td::store(base_theme_, storer);
td::store(message_colors_, storer);
2024-07-05 12:41:35 +02:00
}
template <class ParserT>
void ThemeSettings::parse(ParserT &parser) {
bool has_message_accent_color;
bool has_background;
BEGIN_PARSE_FLAGS();
2024-07-05 12:58:11 +02:00
PARSE_FLAG(animate_message_colors_);
2024-07-05 12:41:35 +02:00
PARSE_FLAG(has_message_accent_color);
PARSE_FLAG(has_background);
END_PARSE_FLAGS();
2024-07-05 12:58:11 +02:00
td::parse(accent_color_, parser);
2024-07-05 12:41:35 +02:00
if (has_message_accent_color) {
2024-07-05 12:58:11 +02:00
td::parse(message_accent_color_, parser);
2024-07-05 12:41:35 +02:00
} else {
2024-07-05 12:58:11 +02:00
message_accent_color_ = accent_color_;
2024-07-05 12:41:35 +02:00
}
if (has_background) {
2024-07-05 12:58:11 +02:00
td::parse(background_info_, parser);
2024-07-05 12:41:35 +02:00
}
2024-07-05 12:58:11 +02:00
td::parse(base_theme_, parser);
td::parse(message_colors_, parser);
2024-07-05 12:41:35 +02:00
}
} // namespace td