diff --git a/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.cpp b/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.cpp index f258b54db..9436e6225 100644 --- a/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.cpp +++ b/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.cpp @@ -44,19 +44,20 @@ rpl::producer StickersPanelController::panelShown() const { } void StickersPanelController::setShowRequestChanges( - rpl::producer> &&showRequest) { + rpl::producer &&showRequest) { std::move( showRequest - ) | rpl::start_with_next([=](std::optional show) { - if (!show) { + ) | rpl::start_with_next([=](ShowRequest show) { + if (show == ShowRequest::ToggleAnimated) { _stickersPanel->toggleAnimated(); _stickersPanel->raise(); - return; - } - if (*show) { + } else if (show == ShowRequest::ShowAnimated) { _stickersPanel->showAnimated(); - } else { - _stickersPanel->toggleAnimated(); + _stickersPanel->raise(); + } else if (show == ShowRequest::HideAnimated) { + _stickersPanel->hideAnimated(); + } else if (show == ShowRequest::HideFast) { + _stickersPanel->hideFast(); } }, _stickersPanel->lifetime()); } diff --git a/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.h b/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.h index 86ae519a4..5404a8adb 100644 --- a/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.h +++ b/Telegram/SourceFiles/editor/controllers/stickers_panel_controller.h @@ -25,6 +25,13 @@ namespace Editor { class StickersPanelController final { public: + enum class ShowRequest { + ToggleAnimated, + ShowAnimated, + HideAnimated, + HideFast, + }; + StickersPanelController( not_null panelContainer, not_null controller); @@ -33,8 +40,7 @@ public: -> rpl::producer>; [[nodiscard]] rpl::producer panelShown() const; - void setShowRequestChanges( - rpl::producer> &&showRequest); + void setShowRequestChanges(rpl::producer &&showRequest); // Middle x and plain y position. void setMoveRequestChanges(rpl::producer &&moveRequest); diff --git a/Telegram/SourceFiles/editor/editor_paint.cpp b/Telegram/SourceFiles/editor/editor_paint.cpp index fe5b3b74e..14eeeeb22 100644 --- a/Telegram/SourceFiles/editor/editor_paint.cpp +++ b/Telegram/SourceFiles/editor/editor_paint.cpp @@ -100,9 +100,11 @@ Paint::Paint( }))); if (controllers->stickersPanelController) { + using ShowRequest = StickersPanelController::ShowRequest; + controllers->stickersPanelController->setShowRequestChanges( controllers->stickersPanelController->stickerChosen( - ) | rpl::map_to(std::optional(false))); + ) | rpl::map_to(ShowRequest::HideAnimated)); controllers->stickersPanelController->stickerChosen( ) | rpl::start_with_next([=](not_null document) { diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.cpp b/Telegram/SourceFiles/editor/photo_editor_controls.cpp index eb6987082..d948bfd9e 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_controls.cpp @@ -309,9 +309,15 @@ PhotoEditorControls::PhotoEditorControls( }, lifetime()); if (_stickersButton) { + using ShowRequest = StickersPanelController::ShowRequest; + controllers->stickersPanelController->setShowRequestChanges( - _stickersButton->clicks( - ) | rpl::map_to(std::optional(std::nullopt))); + rpl::merge( + _mode.value( + ) | rpl::map_to(ShowRequest::HideFast), + _stickersButton->clicks( + ) | rpl::map_to(ShowRequest::ToggleAnimated) + )); controllers->stickersPanelController->setMoveRequestChanges( _paintBottomButtons->positionValue(