mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Added stickers panel controller for photo editor.
This commit is contained in:
parent
812d616f66
commit
c312607ff8
3 changed files with 123 additions and 0 deletions
|
@ -524,6 +524,8 @@ PRIVATE
|
|||
editor/photo_editor_layer_widget.h
|
||||
editor/scene_item_base.cpp
|
||||
editor/scene_item_base.h
|
||||
editor/stickers_panel_controller.cpp
|
||||
editor/stickers_panel_controller.h
|
||||
editor/undo_controller.cpp
|
||||
editor/undo_controller.h
|
||||
export/export_manager.cpp
|
||||
|
|
75
Telegram/SourceFiles/editor/stickers_panel_controller.cpp
Normal file
75
Telegram/SourceFiles/editor/stickers_panel_controller.cpp
Normal 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 "editor/stickers_panel_controller.h"
|
||||
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#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,
|
||||
ChatHelpers::TabbedSelector::Mode::Full))) {
|
||||
_stickersPanel->setDesiredHeightValues(
|
||||
1.,
|
||||
st::emojiPanMinHeight / 2,
|
||||
st::emojiPanMinHeight);
|
||||
_stickersPanel->hide();
|
||||
}
|
||||
|
||||
auto StickersPanelController::stickerChosen() const
|
||||
-> rpl::producer<not_null<DocumentData*>> {
|
||||
return _stickersPanel->selector()->fileChosen(
|
||||
) | rpl::map([](const ChatHelpers::TabbedSelector::FileChosen &data) {
|
||||
return data.document;
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<bool> StickersPanelController::panelShown() const {
|
||||
return _stickersPanel->shownValue();
|
||||
}
|
||||
|
||||
void StickersPanelController::setShowRequestChanges(
|
||||
rpl::producer<std::optional<bool>> &&showRequest) {
|
||||
std::move(
|
||||
showRequest
|
||||
) | rpl::start_with_next([=](std::optional<bool> show) {
|
||||
if (!show) {
|
||||
_stickersPanel->toggleAnimated();
|
||||
_stickersPanel->raise();
|
||||
return;
|
||||
}
|
||||
if (*show) {
|
||||
_stickersPanel->showAnimated();
|
||||
} else {
|
||||
_stickersPanel->toggleAnimated();
|
||||
}
|
||||
}, _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
|
46
Telegram/SourceFiles/editor/stickers_panel_controller.h
Normal file
46
Telegram/SourceFiles/editor/stickers_panel_controller.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
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 "base/unique_qptr.h"
|
||||
|
||||
namespace ChatHelpers {
|
||||
class TabbedPanel;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Editor {
|
||||
|
||||
class StickersPanelController final {
|
||||
public:
|
||||
StickersPanelController(
|
||||
not_null<Ui::RpWidget*> panelContainer,
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
[[nodiscard]] auto stickerChosen() const
|
||||
-> rpl::producer<not_null<DocumentData*>>;
|
||||
[[nodiscard]] rpl::producer<bool> panelShown() const;
|
||||
|
||||
void setShowRequestChanges(
|
||||
rpl::producer<std::optional<bool>> &&showRequest);
|
||||
// Middle x and plain y position.
|
||||
void setMoveRequestChanges(rpl::producer<QPoint> &&moveRequest);
|
||||
|
||||
private:
|
||||
const base::unique_qptr<ChatHelpers::TabbedPanel> _stickersPanel;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Editor
|
Loading…
Add table
Reference in a new issue