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>( const auto item = std::make_shared<ItemSticker>(
document, document,
itemBaseData()); itemBaseData());
item->setFlip(_transform.flipped);
item->setRotation(-_transform.angle);
_scene->addItem(item); _scene->addItem(item);
_scene->clearSelection(); _scene->clearSelection();
}, lifetime()); }, lifetime());
@ -271,8 +269,6 @@ void Paint::handleMimeData(const QMimeData *data) {
const auto item = std::make_shared<ItemImage>( const auto item = std::make_shared<ItemImage>(
Ui::PixmapFromImage(std::move(image)), Ui::PixmapFromImage(std::move(image)),
itemBaseData()); itemBaseData());
item->setFlip(_transform.flipped);
item->setRotation(-_transform.angle);
_scene->addItem(item); _scene->addItem(item);
_scene->clearSelection(); _scene->clearSelection();
}; };
@ -301,6 +297,8 @@ ItemBase::Data Paint::itemBaseData() const {
.size = size, .size = size,
.x = x, .x = x,
.y = y, .y = y,
.flipped = _transform.flipped,
.rotation = -_transform.angle,
}; };
} }

View file

@ -55,6 +55,8 @@ ItemBase::ItemBase(Data data)
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
setPos(data.x, data.y); setPos(data.x, data.y);
setZValue((*_lastZ)++); setZValue((*_lastZ)++);
setFlip(data.flipped);
setRotation(data.rotation);
const auto &handleSize = st::photoEditorItemHandleSize; const auto &handleSize = st::photoEditorItemHandleSize;
_zoom.value( _zoom.value(
@ -237,9 +239,10 @@ void ItemBase::actionDuplicate() {
.zPtr = _lastZ, .zPtr = _lastZ,
.size = int(_horizontalSize), .size = int(_horizontalSize),
.x = int(scenePos().x() + _horizontalSize / 3), .x = int(scenePos().x() + _horizontalSize / 3),
.y = int(scenePos().y() + _verticalSize / 3) }); .y = int(scenePos().y() + _verticalSize / 3),
newItem->setFlip(flipped()); .flipped = flipped(),
newItem->setRotation(rotation()); .rotation = int(rotation()),
});
if (hasFocus()) { if (hasFocus()) {
newItem->setFocus(); newItem->setFocus();
} }

View file

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