Remove public get_color_hex_string method.

GitOrigin-RevId: cfc3100b814766410fadc6749522457f7e5ad514
This commit is contained in:
levlam 2019-12-22 04:42:22 +03:00
parent 8be871bad7
commit e9bb8f2a29
3 changed files with 7 additions and 20 deletions

View File

@ -522,7 +522,7 @@ BackgroundId BackgroundManager::add_solid_background(int32 color, bool is_defaul
background.is_default = is_default; background.is_default = is_default;
background.is_dark = is_dark; background.is_dark = is_dark;
background.type = BackgroundType(color); background.type = BackgroundType(color);
background.name = background.type.get_color_hex_string(); background.name = background.type.get_link();
add_background(background); add_background(background);
return background_id; return background_id;
@ -546,7 +546,7 @@ BackgroundId BackgroundManager::add_gradient_background(const GradientInfo &grad
background.is_default = is_default; background.is_default = is_default;
background.is_dark = is_dark; background.is_dark = is_dark;
background.type = BackgroundType(gradient_info); background.type = BackgroundType(gradient_info);
background.name = gradient_info.get_colors_hex_string(); background.name = background.type.get_link();
add_background(background); add_background(background);
return background_id; return background_id;

View File

@ -10,7 +10,7 @@
namespace td { namespace td {
string get_color_hex_string(int32 color) { static string get_color_hex_string(int32 color) {
string result; string result;
for (int i = 20; i >= 0; i -= 4) { for (int i = 20; i >= 0; i -= 4) {
result += "0123456789abcdef"[(color >> i) & 0xf]; result += "0123456789abcdef"[(color >> i) & 0xf];
@ -18,18 +18,10 @@ string get_color_hex_string(int32 color) {
return result; return result;
} }
string GradientInfo::get_colors_hex_string() const {
return PSTRING() << get_color_hex_string(top_color) << '-' << get_color_hex_string(bottom_color);
}
bool operator==(const GradientInfo &lhs, const GradientInfo &rhs) { bool operator==(const GradientInfo &lhs, const GradientInfo &rhs) {
return lhs.top_color == rhs.top_color && lhs.bottom_color == rhs.bottom_color; return lhs.top_color == rhs.top_color && lhs.bottom_color == rhs.bottom_color;
} }
string BackgroundType::get_color_hex_string() const {
return td::get_color_hex_string(color);
}
string BackgroundType::get_link() const { string BackgroundType::get_link() const {
string mode; string mode;
if (is_blurred) { if (is_blurred) {
@ -50,7 +42,7 @@ string BackgroundType::get_link() const {
return string(); return string();
} }
case BackgroundType::Type::Pattern: { case BackgroundType::Type::Pattern: {
string link = PSTRING() << "intensity=" << intensity << "&bg_color=" << get_color_hex_string(); string link = PSTRING() << "intensity=" << intensity << "&bg_color=" << get_color_hex_string(color);
if (!mode.empty()) { if (!mode.empty()) {
link += "&mode="; link += "&mode=";
link += mode; link += mode;
@ -58,9 +50,10 @@ string BackgroundType::get_link() const {
return link; return link;
} }
case BackgroundType::Type::Solid: case BackgroundType::Type::Solid:
return get_color_hex_string(); return get_color_hex_string(color);
case BackgroundType::Type::Gradient: case BackgroundType::Type::Gradient:
return gradient.get_colors_hex_string(); return PSTRING() << get_color_hex_string(gradient.top_color) << '-'
<< get_color_hex_string(gradient.bottom_color);
default: default:
UNREACHABLE(); UNREACHABLE();
return string(); return string();

View File

@ -15,8 +15,6 @@
namespace td { namespace td {
string get_color_hex_string(int32 color);
struct GradientInfo { struct GradientInfo {
int32 top_color = 0; int32 top_color = 0;
int32 bottom_color = 0; int32 bottom_color = 0;
@ -24,8 +22,6 @@ struct GradientInfo {
GradientInfo() = default; GradientInfo() = default;
GradientInfo(int32 top_color, int32 bottom_color) : top_color(top_color), bottom_color(bottom_color) { GradientInfo(int32 top_color, int32 bottom_color) : top_color(top_color), bottom_color(bottom_color) {
} }
string get_colors_hex_string() const;
}; };
bool operator==(const GradientInfo &lhs, const GradientInfo &rhs); bool operator==(const GradientInfo &lhs, const GradientInfo &rhs);
@ -56,8 +52,6 @@ struct BackgroundType {
} }
string get_link() const; string get_link() const;
string get_color_hex_string() const;
}; };
bool operator==(const BackgroundType &lhs, const BackgroundType &rhs); bool operator==(const BackgroundType &lhs, const BackgroundType &rhs);