Added initial implementation of userpic emoji builder.

This commit is contained in:
23rd 2023-01-24 01:58:18 +03:00 committed by John Preston
parent 6c1e9b1387
commit 9bc4c0a551
4 changed files with 116 additions and 0 deletions

View File

@ -857,6 +857,8 @@ PRIVATE
info/profile/info_profile_widget.h info/profile/info_profile_widget.h
info/settings/info_settings_widget.cpp info/settings/info_settings_widget.cpp
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.h
info/userpic/info_userpic_emoji_builder_widget.cpp info/userpic/info_userpic_emoji_builder_widget.cpp
info/userpic/info_userpic_emoji_builder_widget.h info/userpic/info_userpic_emoji_builder_widget.h
inline_bots/bot_attach_web_view.cpp inline_bots/bot_attach_web_view.cpp

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
using "ui/basic.style"; using "ui/basic.style";
using "boxes/boxes.style";
using "ui/widgets/widgets.style"; using "ui/widgets/widgets.style";
userpicBuilderEmojiPreviewPadding: margins(0px, 36px, 0px, 8px); userpicBuilderEmojiPreviewPadding: margins(0px, 36px, 0px, 8px);
@ -22,6 +23,24 @@ userpicBuilderEmojiBubblePalettePadding: margins(12px, 8px, 12px, 8px);
userpicBuilderEmojiSelectorLeft: 5px; userpicBuilderEmojiSelectorLeft: 5px;
userpicBuilderEmojiButton: RoundButton(defaultBoxButton) {
textFg: boxTextFg;
textFgOver: boxTextFg;
textBg: boxDividerBg;
textBgOver: boxDividerBg;
ripple: universalRippleAnimation;
}
userpicBuilderEmojiBackButton: IconButton(backButton) {
icon: icon {{ "box_button_back", boxTextFg }};
iconOver: icon {{ "box_button_back", boxTextFg }};
ripple: universalRippleAnimation;
}
userpicBuilderEmojiBackPosiiton: point(8px, 8px);
userpicBuilderEmojiSavePosiiton: point(7px, 12px);
userpicBuilderEmojiAccentColorSize: 30px; userpicBuilderEmojiAccentColorSize: 30px;
userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px); userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px);

View File

@ -0,0 +1,75 @@
/*
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.h"
#include "info/userpic/info_userpic_emoji_builder_layer.h"
#include "info/userpic/info_userpic_emoji_builder_widget.h"
#include "lang/lang_keys.h"
#include "ui/widgets/buttons.h"
#include "ui/wrap/vertical_layout.h"
#include "window/window_session_controller.h"
#include "styles/style_info_userpic_builder.h"
namespace UserpicBuilder {
void ShowLayer(
not_null<Window::SessionController*> controller,
Fn<void(QImage &&image)> &&doneCallback) {
auto layer = std::make_unique<LayerWidget>();
const auto layerRaw = layer.get();
{
struct State {
rpl::event_stream<> clicks;
};
const auto state = layer->lifetime().make_state<State>();
const auto content = CreateUserpicBuilder(
layerRaw,
controller,
BothWayCommunication{
.triggers = state->clicks.events(),
.result = [=, done = std::move(doneCallback)](QImage &&i) {
done(std::move(i));
layerRaw->closeLayer();
},
});
const auto save = Ui::CreateChild<Ui::RoundButton>(
content.get(),
tr::lng_connection_save(),
st::userpicBuilderEmojiButton);
save->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
content->sizeValue(
) | rpl::start_with_next([=] {
const auto &p = st::userpicBuilderEmojiSavePosiiton;
save->moveToRight(p.x(), p.y());
}, save->lifetime());
save->clicks() | rpl::to_empty | rpl::start_to_stream(
state->clicks,
save->lifetime());
const auto back = Ui::CreateChild<Ui::IconButton>(
content.get(),
st::userpicBuilderEmojiBackButton);
back->setClickedCallback([=] {
layerRaw->closeLayer();
});
content->sizeValue(
) | rpl::start_with_next([=] {
const auto &p = st::userpicBuilderEmojiBackPosiiton;
back->moveToLeft(p.x(), p.y());
}, back->lifetime());
layer->setContent(content);
}
controller->showLayer(std::move(layer), Ui::LayerOption::KeepOther);
}
} // namespace UserpicBuilder

View File

@ -0,0 +1,20 @@
/*
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 Window {
class SessionController;
} // namespace Window
namespace UserpicBuilder {
void ShowLayer(
not_null<Window::SessionController*> controller,
Fn<void(QImage &&image)> &&doneCallback);
} // namespace UserpicBuilder