diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.cpp b/Telegram/SourceFiles/ui/chat/chat_theme.cpp index 868c9a9a4..67d93fa62 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_theme.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/chat/message_bubble.h" #include "ui/chat/chat_style.h" #include "ui/style/style_core_palette.h" +#include "ui/style/style_palette_colorizer.h" #include #include @@ -247,6 +248,7 @@ void ChatTheme::adjustPalette(const ChatThemeDescriptor &descriptor) { CountAverageColor(descriptor.bubblesData.colors)) : std::optional(); if (bubblesAccent) { + // First set hue/saturation the same for all those colors from accent. const auto by = *bubblesAccent; if (!overrideOutBg) { adjust(p.msgOutBg(), by); @@ -269,6 +271,18 @@ void ChatTheme::adjustPalette(const ChatThemeDescriptor &descriptor) { adjust(p.historyOutIconFg(), by); adjust(p.historyCallArrowOutFg(), by); adjust(p.historyFileOutIconFg(), by); + + // After make msgFileOutBg exact accent and adjust some others. + const auto colorizer = bubblesAccentColorizer(by); + adjust(p.msgOutServiceFg(), colorizer); + adjust(p.msgOutDateFg(), colorizer); + adjust(p.msgFileThumbLinkOutFg(), colorizer); + adjust(p.msgFileOutBg(), colorizer); + adjust(p.msgOutReplyBarColor(), colorizer); + adjust(p.msgWaveformOutActive(), colorizer); + adjust(p.msgWaveformOutInactive(), colorizer); + adjust(p.mediaOutFg(), colorizer); + adjust(p.historyLinkOutFg(), colorizer); } auto outBgColors = descriptor.bubblesData.colors; if (outBgColors.empty()) { @@ -321,6 +335,22 @@ void ChatTheme::adjustPalette(const ChatThemeDescriptor &descriptor) { } } +style::colorizer ChatTheme::bubblesAccentColorizer( + const QColor &accent) const { + const auto color = [](const QColor &value) { + auto hue = 0; + auto saturation = 0; + auto lightness = 0; + value.getHsv(&hue, &saturation, &lightness); + return style::colorizer::Color{ hue, saturation, lightness }; + }; + return { + .hueThreshold = 255, + .was = color(_palette->msgFileOutBg()->c), + .now = color(accent), + }; +} + void ChatTheme::set(const style::color &my, const QColor &color) { auto r = 0, g = 0, b = 0, a = 0; color.getRgb(&r, &g, &b, &a); @@ -331,6 +361,12 @@ void ChatTheme::adjust(const style::color &my, const QColor &by) { set(my, ThemeAdjustedColor(my->c, by)); } +void ChatTheme::adjust(const style::color &my, const style::colorizer &by) { + if (const auto adjusted = style::colorize(my->c, by)) { + set(my, *adjusted); + } +} + void ChatTheme::setBackground(ChatThemeBackground &&background) { _mutableBackground = std::move(background); _backgroundState = {}; diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.h b/Telegram/SourceFiles/ui/chat/chat_theme.h index 25a24cdc9..a6ee89a4f 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.h +++ b/Telegram/SourceFiles/ui/chat/chat_theme.h @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace style { class palette; +struct colorizer; } // namespace style namespace Ui { @@ -150,9 +151,12 @@ private: [[nodiscard]] bool readyForBackgroundRotation() const; void generateNextBackgroundRotation(); + [[nodiscard]] style::colorizer bubblesAccentColorizer( + const QColor &accent) const; void adjustPalette(const ChatThemeDescriptor &descriptor); void set(const style::color &my, const QColor &color); void adjust(const style::color &my, const QColor &by); + void adjust(const style::color &my, const style::colorizer &by); uint64 _id = 0; std::unique_ptr _palette; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 5b521d63a..246b947fa 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 5b521d63a424b9b2521c13785e5f264279c7ba2e +Subproject commit 246b947fa747a1fd54e0b4a58516e1b3a9465c1a