Added bubble wrap for layer of userpic builder.
This commit is contained in:
parent
d2e940f1ff
commit
177b9140d5
|
@ -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<QRect> BubbleWrap::innerRectValue() const {
|
||||
return sizeValue() | rpl::map([](const QSize &s) {
|
||||
return Rect(s) - st::userpicBuilderEmojiBubblePadding;
|
||||
});
|
||||
}
|
||||
|
||||
not_null<BubbleWrap*> AddBubbleWrap(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QSize &size,
|
||||
Fn<not_null<const Ui::ChatStyle*>()> chatStyle) {
|
||||
const auto bubble = container->add(object_ptr<Ui::CenterWrap<BubbleWrap>>(
|
||||
container,
|
||||
object_ptr<BubbleWrap>(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
|
|
@ -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<QRect> innerRectValue() const;
|
||||
|
||||
};
|
||||
|
||||
not_null<BubbleWrap*> AddBubbleWrap(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QSize &size,
|
||||
Fn<not_null<const Ui::ChatStyle*>()> chatStyle);
|
||||
|
||||
} // namespace Ui
|
|
@ -8,3 +8,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
using "ui/basic.style";
|
||||
|
||||
userpicBuilderEmojiAccentColorSize: 30px;
|
||||
userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue