Fixed display of sticker panel on mode change in photo editor.

This commit is contained in:
23rd 2021-05-04 20:57:52 +03:00
parent 785ebfee34
commit 82bf6ca94f
4 changed files with 28 additions and 13 deletions

View file

@ -44,19 +44,20 @@ rpl::producer<bool> StickersPanelController::panelShown() const {
} }
void StickersPanelController::setShowRequestChanges( void StickersPanelController::setShowRequestChanges(
rpl::producer<std::optional<bool>> &&showRequest) { rpl::producer<ShowRequest> &&showRequest) {
std::move( std::move(
showRequest showRequest
) | rpl::start_with_next([=](std::optional<bool> show) { ) | rpl::start_with_next([=](ShowRequest show) {
if (!show) { if (show == ShowRequest::ToggleAnimated) {
_stickersPanel->toggleAnimated(); _stickersPanel->toggleAnimated();
_stickersPanel->raise(); _stickersPanel->raise();
return; } else if (show == ShowRequest::ShowAnimated) {
}
if (*show) {
_stickersPanel->showAnimated(); _stickersPanel->showAnimated();
} else { _stickersPanel->raise();
_stickersPanel->toggleAnimated(); } else if (show == ShowRequest::HideAnimated) {
_stickersPanel->hideAnimated();
} else if (show == ShowRequest::HideFast) {
_stickersPanel->hideFast();
} }
}, _stickersPanel->lifetime()); }, _stickersPanel->lifetime());
} }

View file

@ -25,6 +25,13 @@ namespace Editor {
class StickersPanelController final { class StickersPanelController final {
public: public:
enum class ShowRequest {
ToggleAnimated,
ShowAnimated,
HideAnimated,
HideFast,
};
StickersPanelController( StickersPanelController(
not_null<Ui::RpWidget*> panelContainer, not_null<Ui::RpWidget*> panelContainer,
not_null<Window::SessionController*> controller); not_null<Window::SessionController*> controller);
@ -33,8 +40,7 @@ public:
-> rpl::producer<not_null<DocumentData*>>; -> rpl::producer<not_null<DocumentData*>>;
[[nodiscard]] rpl::producer<bool> panelShown() const; [[nodiscard]] rpl::producer<bool> panelShown() const;
void setShowRequestChanges( void setShowRequestChanges(rpl::producer<ShowRequest> &&showRequest);
rpl::producer<std::optional<bool>> &&showRequest);
// Middle x and plain y position. // Middle x and plain y position.
void setMoveRequestChanges(rpl::producer<QPoint> &&moveRequest); void setMoveRequestChanges(rpl::producer<QPoint> &&moveRequest);

View file

@ -100,9 +100,11 @@ Paint::Paint(
}))); })));
if (controllers->stickersPanelController) { if (controllers->stickersPanelController) {
using ShowRequest = StickersPanelController::ShowRequest;
controllers->stickersPanelController->setShowRequestChanges( controllers->stickersPanelController->setShowRequestChanges(
controllers->stickersPanelController->stickerChosen( controllers->stickersPanelController->stickerChosen(
) | rpl::map_to(std::optional<bool>(false))); ) | rpl::map_to(ShowRequest::HideAnimated));
controllers->stickersPanelController->stickerChosen( controllers->stickersPanelController->stickerChosen(
) | rpl::start_with_next([=](not_null<DocumentData*> document) { ) | rpl::start_with_next([=](not_null<DocumentData*> document) {

View file

@ -309,9 +309,15 @@ PhotoEditorControls::PhotoEditorControls(
}, lifetime()); }, lifetime());
if (_stickersButton) { if (_stickersButton) {
using ShowRequest = StickersPanelController::ShowRequest;
controllers->stickersPanelController->setShowRequestChanges( controllers->stickersPanelController->setShowRequestChanges(
_stickersButton->clicks( rpl::merge(
) | rpl::map_to(std::optional<bool>(std::nullopt))); _mode.value(
) | rpl::map_to(ShowRequest::HideFast),
_stickersButton->clicks(
) | rpl::map_to(ShowRequest::ToggleAnimated)
));
controllers->stickersPanelController->setMoveRequestChanges( controllers->stickersPanelController->setMoveRequestChanges(
_paintBottomButtons->positionValue( _paintBottomButtons->positionValue(