2021-02-23 10:31:48 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
2021-03-21 12:38:33 +00:00
|
|
|
#include "editor/controllers/stickers_panel_controller.h"
|
2021-02-23 10:31:48 +00:00
|
|
|
|
|
|
|
#include "chat_helpers/tabbed_panel.h"
|
|
|
|
#include "chat_helpers/tabbed_selector.h"
|
2022-07-25 10:34:18 +00:00
|
|
|
#include "window/window_session_controller.h" // Window::GifPauseReason
|
|
|
|
|
2021-02-23 10:31:48 +00:00
|
|
|
#include "styles/style_chat_helpers.h"
|
|
|
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
StickersPanelController::StickersPanelController(
|
|
|
|
not_null<Ui::RpWidget*> panelContainer,
|
|
|
|
not_null<Window::SessionController*> controller)
|
|
|
|
: _stickersPanel(
|
|
|
|
base::make_unique_q<ChatHelpers::TabbedPanel>(
|
|
|
|
panelContainer,
|
|
|
|
controller,
|
|
|
|
object_ptr<ChatHelpers::TabbedSelector>(
|
|
|
|
nullptr,
|
|
|
|
controller,
|
2022-07-25 10:34:18 +00:00
|
|
|
Window::GifPauseReason::Layer,
|
2021-03-25 11:05:33 +00:00
|
|
|
ChatHelpers::TabbedSelector::Mode::MediaEditor))) {
|
2021-02-23 10:31:48 +00:00
|
|
|
_stickersPanel->setDesiredHeightValues(
|
|
|
|
1.,
|
|
|
|
st::emojiPanMinHeight / 2,
|
|
|
|
st::emojiPanMinHeight);
|
|
|
|
_stickersPanel->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StickersPanelController::stickerChosen() const
|
|
|
|
-> rpl::producer<not_null<DocumentData*>> {
|
|
|
|
return _stickersPanel->selector()->fileChosen(
|
2022-09-14 10:45:23 +00:00
|
|
|
) | rpl::map([](const ChatHelpers::FileChosen &data) {
|
2021-02-23 10:31:48 +00:00
|
|
|
return data.document;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<bool> StickersPanelController::panelShown() const {
|
|
|
|
return _stickersPanel->shownValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StickersPanelController::setShowRequestChanges(
|
2021-05-04 17:57:52 +00:00
|
|
|
rpl::producer<ShowRequest> &&showRequest) {
|
2021-02-23 10:31:48 +00:00
|
|
|
std::move(
|
|
|
|
showRequest
|
2021-05-04 17:57:52 +00:00
|
|
|
) | rpl::start_with_next([=](ShowRequest show) {
|
|
|
|
if (show == ShowRequest::ToggleAnimated) {
|
2021-02-23 10:31:48 +00:00
|
|
|
_stickersPanel->toggleAnimated();
|
|
|
|
_stickersPanel->raise();
|
2021-05-04 17:57:52 +00:00
|
|
|
} else if (show == ShowRequest::ShowAnimated) {
|
2021-02-23 10:31:48 +00:00
|
|
|
_stickersPanel->showAnimated();
|
2021-05-04 17:57:52 +00:00
|
|
|
_stickersPanel->raise();
|
|
|
|
} else if (show == ShowRequest::HideAnimated) {
|
|
|
|
_stickersPanel->hideAnimated();
|
|
|
|
} else if (show == ShowRequest::HideFast) {
|
|
|
|
_stickersPanel->hideFast();
|
2021-02-23 10:31:48 +00:00
|
|
|
}
|
|
|
|
}, _stickersPanel->lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StickersPanelController::setMoveRequestChanges(
|
|
|
|
rpl::producer<QPoint> &&moveRequest) {
|
|
|
|
std::move(
|
|
|
|
moveRequest
|
|
|
|
) | rpl::start_with_next([=](const QPoint &point) {
|
|
|
|
_stickersPanel->moveBottomRight(
|
|
|
|
point.y(),
|
|
|
|
point.x() + _stickersPanel->width() / 2);
|
|
|
|
}, _stickersPanel->lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Editor
|