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(
rpl::producer<std::optional<bool>> &&showRequest) {
rpl::producer<ShowRequest> &&showRequest) {
std::move(
showRequest
) | rpl::start_with_next([=](std::optional<bool> 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());
}

View file

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

View file

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

View file

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