Moved out common structures for userpic emoji builder to single place.
This commit is contained in:
parent
9a717b885a
commit
2f7e4ae8fb
|
@ -859,6 +859,8 @@ PRIVATE
|
||||||
info/settings/info_settings_widget.h
|
info/settings/info_settings_widget.h
|
||||||
info/userpic/info_userpic_emoji_builder.cpp
|
info/userpic/info_userpic_emoji_builder.cpp
|
||||||
info/userpic/info_userpic_emoji_builder.h
|
info/userpic/info_userpic_emoji_builder.h
|
||||||
|
info/userpic/info_userpic_emoji_builder_common.cpp
|
||||||
|
info/userpic/info_userpic_emoji_builder_common.h
|
||||||
info/userpic/info_userpic_emoji_builder_menu_item.cpp
|
info/userpic/info_userpic_emoji_builder_menu_item.cpp
|
||||||
info/userpic/info_userpic_emoji_builder_menu_item.h
|
info/userpic/info_userpic_emoji_builder_menu_item.h
|
||||||
info/userpic/info_userpic_emoji_builder_preview.cpp
|
info/userpic/info_userpic_emoji_builder_preview.cpp
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/userpic/info_userpic_emoji_builder.h"
|
#include "info/userpic/info_userpic_emoji_builder.h"
|
||||||
|
|
||||||
|
#include "info/userpic/info_userpic_emoji_builder_common.h"
|
||||||
#include "info/userpic/info_userpic_emoji_builder_layer.h"
|
#include "info/userpic/info_userpic_emoji_builder_layer.h"
|
||||||
#include "info/userpic/info_userpic_emoji_builder_widget.h"
|
#include "info/userpic/info_userpic_emoji_builder_widget.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -33,7 +34,7 @@ void ShowLayer(
|
||||||
layerRaw,
|
layerRaw,
|
||||||
controller,
|
controller,
|
||||||
data,
|
data,
|
||||||
BothWayCommunication{
|
BothWayCommunication<QImage&&>{
|
||||||
.triggers = state->clicks.events(),
|
.triggers = state->clicks.events(),
|
||||||
.result = [=, done = std::move(doneCallback)](QImage &&i) {
|
.result = [=, done = std::move(doneCallback)](QImage &&i) {
|
||||||
done(std::move(i));
|
done(std::move(i));
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
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_emoji_builder_common.h"
|
||||||
|
|
||||||
|
#include "ui/image/image_prepare.h"
|
||||||
|
|
||||||
|
namespace UserpicBuilder {
|
||||||
|
|
||||||
|
[[nodiscard]] QImage GenerateGradient(
|
||||||
|
const QSize &size,
|
||||||
|
const std::vector<QColor> &colors,
|
||||||
|
bool circle) {
|
||||||
|
constexpr auto kRotation = int(45);
|
||||||
|
auto gradient = Images::GenerateGradient(size, colors, kRotation);
|
||||||
|
if (!circle) {
|
||||||
|
return gradient;
|
||||||
|
} else if (style::DevicePixelRatio() == 1) {
|
||||||
|
return Images::Circle(std::move(gradient));
|
||||||
|
}
|
||||||
|
auto image = QImage(
|
||||||
|
size * style::DevicePixelRatio(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
image.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
|
image.fill(Qt::transparent);
|
||||||
|
{
|
||||||
|
auto p = QPainter(&image);
|
||||||
|
p.drawImage(QRect(QPoint(), size), gradient);
|
||||||
|
}
|
||||||
|
return Images::Circle(std::move(image));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace UserpicBuilder
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
|
||||||
|
namespace UserpicBuilder {
|
||||||
|
|
||||||
|
[[nodiscard]] QImage GenerateGradient(
|
||||||
|
const QSize &size,
|
||||||
|
const std::vector<QColor> &colors,
|
||||||
|
bool circle = true);
|
||||||
|
|
||||||
|
struct StartData {
|
||||||
|
DocumentId documentId = DocumentId(0);
|
||||||
|
int builderColorIndex = 0;
|
||||||
|
std::vector<QColor> gradientEditorColors;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Result>
|
||||||
|
struct BothWayCommunication {
|
||||||
|
rpl::producer<> triggers;
|
||||||
|
Fn<void(Result)> result;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace UserpicBuilder
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "info/userpic/info_userpic_emoji_builder.h"
|
#include "info/userpic/info_userpic_emoji_builder.h"
|
||||||
|
#include "info/userpic/info_userpic_emoji_builder_common.h"
|
||||||
#include "info/userpic/info_userpic_emoji_builder_widget.h"
|
#include "info/userpic/info_userpic_emoji_builder_widget.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "editor/photo_editor_layer_widget.h" // Editor::kProfilePhotoSize.
|
#include "editor/photo_editor_layer_widget.h" // Editor::kProfilePhotoSize.
|
||||||
#include "info/userpic/info_userpic_bubble_wrap.h"
|
#include "info/userpic/info_userpic_bubble_wrap.h"
|
||||||
#include "info/userpic/info_userpic_colors_palette_chooser.h"
|
#include "info/userpic/info_userpic_colors_palette_chooser.h"
|
||||||
|
#include "info/userpic/info_userpic_emoji_builder_common.h"
|
||||||
#include "info/userpic/info_userpic_emoji_builder_preview.h"
|
#include "info/userpic/info_userpic_emoji_builder_preview.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -241,7 +242,7 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
StartData data,
|
StartData data,
|
||||||
BothWayCommunication communication) {
|
BothWayCommunication<QImage&&> communication) {
|
||||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
|
const auto container = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
|
||||||
|
|
||||||
const auto preview = container->add(
|
const auto preview = container->add(
|
||||||
|
@ -273,7 +274,7 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
||||||
|
|
||||||
const auto palette = Ui::CreateChild<ColorsPalette>(
|
const auto palette = Ui::CreateChild<ColorsPalette>(
|
||||||
paletteBg.get(),
|
paletteBg.get(),
|
||||||
data.colorIndex);
|
data.builderColorIndex);
|
||||||
palette->stopsValue(
|
palette->stopsValue(
|
||||||
) | rpl::start_with_next([=](QGradientStops stops) {
|
) | rpl::start_with_next([=](QGradientStops stops) {
|
||||||
preview->setGradientStops(std::move(stops));
|
preview->setGradientStops(std::move(stops));
|
||||||
|
|
|
@ -18,21 +18,16 @@ class SessionController;
|
||||||
|
|
||||||
namespace UserpicBuilder {
|
namespace UserpicBuilder {
|
||||||
|
|
||||||
struct StartData {
|
struct StartData;
|
||||||
DocumentId documentId = DocumentId(0);
|
|
||||||
int colorIndex = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BothWayCommunication {
|
template <typename Result>
|
||||||
rpl::producer<> triggers;
|
struct BothWayCommunication;
|
||||||
Fn<void(QImage &&image)> result;
|
|
||||||
};
|
|
||||||
|
|
||||||
not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
StartData data,
|
StartData data,
|
||||||
BothWayCommunication communication);
|
BothWayCommunication<QImage&&> communication);
|
||||||
|
|
||||||
[[nodiscard]] not_null<Ui::RpWidget*> CreateEmojiUserpic(
|
[[nodiscard]] not_null<Ui::RpWidget*> CreateEmojiUserpic(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
Loading…
Reference in New Issue