Moved flip and rotation info to Editor::ItemBase struct.

This commit is contained in:
23rd 2021-07-04 16:13:54 +03:00
parent 0c50fbf1b9
commit d69090bf34
3 changed files with 10 additions and 7 deletions

View file

@ -112,8 +112,6 @@ Paint::Paint(
const auto item = std::make_shared<ItemSticker>(
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<ItemImage>(
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,
};
}

View file

@ -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();
}

View file

@ -42,6 +42,8 @@ public:
int size = 0;
int x = 0;
int y = 0;
bool flipped = false;
int rotation = 0;
};
ItemBase(Data data);