tdesktop/Telegram/SourceFiles/window/themes/window_themes_embedded.h

91 lines
2.0 KiB
C
Raw Normal View History

2019-08-23 13:52:59 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "lang/lang_keys.h"
class QImage;
namespace Window {
namespace Theme {
enum class EmbeddedType {
DayBlue,
Default,
Night,
NightGreen,
};
struct EmbeddedScheme {
EmbeddedType type = EmbeddedType();
QColor background;
QColor sent;
QColor received;
QColor radiobuttonInactive;
QColor radiobuttonActive;
tr::phrase<> name;
QString path;
QColor accentColor;
};
class AccentColors final {
public:
[[nodiscard]] QByteArray serialize() const;
bool setFromSerialized(const QByteArray &serialized);
void set(EmbeddedType type, const QColor &value);
void clear(EmbeddedType type);
[[nodiscard]] std::optional<QColor> get(EmbeddedType type) const;
private:
base::flat_map<EmbeddedType, QColor> _data;
};
struct Colorizer {
2019-08-26 14:08:33 +00:00
struct Color {
int hue = 0;
int saturation = 0;
2019-08-27 14:44:51 +00:00
int value = 0;
2019-08-26 14:08:33 +00:00
};
2019-08-23 13:52:59 +00:00
int hueThreshold = 0;
2019-08-26 18:35:51 +00:00
int lightnessMin = 0;
int lightnessMax = 255;
2019-08-26 14:08:33 +00:00
Color was;
Color now;
2019-08-23 13:52:59 +00:00
base::flat_set<QLatin1String> ignoreKeys;
2019-08-27 13:59:15 +00:00
base::flat_map<QLatin1String, std::pair<Color, Color>> keepContrast;
explicit operator bool() const {
return (hueThreshold > 0);
}
2019-08-23 13:52:59 +00:00
};
[[nodiscard]] Colorizer ColorizerFrom(
const EmbeddedScheme &scheme,
const QColor &color);
2019-08-27 13:59:15 +00:00
[[nodiscard]] Colorizer ColorizerForTheme(const QString &absolutePath);
2019-08-23 13:52:59 +00:00
2019-08-27 13:59:15 +00:00
void Colorize(uchar &r, uchar &g, uchar &b, const Colorizer &colorizer);
2019-08-23 13:52:59 +00:00
void Colorize(
2019-08-27 13:59:15 +00:00
QLatin1String name,
2019-08-23 13:52:59 +00:00
uchar &r,
uchar &g,
uchar &b,
2019-08-27 13:59:15 +00:00
const Colorizer &colorizer);
void Colorize(QImage &image, const Colorizer &colorizer);
void Colorize(EmbeddedScheme &scheme, const Colorizer &colorizer);
2019-08-26 16:36:23 +00:00
[[nodiscard]] QByteArray Colorize(
QLatin1String hexColor,
2019-08-27 13:59:15 +00:00
const Colorizer &colorizer);
2019-08-23 13:52:59 +00:00
[[nodiscard]] std::vector<EmbeddedScheme> EmbeddedThemes();
[[nodiscard]] std::vector<QColor> DefaultAccentColors(EmbeddedType type);
} // namespace Theme
} // namespace Window