Added sticker panel to photo editor.

This commit is contained in:
23rd 2021-02-23 13:35:23 +03:00
parent 216ffad80e
commit 75367f0488
4 changed files with 37 additions and 0 deletions

View File

@ -39,6 +39,10 @@ photoEditorRedoButton: IconButton(historyAttach) {
icon: icon {{ "photo_editor/undo-flip_horizontal", photoEditorButtonIconFg }};
iconOver: icon {{ "photo_editor/undo-flip_horizontal", photoEditorButtonIconFgOver }};
}
photoEditorStickersButton: IconButton(historyAttach) {
icon: icon {{ "settings_stickers", photoEditorButtonIconFg }};
iconOver: icon {{ "settings_stickers", photoEditorButtonIconFgOver }};
}
photoEditorUndoButtonInactive: icon {{ "photo_editor/undo", photoEditorButtonIconFgInactive }};
photoEditorRedoButtonInactive: icon {{ "photo_editor/undo-flip_horizontal", photoEditorButtonIconFgInactive }};

View File

@ -95,6 +95,12 @@ Paint::Paint(
.enable = enable,
};
})));
if (controllers->stickersPanelController) {
controllers->stickersPanelController->setShowRequestChanges(
controllers->stickersPanelController->stickerChosen(
) | rpl::map_to(std::optional<bool>(false)));
}
}
void Paint::applyTransform(QRect geometry, int angle, bool flipped) {

View File

@ -159,6 +159,11 @@ PhotoEditorControls::PhotoEditorControls(
, _paintModeButtonActive(base::make_unique_q<Ui::IconButton>(
_paintButtons,
st::photoEditorPaintModeButton))
, _stickersButton(controllers->stickersPanelController
? base::make_unique_q<Ui::IconButton>(
_paintButtons,
st::photoEditorStickersButton)
: nullptr)
, _cancel(base::make_unique_q<EdgeButton>(
this,
tr::lng_cancel(tr::now),
@ -243,6 +248,27 @@ PhotoEditorControls::PhotoEditorControls(
: &st::photoEditorRedoButtonInactive);
}, lifetime());
if (_stickersButton) {
controllers->stickersPanelController->setShowRequestChanges(
_stickersButton->clicks(
) | rpl::map_to(std::optional<bool>(std::nullopt)));
controllers->stickersPanelController->setMoveRequestChanges(
_paintButtons->positionValue(
) | rpl::map([=](const QPoint &containerPos) {
return QPoint(
(x() + width()) / 2,
y() + containerPos.y() + _stickersButton->y());
}));
controllers->stickersPanelController->panelShown(
) | rpl::start_with_next([=](bool shown) {
_stickersButton->setIconOverride(shown
? &st::photoEditorStickersButton.iconOver
: nullptr);
}, _stickersButton->lifetime());
}
_flipButton->clicks(
) | rpl::start_with_next([=] {
_flipped = !_flipped;

View File

@ -50,6 +50,7 @@ private:
const base::unique_qptr<Ui::IconButton> _undoButton;
const base::unique_qptr<Ui::IconButton> _redoButton;
const base::unique_qptr<Ui::IconButton> _paintModeButtonActive;
const base::unique_qptr<Ui::IconButton> _stickersButton;
const base::unique_qptr<EdgeButton> _cancel;
const base::unique_qptr<EdgeButton> _done;