From d69090bf34f5e347a30f6204f8d8c3ee9cc25739 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 4 Jul 2021 16:13:54 +0300 Subject: [PATCH] Moved flip and rotation info to Editor::ItemBase struct. --- Telegram/SourceFiles/editor/editor_paint.cpp | 6 ++---- Telegram/SourceFiles/editor/scene/scene_item_base.cpp | 9 ++++++--- Telegram/SourceFiles/editor/scene/scene_item_base.h | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/editor/editor_paint.cpp b/Telegram/SourceFiles/editor/editor_paint.cpp index d27902050..22c6ebd3b 100644 --- a/Telegram/SourceFiles/editor/editor_paint.cpp +++ b/Telegram/SourceFiles/editor/editor_paint.cpp @@ -112,8 +112,6 @@ Paint::Paint( const auto item = std::make_shared( document, itemBaseData()); - item->setFlip(_transform.flipped); - item->setRotation(-_transform.angle); _scene->addItem(item); _scene->clearSelection(); }, lifetime()); @@ -271,8 +269,6 @@ void Paint::handleMimeData(const QMimeData *data) { const auto item = std::make_shared( Ui::PixmapFromImage(std::move(image)), itemBaseData()); - item->setFlip(_transform.flipped); - item->setRotation(-_transform.angle); _scene->addItem(item); _scene->clearSelection(); }; @@ -301,6 +297,8 @@ ItemBase::Data Paint::itemBaseData() const { .size = size, .x = x, .y = y, + .flipped = _transform.flipped, + .rotation = -_transform.angle, }; } diff --git a/Telegram/SourceFiles/editor/scene/scene_item_base.cpp b/Telegram/SourceFiles/editor/scene/scene_item_base.cpp index 8dcea5a5f..dc06a62da 100644 --- a/Telegram/SourceFiles/editor/scene/scene_item_base.cpp +++ b/Telegram/SourceFiles/editor/scene/scene_item_base.cpp @@ -55,6 +55,8 @@ ItemBase::ItemBase(Data data) setAcceptHoverEvents(true); setPos(data.x, data.y); setZValue((*_lastZ)++); + setFlip(data.flipped); + setRotation(data.rotation); const auto &handleSize = st::photoEditorItemHandleSize; _zoom.value( @@ -237,9 +239,10 @@ void ItemBase::actionDuplicate() { .zPtr = _lastZ, .size = int(_horizontalSize), .x = int(scenePos().x() + _horizontalSize / 3), - .y = int(scenePos().y() + _verticalSize / 3) }); - newItem->setFlip(flipped()); - newItem->setRotation(rotation()); + .y = int(scenePos().y() + _verticalSize / 3), + .flipped = flipped(), + .rotation = int(rotation()), + }); if (hasFocus()) { newItem->setFocus(); } diff --git a/Telegram/SourceFiles/editor/scene/scene_item_base.h b/Telegram/SourceFiles/editor/scene/scene_item_base.h index c38d7f9f7..76e351731 100644 --- a/Telegram/SourceFiles/editor/scene/scene_item_base.h +++ b/Telegram/SourceFiles/editor/scene/scene_item_base.h @@ -42,6 +42,8 @@ public: int size = 0; int x = 0; int y = 0; + bool flipped = false; + int rotation = 0; }; ItemBase(Data data);