mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to open userpic emoji builder with initial data.
This commit is contained in:
parent
76ee5fcefe
commit
e0aabe3acf
6 changed files with 27 additions and 8 deletions
|
@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace UserpicBuilder {
|
namespace UserpicBuilder {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kColorsCount = 7;
|
||||||
|
|
||||||
[[nodiscard]] QLinearGradient VerticalGradient(
|
[[nodiscard]] QLinearGradient VerticalGradient(
|
||||||
float64 size,
|
float64 size,
|
||||||
const QColor &c1,
|
const QColor &c1,
|
||||||
|
@ -78,8 +80,9 @@ void ColorsPalette::CircleButton::paintEvent(QPaintEvent *event) {
|
||||||
Settings::PaintRoundColorButton(p, h, _brush, _selectedProgress);
|
Settings::PaintRoundColorButton(p, h, _brush, _selectedProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorsPalette::ColorsPalette(not_null<Ui::RpWidget*> parent)
|
ColorsPalette::ColorsPalette(not_null<Ui::RpWidget*> parent, int index)
|
||||||
: Ui::RpWidget(parent) {
|
: Ui::RpWidget(parent)
|
||||||
|
, _currentIndex(index % kColorsCount) {
|
||||||
rebuildButtons();
|
rebuildButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +93,6 @@ rpl::producer<QGradientStops> ColorsPalette::stopsValue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorsPalette::rebuildButtons() {
|
void ColorsPalette::rebuildButtons() {
|
||||||
constexpr auto kColorsCount = 7;
|
|
||||||
const auto size = resizeGetHeight(0);
|
const auto size = resizeGetHeight(0);
|
||||||
for (auto i = 0; i < kColorsCount; i++) {
|
for (auto i = 0; i < kColorsCount; i++) {
|
||||||
_buttons.emplace_back(base::make_unique_q<CircleButton>(this));
|
_buttons.emplace_back(base::make_unique_q<CircleButton>(this));
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace UserpicBuilder {
|
||||||
|
|
||||||
class ColorsPalette final : public Ui::RpWidget {
|
class ColorsPalette final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
ColorsPalette(not_null<Ui::RpWidget*> parent);
|
ColorsPalette(not_null<Ui::RpWidget*> parent, int index = 0);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<QGradientStops> stopsValue();
|
[[nodiscard]] rpl::producer<QGradientStops> stopsValue();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace UserpicBuilder {
|
||||||
|
|
||||||
void ShowLayer(
|
void ShowLayer(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
StartData data,
|
||||||
Fn<void(QImage &&image)> &&doneCallback) {
|
Fn<void(QImage &&image)> &&doneCallback) {
|
||||||
auto layer = std::make_unique<LayerWidget>();
|
auto layer = std::make_unique<LayerWidget>();
|
||||||
const auto layerRaw = layer.get();
|
const auto layerRaw = layer.get();
|
||||||
|
@ -31,6 +32,7 @@ void ShowLayer(
|
||||||
const auto content = CreateUserpicBuilder(
|
const auto content = CreateUserpicBuilder(
|
||||||
layerRaw,
|
layerRaw,
|
||||||
controller,
|
controller,
|
||||||
|
data,
|
||||||
BothWayCommunication{
|
BothWayCommunication{
|
||||||
.triggers = state->clicks.events(),
|
.triggers = state->clicks.events(),
|
||||||
.result = [=, done = std::move(doneCallback)](QImage &&i) {
|
.result = [=, done = std::move(doneCallback)](QImage &&i) {
|
||||||
|
|
|
@ -13,8 +13,11 @@ class SessionController;
|
||||||
|
|
||||||
namespace UserpicBuilder {
|
namespace UserpicBuilder {
|
||||||
|
|
||||||
|
struct StartData;
|
||||||
|
|
||||||
void ShowLayer(
|
void ShowLayer(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
StartData data,
|
||||||
Fn<void(QImage &&image)> &&doneCallback);
|
Fn<void(QImage &&image)> &&doneCallback);
|
||||||
|
|
||||||
} // namespace UserpicBuilder
|
} // namespace UserpicBuilder
|
||||||
|
|
|
@ -173,9 +173,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EmojiUserpic::EmojiUserpic(
|
EmojiUserpic::EmojiUserpic(not_null<Ui::RpWidget*> parent, const QSize &size)
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
const QSize &size)
|
|
||||||
: Ui::RpWidget(parent)
|
: Ui::RpWidget(parent)
|
||||||
, _painter(size.width()) {
|
, _painter(size.width()) {
|
||||||
resize(size);
|
resize(size);
|
||||||
|
@ -358,6 +356,7 @@ void EmojiSelector::prepare() {
|
||||||
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,
|
||||||
BothWayCommunication communication) {
|
BothWayCommunication communication) {
|
||||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
|
const auto container = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
|
||||||
|
|
||||||
|
@ -368,6 +367,11 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
||||||
container,
|
container,
|
||||||
Size(st::settingsInfoPhotoSize))),
|
Size(st::settingsInfoPhotoSize))),
|
||||||
st::userpicBuilderEmojiPreviewPadding)->entity();
|
st::userpicBuilderEmojiPreviewPadding)->entity();
|
||||||
|
if (const auto id = data.documentId) {
|
||||||
|
if (const auto document = controller->session().data().document(id)) {
|
||||||
|
preview->setDocument(document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container->add(
|
container->add(
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||||
|
@ -383,7 +387,9 @@ not_null<Ui::VerticalLayout*> CreateUserpicBuilder(
|
||||||
st::userpicBuilderEmojiBubblePaletteSize,
|
st::userpicBuilderEmojiBubblePaletteSize,
|
||||||
[=] { return controller->chatStyle(); });
|
[=] { return controller->chatStyle(); });
|
||||||
|
|
||||||
const auto palette = Ui::CreateChild<ColorsPalette>(paletteBg.get());
|
const auto palette = Ui::CreateChild<ColorsPalette>(
|
||||||
|
paletteBg.get(),
|
||||||
|
data.colorIndex);
|
||||||
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,6 +18,11 @@ class SessionController;
|
||||||
|
|
||||||
namespace UserpicBuilder {
|
namespace UserpicBuilder {
|
||||||
|
|
||||||
|
struct StartData {
|
||||||
|
DocumentId documentId = DocumentId(0);
|
||||||
|
int colorIndex = 0;
|
||||||
|
};
|
||||||
|
|
||||||
struct BothWayCommunication {
|
struct BothWayCommunication {
|
||||||
rpl::producer<> triggers;
|
rpl::producer<> triggers;
|
||||||
Fn<void(QImage &&image)> result;
|
Fn<void(QImage &&image)> result;
|
||||||
|
@ -26,6 +31,7 @@ struct BothWayCommunication {
|
||||||
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,
|
||||||
BothWayCommunication communication);
|
BothWayCommunication communication);
|
||||||
|
|
||||||
} // namespace UserpicBuilder
|
} // namespace UserpicBuilder
|
||||||
|
|
Loading…
Add table
Reference in a new issue