2019-05-10 16:58:44 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2019-05-10 16:58:44 +02:00
|
|
|
//
|
|
|
|
// 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/BackgroundType.h"
|
|
|
|
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
2021-06-10 00:29:42 +02:00
|
|
|
void BackgroundType::store(StorerT &storer) const {
|
|
|
|
using td::store;
|
2021-06-10 00:44:46 +02:00
|
|
|
bool has_fill = fill_.top_color_ != 0 || fill_.bottom_color_ != 0;
|
|
|
|
bool has_intensity = intensity_ != 0;
|
|
|
|
auto fill_type = fill_.get_type();
|
2021-05-20 01:21:20 +02:00
|
|
|
bool is_gradient = fill_type == BackgroundFill::Type::Gradient;
|
2021-05-21 00:49:59 +02:00
|
|
|
bool is_freeform_gradient = fill_type == BackgroundFill::Type::FreeformGradient;
|
2023-12-19 14:00:50 +01:00
|
|
|
bool has_theme_name = !theme_name_.empty();
|
2019-05-10 16:58:44 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
2021-06-10 00:44:46 +02:00
|
|
|
STORE_FLAG(is_blurred_);
|
|
|
|
STORE_FLAG(is_moving_);
|
2019-12-22 19:01:51 +01:00
|
|
|
STORE_FLAG(has_fill);
|
2019-05-10 16:58:44 +02:00
|
|
|
STORE_FLAG(has_intensity);
|
2019-12-22 19:01:51 +01:00
|
|
|
STORE_FLAG(is_gradient);
|
2021-05-21 00:49:59 +02:00
|
|
|
STORE_FLAG(is_freeform_gradient);
|
2023-12-19 14:00:50 +01:00
|
|
|
STORE_FLAG(has_theme_name);
|
2019-05-10 16:58:44 +02:00
|
|
|
END_STORE_FLAGS();
|
2021-06-10 00:44:46 +02:00
|
|
|
store(type_, storer);
|
2021-05-21 00:49:59 +02:00
|
|
|
if (is_freeform_gradient) {
|
2021-06-10 00:44:46 +02:00
|
|
|
store(fill_.top_color_, storer);
|
|
|
|
store(fill_.bottom_color_, storer);
|
|
|
|
store(fill_.third_color_, storer);
|
|
|
|
store(fill_.fourth_color_, storer);
|
2021-05-21 00:49:59 +02:00
|
|
|
} else if (has_fill) {
|
2021-06-10 00:44:46 +02:00
|
|
|
store(fill_.top_color_, storer);
|
2019-12-22 19:01:51 +01:00
|
|
|
if (is_gradient) {
|
2021-06-10 00:44:46 +02:00
|
|
|
store(fill_.bottom_color_, storer);
|
|
|
|
store(fill_.rotation_angle_, storer);
|
2019-12-22 19:01:51 +01:00
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
if (has_intensity) {
|
2021-06-10 00:44:46 +02:00
|
|
|
store(intensity_, storer);
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
2023-12-19 14:00:50 +01:00
|
|
|
if (has_theme_name) {
|
|
|
|
store(theme_name_, storer);
|
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
2021-06-10 00:29:42 +02:00
|
|
|
void BackgroundType::parse(ParserT &parser) {
|
|
|
|
using td::parse;
|
2019-12-22 19:01:51 +01:00
|
|
|
bool has_fill;
|
2019-05-10 16:58:44 +02:00
|
|
|
bool has_intensity;
|
2019-12-22 19:01:51 +01:00
|
|
|
bool is_gradient;
|
2021-05-21 00:49:59 +02:00
|
|
|
bool is_freeform_gradient;
|
2023-12-19 14:00:50 +01:00
|
|
|
bool has_theme_name;
|
2019-05-10 16:58:44 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
2021-06-10 00:44:46 +02:00
|
|
|
PARSE_FLAG(is_blurred_);
|
|
|
|
PARSE_FLAG(is_moving_);
|
2019-12-22 19:01:51 +01:00
|
|
|
PARSE_FLAG(has_fill);
|
2019-05-10 16:58:44 +02:00
|
|
|
PARSE_FLAG(has_intensity);
|
2019-12-22 19:01:51 +01:00
|
|
|
PARSE_FLAG(is_gradient);
|
2021-05-21 00:49:59 +02:00
|
|
|
PARSE_FLAG(is_freeform_gradient);
|
2023-12-19 14:00:50 +01:00
|
|
|
PARSE_FLAG(has_theme_name);
|
2019-05-10 16:58:44 +02:00
|
|
|
END_PARSE_FLAGS();
|
2021-06-10 00:44:46 +02:00
|
|
|
parse(type_, parser);
|
2021-05-21 00:49:59 +02:00
|
|
|
if (is_freeform_gradient) {
|
2021-06-10 00:44:46 +02:00
|
|
|
parse(fill_.top_color_, parser);
|
|
|
|
parse(fill_.bottom_color_, parser);
|
|
|
|
parse(fill_.third_color_, parser);
|
|
|
|
parse(fill_.fourth_color_, parser);
|
2021-05-21 00:49:59 +02:00
|
|
|
} else if (has_fill) {
|
2021-06-10 00:44:46 +02:00
|
|
|
parse(fill_.top_color_, parser);
|
2019-12-22 19:01:51 +01:00
|
|
|
if (is_gradient) {
|
2021-06-10 00:44:46 +02:00
|
|
|
parse(fill_.bottom_color_, parser);
|
|
|
|
parse(fill_.rotation_angle_, parser);
|
2019-12-22 19:01:51 +01:00
|
|
|
} else {
|
2021-06-10 00:44:46 +02:00
|
|
|
fill_.bottom_color_ = fill_.top_color_;
|
2019-12-22 19:01:51 +01:00
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
if (has_intensity) {
|
2021-06-10 00:44:46 +02:00
|
|
|
parse(intensity_, parser);
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
2023-12-19 14:00:50 +01:00
|
|
|
if (has_theme_name) {
|
|
|
|
parse(theme_name_, parser);
|
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|