diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp new file mode 100644 index 0000000000..282d080402 --- /dev/null +++ b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.cpp @@ -0,0 +1,64 @@ +/* +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 +*/ +#include "info/userpic/info_userpic_bubble_wrap.h" + +#include "ui/chat/message_bubble.h" +#include "ui/rect.h" +#include "ui/wrap/padding_wrap.h" +#include "ui/wrap/vertical_layout.h" +#include "styles/style_info_userpic_builder.h" + +namespace Ui { + +QRect BubbleWrap::innerRect() const { + return rect() - st::userpicBuilderEmojiBubblePadding; +} + +rpl::producer BubbleWrap::innerRectValue() const { + return sizeValue() | rpl::map([](const QSize &s) { + return Rect(s) - st::userpicBuilderEmojiBubblePadding; + }); +} + +not_null AddBubbleWrap( + not_null container, + const QSize &size, + Fn()> chatStyle) { + const auto bubble = container->add(object_ptr>( + container, + object_ptr(container)))->entity(); + bubble->resize(size); + const auto rounding = BubbleRounding{ + .topLeft = BubbleCornerRounding::Small, + .topRight = BubbleCornerRounding::Small, + .bottomLeft = BubbleCornerRounding::Small, + .bottomRight = BubbleCornerRounding::Small, + }; + + bubble->paintRequest( + ) | rpl::start_with_next([=] { + auto p = QPainter(bubble); + const auto innerRect = bubble->innerRect(); + const auto args = SimpleBubble{ + .st = chatStyle(), + .geometry = innerRect, + .pattern = nullptr, + .patternViewport = innerRect, + .outerWidth = bubble->width(), + .selected = false, + .shadowed = true, + .outbg = false, + .rounding = rounding, + }; + PaintBubble(p, args); + }, bubble->lifetime()); + + return bubble; +} + +} // namespace Ui diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.h b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.h new file mode 100644 index 0000000000..a835e34079 --- /dev/null +++ b/Telegram/SourceFiles/info/userpic/info_userpic_bubble_wrap.h @@ -0,0 +1,31 @@ +/* +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 "ui/rp_widget.h" + +namespace Ui { + +class ChatStyle; +class VerticalLayout; + +class BubbleWrap final : public Ui::RpWidget { +public: + using Ui::RpWidget::RpWidget; + + [[nodiscard]] QRect innerRect() const; + [[nodiscard]] rpl::producer innerRectValue() const; + +}; + +not_null AddBubbleWrap( + not_null container, + const QSize &size, + Fn()> chatStyle); + +} // namespace Ui diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_builder.style b/Telegram/SourceFiles/info/userpic/info_userpic_builder.style index 0dddfbf4a2..0dee1aefeb 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_builder.style +++ b/Telegram/SourceFiles/info/userpic/info_userpic_builder.style @@ -8,3 +8,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL using "ui/basic.style"; userpicBuilderEmojiAccentColorSize: 30px; +userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px); diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index 09af2325d7..d216583544 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -95,6 +95,8 @@ PRIVATE info/profile/info_profile_icon.cpp info/profile/info_profile_icon.h + info/userpic/info_userpic_bubble_wrap.cpp + info/userpic/info_userpic_bubble_wrap.h info/userpic/info_userpic_colors_palette_chooser.cpp info/userpic/info_userpic_colors_palette_chooser.h