2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Colorize bubbles according to a custom chat theme.

This commit is contained in:
John Preston
2021-08-27 23:44:47 +03:00
parent 5de83ef30c
commit beff635e45
38 changed files with 479 additions and 165 deletions

View File

@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/calls_instance.h"
#include "base/unixtime.h"
#include "ui/chat/chat_theme.h"
#include "ui/chat/chat_style.h"
#include "ui/widgets/checkbox.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h"
@@ -633,7 +634,9 @@ rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionsDescription()
ForwardsPrivacyController::ForwardsPrivacyController(
not_null<Window::SessionController*> controller)
: SimpleElementDelegate(controller, [] {})
, _controller(controller) {
, _controller(controller)
, _chatStyle(std::make_unique<Ui::ChatStyle>()) {
_chatStyle->apply(controller->defaultChatTheme().get());
}
UserPrivacy::Key ForwardsPrivacyController::key() {
@@ -715,13 +718,11 @@ object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
rect);
Painter p(widget);
const auto context = HistoryView::PaintContext{
.st = style::main_palette::get(),
.bubblesPattern = nullptr,
.viewport = widget->rect(),
.clip = widget->rect(),
.now = crl::now(),
};
const auto theme = _controller->defaultChatTheme().get();
const auto context = theme->preparePaintContext(
_chatStyle.get(),
widget->rect(),
widget->rect());
p.translate(0, padding + view->marginBottom());
view->draw(p, context);

View File

@@ -16,6 +16,10 @@ namespace Window {
class SessionController;
} // namespace Window
namespace Ui {
class ChatStyle;
} // namespace Ui
namespace Settings {
class BlockedBoxController : public PeerListController {
@@ -193,6 +197,7 @@ private:
Option value);
const not_null<Window::SessionController*> _controller;
const std::unique_ptr<Ui::ChatStyle> _chatStyle;
};