mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fixed display of sticker panel on mode change in photo editor.
This commit is contained in:
parent
785ebfee34
commit
82bf6ca94f
4 changed files with 28 additions and 13 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue