chat_style.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/cached_round_corners.h"
  9. #include "ui/chat/message_bubble.h"
  10. #include "ui/chat/chat_style_radius.h"
  11. #include "ui/controls/swipe_handler_data.h"
  12. #include "ui/style/style_core_palette.h"
  13. #include "layout/layout_selection.h"
  14. #include "styles/style_basic.h"
  15. enum class ImageRoundRadius;
  16. namespace style {
  17. struct TwoIconButton;
  18. struct ScrollArea;
  19. } // namespace style
  20. namespace Ui::Text {
  21. class CustomEmoji;
  22. } // namespace Ui::Text
  23. namespace Ui {
  24. class ChatTheme;
  25. class ChatStyle;
  26. struct BubblePattern;
  27. inline constexpr auto kColorPatternsCount = Text::kMaxQuoteOutlines;
  28. inline constexpr auto kColorIndexCount = uint8(1 << 6);
  29. inline constexpr auto kSimpleColorIndexCount = uint8(7);
  30. inline constexpr auto kDefaultBgOpacity = 0.12;
  31. inline constexpr auto kDefaultOutline1Opacity = 0.9;
  32. inline constexpr auto kDefaultOutline2Opacity = 0.3;
  33. inline constexpr auto kDefaultOutline3Opacity = 0.6;
  34. inline constexpr auto kDefaultOutlineOpacitySecond = 0.5;
  35. struct MessageStyle {
  36. CornersPixmaps msgBgCornersSmall;
  37. CornersPixmaps msgBgCornersLarge;
  38. style::color msgBg;
  39. style::color msgShadow;
  40. style::color msgServiceFg;
  41. style::color msgDateFg;
  42. style::color msgFileThumbLinkFg;
  43. style::color msgFileBg;
  44. style::color msgReplyBarColor;
  45. style::color msgWaveformActive;
  46. style::color msgWaveformInactive;
  47. style::color historyTextFg;
  48. style::color historyFileNameFg;
  49. style::color historyFileRadialFg;
  50. style::color mediaFg;
  51. style::TextPalette textPalette;
  52. style::TextPalette semiboldPalette;
  53. style::TextPalette fwdTextPalette;
  54. style::TextPalette replyTextPalette;
  55. style::icon tailLeft = { Qt::Uninitialized };
  56. style::icon tailRight = { Qt::Uninitialized };
  57. style::icon historyRepliesIcon = { Qt::Uninitialized };
  58. style::icon historyViewsIcon = { Qt::Uninitialized };
  59. style::icon historyPinIcon = { Qt::Uninitialized };
  60. style::icon historySentIcon = { Qt::Uninitialized };
  61. style::icon historyReceivedIcon = { Qt::Uninitialized };
  62. style::icon historyPsaIcon = { Qt::Uninitialized };
  63. style::icon historyCommentsOpen = { Qt::Uninitialized };
  64. style::icon historyComments = { Qt::Uninitialized };
  65. style::icon historyCallArrow = { Qt::Uninitialized };
  66. style::icon historyCallArrowMissed = { Qt::Uninitialized };
  67. style::icon historyCallIcon = { Qt::Uninitialized };
  68. style::icon historyCallCameraIcon = { Qt::Uninitialized };
  69. style::icon historyFilePlay = { Qt::Uninitialized };
  70. style::icon historyFileWaiting = { Qt::Uninitialized };
  71. style::icon historyFileDownload = { Qt::Uninitialized };
  72. style::icon historyFileCancel = { Qt::Uninitialized };
  73. style::icon historyFilePause = { Qt::Uninitialized };
  74. style::icon historyFileImage = { Qt::Uninitialized };
  75. style::icon historyFileDocument = { Qt::Uninitialized };
  76. style::icon historyAudioDownload = { Qt::Uninitialized };
  77. style::icon historyAudioCancel = { Qt::Uninitialized };
  78. style::icon historyQuizTimer = { Qt::Uninitialized };
  79. style::icon historyQuizExplain = { Qt::Uninitialized };
  80. style::icon historyPollChosen = { Qt::Uninitialized };
  81. style::icon historyPollChoiceRight = { Qt::Uninitialized };
  82. style::icon historyTranscribeIcon = { Qt::Uninitialized };
  83. style::icon historyTranscribeLock = { Qt::Uninitialized };
  84. style::icon historyTranscribeHide = { Qt::Uninitialized };
  85. style::icon historyVoiceMessageTTL = { Qt::Uninitialized };
  86. style::icon liveLocationLongIcon = { Qt::Uninitialized };
  87. std::array<
  88. std::unique_ptr<Text::QuotePaintCache>,
  89. kColorPatternsCount> quoteCache;
  90. std::array<
  91. std::unique_ptr<Text::QuotePaintCache>,
  92. kColorPatternsCount> replyCache;
  93. std::unique_ptr<Text::QuotePaintCache> preCache;
  94. };
  95. struct MessageImageStyle {
  96. CornersPixmaps msgDateImgBgCorners;
  97. CornersPixmaps msgServiceBgCornersSmall;
  98. CornersPixmaps msgServiceBgCornersLarge;
  99. CornersPixmaps msgShadowCornersSmall;
  100. CornersPixmaps msgShadowCornersLarge;
  101. style::color msgServiceBg;
  102. style::color msgDateImgBg;
  103. style::color msgShadow;
  104. style::color historyFileThumbRadialFg;
  105. style::icon historyFileThumbPlay = { Qt::Uninitialized };
  106. style::icon historyFileThumbWaiting = { Qt::Uninitialized };
  107. style::icon historyFileThumbDownload = { Qt::Uninitialized };
  108. style::icon historyFileThumbCancel = { Qt::Uninitialized };
  109. style::icon historyFileThumbPause = { Qt::Uninitialized };
  110. style::icon historyVideoDownload = { Qt::Uninitialized };
  111. style::icon historyVideoCancel = { Qt::Uninitialized };
  112. style::icon historyVideoMessageMute = { Qt::Uninitialized };
  113. style::icon historyVideoMessageTtlIcon = { Qt::Uninitialized };
  114. style::icon historyPageEnlarge = { Qt::Uninitialized };
  115. };
  116. struct ReactionPaintInfo {
  117. QPoint position;
  118. QPoint effectOffset;
  119. Fn<QRect(QPainter&)> effectPaint;
  120. };
  121. struct BackgroundEmojiCache {
  122. QColor color;
  123. std::array<QImage, 3> frames;
  124. };
  125. struct BackgroundEmojiData {
  126. std::unique_ptr<Text::CustomEmoji> emoji;
  127. QImage firstFrameMask;
  128. std::array<BackgroundEmojiCache, 2 * (3 + kColorIndexCount)> caches;
  129. [[nodiscard]] static int CacheIndex(
  130. bool selected,
  131. bool outbg,
  132. bool inbubble,
  133. uint8 colorIndexPlusOne);
  134. };
  135. struct ChatPaintHighlight {
  136. float64 opacity = 0.;
  137. float64 collapsion = 0.;
  138. TextSelection range;
  139. };
  140. struct ChatPaintContext {
  141. not_null<const ChatStyle*> st;
  142. const BubblePattern *bubblesPattern = nullptr;
  143. ReactionPaintInfo *reactionInfo = nullptr;
  144. QRect viewport;
  145. QRect clip;
  146. TextSelection selection;
  147. ChatPaintHighlight highlight;
  148. QPainterPath *highlightPathCache = nullptr;
  149. mutable QRect highlightInterpolateTo;
  150. crl::time now = 0;
  151. Ui::Controls::SwipeContextData gestureHorizontal;
  152. void translate(int x, int y) {
  153. viewport.translate(x, y);
  154. clip.translate(x, y);
  155. highlightInterpolateTo.translate(x, y);
  156. }
  157. void translate(QPoint point) {
  158. translate(point.x(), point.y());
  159. }
  160. [[nodiscard]] bool selected() const {
  161. return (selection == FullSelection);
  162. }
  163. [[nodiscard]] not_null<const MessageStyle*> messageStyle() const;
  164. [[nodiscard]] not_null<const MessageImageStyle*> imageStyle() const;
  165. [[nodiscard]] not_null<Text::QuotePaintCache*> quoteCache(
  166. uint8 colorIndex) const;
  167. [[nodiscard]] ChatPaintContext translated(int x, int y) const {
  168. auto result = *this;
  169. result.translate(x, y);
  170. return result;
  171. }
  172. [[nodiscard]] ChatPaintContext translated(QPoint point) const {
  173. return translated(point.x(), point.y());
  174. }
  175. [[nodiscard]] ChatPaintContext withSelection(
  176. TextSelection selection) const {
  177. auto result = *this;
  178. result.selection = selection;
  179. return result;
  180. }
  181. [[nodiscard]] auto computeHighlightCache() const
  182. -> std::optional<Ui::Text::HighlightInfoRequest> {
  183. if (highlight.range.empty() || highlight.collapsion <= 0.) {
  184. return {};
  185. }
  186. return Ui::Text::HighlightInfoRequest{
  187. .range = highlight.range,
  188. .interpolateTo = highlightInterpolateTo,
  189. .interpolateProgress = (1. - highlight.collapsion),
  190. .outPath = highlightPathCache,
  191. };
  192. };
  193. // This is supported only in unwrapped media for now.
  194. enum class SkipDrawingParts {
  195. None,
  196. Content,
  197. Surrounding,
  198. };
  199. SkipDrawingParts skipDrawingParts = SkipDrawingParts::None;
  200. bool outbg = false;
  201. bool paused = false;
  202. };
  203. struct ChatPaintContextArgs {
  204. not_null<ChatTheme*> theme;
  205. QRect clip;
  206. QPoint visibleAreaPositionGlobal;
  207. int visibleAreaTop = 0;
  208. int visibleAreaWidth = 0;
  209. };
  210. [[nodiscard]] int HistoryServiceMsgRadius();
  211. [[nodiscard]] int HistoryServiceMsgInvertedRadius();
  212. [[nodiscard]] int HistoryServiceMsgInvertedShrink();
  213. struct ColorIndexData {
  214. std::array<uint32, kColorPatternsCount> light = {};
  215. std::array<uint32, kColorPatternsCount> dark = {};
  216. friend inline bool operator==(
  217. const ColorIndexData&,
  218. const ColorIndexData&) = default;
  219. };
  220. struct ColorIndicesCompressed {
  221. std::shared_ptr<std::array<ColorIndexData, kColorIndexCount>> colors;
  222. };
  223. [[nodiscard]] int ColorPatternIndex(
  224. const ColorIndicesCompressed &indices,
  225. uint8 colorIndex,
  226. bool dark);
  227. struct ColorIndexValues {
  228. std::array<QColor, kColorPatternsCount> outlines;
  229. QColor name;
  230. QColor bg;
  231. };
  232. [[nodiscard]] ColorIndexValues SimpleColorIndexValues(
  233. QColor color,
  234. int patternIndex);
  235. class ChatStyle final : public style::palette {
  236. public:
  237. explicit ChatStyle(rpl::producer<ColorIndicesCompressed> colorIndices);
  238. explicit ChatStyle(not_null<const style::palette*> isolated);
  239. ChatStyle(const ChatStyle &other) = delete;
  240. ChatStyle &operator=(const ChatStyle &other) = delete;
  241. ~ChatStyle();
  242. void apply(not_null<ChatTheme*> theme);
  243. void applyCustomPalette(const style::palette *palette);
  244. void applyAdjustedServiceBg(QColor serviceBg);
  245. [[nodiscard]] bool dark() const {
  246. return _dark;
  247. }
  248. [[nodiscard]] std::span<Text::SpecialColor> highlightColors() const;
  249. [[nodiscard]] rpl::producer<> paletteChanged() const {
  250. return _paletteChanged.events();
  251. }
  252. template <typename Type>
  253. [[nodiscard]] Type value(const Type &original) const {
  254. auto my = Type();
  255. make(my, original);
  256. return my;
  257. }
  258. template <typename Type>
  259. [[nodiscard]] const Type &value(
  260. rpl::lifetime &parentLifetime,
  261. const Type &original) const {
  262. const auto my = parentLifetime.make_state<Type>();
  263. make(*my, original);
  264. return *my;
  265. }
  266. [[nodiscard]] const CornersPixmaps &serviceBgCornersNormal() const;
  267. [[nodiscard]] const CornersPixmaps &serviceBgCornersInverted() const;
  268. [[nodiscard]] const MessageStyle &messageStyle(
  269. bool outbg,
  270. bool selected) const;
  271. [[nodiscard]] const MessageImageStyle &imageStyle(bool selected) const;
  272. [[nodiscard]] int colorPatternIndex(uint8 colorIndex) const;
  273. [[nodiscard]] ColorIndexValues computeColorIndexValues(
  274. bool selected,
  275. uint8 colorIndex) const;
  276. [[nodiscard]] auto serviceQuoteCache(bool twoColored) const
  277. -> not_null<Text::QuotePaintCache*>;
  278. [[nodiscard]] auto serviceReplyCache(bool twoColored) const
  279. -> not_null<Text::QuotePaintCache*>;
  280. [[nodiscard]] const ColorIndexValues &coloredValues(
  281. bool selected,
  282. uint8 colorIndex) const;
  283. [[nodiscard]] not_null<Text::QuotePaintCache*> coloredQuoteCache(
  284. bool selected,
  285. uint8 colorIndex) const;
  286. [[nodiscard]] not_null<Text::QuotePaintCache*> coloredReplyCache(
  287. bool selected,
  288. uint8 colorIndex) const;
  289. [[nodiscard]] const style::TextPalette &coloredTextPalette(
  290. bool selected,
  291. uint8 colorIndex) const;
  292. [[nodiscard]] not_null<BackgroundEmojiData*> backgroundEmojiData(
  293. uint64 id) const;
  294. [[nodiscard]] const CornersPixmaps &msgBotKbOverBgAddCornersSmall() const;
  295. [[nodiscard]] const CornersPixmaps &msgBotKbOverBgAddCornersLarge() const;
  296. [[nodiscard]] const CornersPixmaps &msgSelectOverlayCorners(
  297. CachedCornerRadius radius) const;
  298. [[nodiscard]] const style::TextPalette &historyPsaForwardPalette() const {
  299. return _historyPsaForwardPalette;
  300. }
  301. [[nodiscard]] const style::TextPalette &imgReplyTextPalette() const {
  302. return _imgReplyTextPalette;
  303. }
  304. [[nodiscard]] const style::TextPalette &serviceTextPalette() const {
  305. return _serviceTextPalette;
  306. }
  307. [[nodiscard]] const style::TextPalette &priceTagTextPalette() const {
  308. return _priceTagTextPalette;
  309. }
  310. [[nodiscard]] const style::icon &historyRepliesInvertedIcon() const {
  311. return _historyRepliesInvertedIcon;
  312. }
  313. [[nodiscard]] const style::icon &historyViewsInvertedIcon() const {
  314. return _historyViewsInvertedIcon;
  315. }
  316. [[nodiscard]] const style::icon &historyViewsSendingIcon() const {
  317. return _historyViewsSendingIcon;
  318. }
  319. [[nodiscard]] const style::icon &historyViewsSendingInvertedIcon() const {
  320. return _historyViewsSendingInvertedIcon;
  321. }
  322. [[nodiscard]] const style::icon &historyPinInvertedIcon() const {
  323. return _historyPinInvertedIcon;
  324. }
  325. [[nodiscard]] const style::icon &historySendingIcon() const {
  326. return _historySendingIcon;
  327. }
  328. [[nodiscard]] const style::icon &historySendingInvertedIcon() const {
  329. return _historySendingInvertedIcon;
  330. }
  331. [[nodiscard]] const style::icon &historySentInvertedIcon() const {
  332. return _historySentInvertedIcon;
  333. }
  334. [[nodiscard]] const style::icon &historyReceivedInvertedIcon() const {
  335. return _historyReceivedInvertedIcon;
  336. }
  337. [[nodiscard]] const style::icon &msgBotKbUrlIcon() const {
  338. return _msgBotKbUrlIcon;
  339. }
  340. [[nodiscard]] const style::icon &msgBotKbPaymentIcon() const {
  341. return _msgBotKbPaymentIcon;
  342. }
  343. [[nodiscard]] const style::icon &msgBotKbSwitchPmIcon() const {
  344. return _msgBotKbSwitchPmIcon;
  345. }
  346. [[nodiscard]] const style::icon &msgBotKbWebviewIcon() const {
  347. return _msgBotKbWebviewIcon;
  348. }
  349. [[nodiscard]] const style::icon &msgBotKbCopyIcon() const {
  350. return _msgBotKbCopyIcon;
  351. }
  352. [[nodiscard]] const style::icon &historyFastCommentsIcon() const {
  353. return _historyFastCommentsIcon;
  354. }
  355. [[nodiscard]] const style::icon &historyFastShareIcon() const {
  356. return _historyFastShareIcon;
  357. }
  358. [[nodiscard]] const style::icon &historyFastTranscribeIcon() const {
  359. return _historyFastTranscribeIcon;
  360. }
  361. [[nodiscard]] const style::icon &historyFastTranscribeLock() const {
  362. return _historyFastTranscribeLock;
  363. }
  364. [[nodiscard]] const style::icon &historyGoToOriginalIcon() const {
  365. return _historyGoToOriginalIcon;
  366. }
  367. [[nodiscard]] const style::icon &historyFastCloseIcon() const {
  368. return _historyFastCloseIcon;
  369. }
  370. [[nodiscard]] const style::icon &historyFastMoreIcon() const {
  371. return _historyFastMoreIcon;
  372. }
  373. [[nodiscard]] const style::icon &historyMapPoint() const {
  374. return _historyMapPoint;
  375. }
  376. [[nodiscard]] const style::icon &historyMapPointInner() const {
  377. return _historyMapPointInner;
  378. }
  379. [[nodiscard]] const style::icon &youtubeIcon() const {
  380. return _youtubeIcon;
  381. }
  382. [[nodiscard]] const style::icon &videoIcon() const {
  383. return _videoIcon;
  384. }
  385. [[nodiscard]] const style::icon &historyPollChoiceRight() const {
  386. return _historyPollChoiceRight;
  387. }
  388. [[nodiscard]] const style::icon &historyPollChoiceWrong() const {
  389. return _historyPollChoiceWrong;
  390. }
  391. private:
  392. using ColoredQuotePaintCaches = std::array<
  393. std::unique_ptr<Text::QuotePaintCache>,
  394. kColorIndexCount * 2>;
  395. struct ColoredPalette {
  396. std::optional<style::owned_color> linkFg;
  397. style::TextPalette data;
  398. };
  399. void assignPalette(not_null<const style::palette*> palette);
  400. void clearColorIndexCaches();
  401. void updateDarkValue();
  402. [[nodiscard]] not_null<Text::QuotePaintCache*> coloredCache(
  403. ColoredQuotePaintCaches &caches,
  404. bool selected,
  405. uint8 colorIndex) const;
  406. void make(style::color &my, const style::color &original) const;
  407. void make(style::icon &my, const style::icon &original) const;
  408. void make(
  409. style::TextPalette &my,
  410. const style::TextPalette &original) const;
  411. void make(
  412. style::TwoIconButton &my,
  413. const style::TwoIconButton &original) const;
  414. void make(
  415. style::ScrollArea &my,
  416. const style::ScrollArea &original) const;
  417. [[nodiscard]] MessageStyle &messageStyleRaw(
  418. bool outbg,
  419. bool selected) const;
  420. [[nodiscard]] MessageStyle &messageIn();
  421. [[nodiscard]] MessageStyle &messageInSelected();
  422. [[nodiscard]] MessageStyle &messageOut();
  423. [[nodiscard]] MessageStyle &messageOutSelected();
  424. [[nodiscard]] MessageImageStyle &imageStyleRaw(bool selected) const;
  425. [[nodiscard]] MessageImageStyle &image();
  426. [[nodiscard]] MessageImageStyle &imageSelected();
  427. template <typename Type>
  428. void make(
  429. Type MessageStyle::*my,
  430. const Type &originalIn,
  431. const Type &originalInSelected,
  432. const Type &originalOut,
  433. const Type &originalOutSelected);
  434. template <typename Type>
  435. void make(
  436. Type MessageImageStyle::*my,
  437. const Type &original,
  438. const Type &originalSelected);
  439. mutable CornersPixmaps _serviceBgCornersNormal;
  440. mutable CornersPixmaps _serviceBgCornersInverted;
  441. mutable std::array<MessageStyle, 4> _messageStyles;
  442. mutable std::array<MessageImageStyle, 2> _imageStyles;
  443. mutable CornersPixmaps _msgBotKbOverBgAddCornersSmall;
  444. mutable CornersPixmaps _msgBotKbOverBgAddCornersLarge;
  445. mutable CornersPixmaps _msgSelectOverlayCorners[
  446. int(CachedCornerRadius::kCount)];
  447. mutable std::vector<Text::SpecialColor> _highlightColors;
  448. mutable std::array<
  449. std::unique_ptr<Text::QuotePaintCache>,
  450. 2> _serviceQuoteCache;
  451. mutable std::array<
  452. std::unique_ptr<Text::QuotePaintCache>,
  453. 2> _serviceReplyCache;
  454. mutable std::array<
  455. std::optional<ColorIndexValues>,
  456. 2 * kColorIndexCount> _coloredValues;
  457. mutable ColoredQuotePaintCaches _coloredQuoteCaches;
  458. mutable ColoredQuotePaintCaches _coloredReplyCaches;
  459. mutable std::array<
  460. ColoredPalette,
  461. 2 * kColorIndexCount> _coloredTextPalettes;
  462. mutable base::flat_map<uint64, BackgroundEmojiData> _backgroundEmojis;
  463. style::TextPalette _historyPsaForwardPalette;
  464. style::TextPalette _imgReplyTextPalette;
  465. style::TextPalette _serviceTextPalette;
  466. style::TextPalette _priceTagTextPalette;
  467. style::icon _historyRepliesInvertedIcon = { Qt::Uninitialized };
  468. style::icon _historyViewsInvertedIcon = { Qt::Uninitialized };
  469. style::icon _historyViewsSendingIcon = { Qt::Uninitialized };
  470. style::icon _historyViewsSendingInvertedIcon = { Qt::Uninitialized };
  471. style::icon _historyPinInvertedIcon = { Qt::Uninitialized };
  472. style::icon _historySendingIcon = { Qt::Uninitialized };
  473. style::icon _historySendingInvertedIcon = { Qt::Uninitialized };
  474. style::icon _historySentInvertedIcon = { Qt::Uninitialized };
  475. style::icon _historyReceivedInvertedIcon = { Qt::Uninitialized };
  476. style::icon _msgBotKbUrlIcon = { Qt::Uninitialized };
  477. style::icon _msgBotKbPaymentIcon = { Qt::Uninitialized };
  478. style::icon _msgBotKbSwitchPmIcon = { Qt::Uninitialized };
  479. style::icon _msgBotKbWebviewIcon = { Qt::Uninitialized };
  480. style::icon _msgBotKbCopyIcon = { Qt::Uninitialized };
  481. style::icon _historyFastCommentsIcon = { Qt::Uninitialized };
  482. style::icon _historyFastShareIcon = { Qt::Uninitialized };
  483. style::icon _historyFastMoreIcon = { Qt::Uninitialized };
  484. style::icon _historyFastTranscribeIcon = { Qt::Uninitialized };
  485. style::icon _historyFastTranscribeLock = { Qt::Uninitialized };
  486. style::icon _historyGoToOriginalIcon = { Qt::Uninitialized };
  487. style::icon _historyFastCloseIcon = { Qt::Uninitialized };
  488. style::icon _historyMapPoint = { Qt::Uninitialized };
  489. style::icon _historyMapPointInner = { Qt::Uninitialized };
  490. style::icon _youtubeIcon = { Qt::Uninitialized };
  491. style::icon _videoIcon = { Qt::Uninitialized };
  492. style::icon _historyPollChoiceRight = { Qt::Uninitialized };
  493. style::icon _historyPollChoiceWrong = { Qt::Uninitialized };
  494. ColorIndicesCompressed _colorIndices;
  495. bool _dark = false;
  496. rpl::event_stream<> _paletteChanged;
  497. rpl::lifetime _defaultPaletteChangeLifetime;
  498. rpl::lifetime _colorIndicesLifetime;
  499. };
  500. [[nodiscard]] uint8 DecideColorIndex(uint64 id);
  501. [[nodiscard]] uint8 ColorIndexToPaletteIndex(uint8 colorIndex);
  502. [[nodiscard]] QColor FromNameFg(
  503. not_null<const ChatStyle*> st,
  504. bool selected,
  505. uint8 colorIndex);
  506. [[nodiscard]] inline QColor FromNameFg(
  507. const ChatPaintContext &context,
  508. uint8 colorIndex) {
  509. return FromNameFg(context.st, context.selected(), colorIndex);
  510. }
  511. void FillComplexOverlayRect(
  512. QPainter &p,
  513. QRect rect,
  514. const style::color &color,
  515. const CornersPixmaps &corners);
  516. void FillComplexEllipse(
  517. QPainter &p,
  518. not_null<const ChatStyle*> st,
  519. QRect rect);
  520. } // namespace Ui