Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void NodeWidget::composePort(NodePort &port) {
}
} else {
m_callLayout = new Layout;
m_callLayout->setDirection(Layout::Horizontal);
m_callLayout->setOrientation(Widget::Horizontal);
m_callLayout->addTransform(portRect);
layout->addLayout(m_callLayout);
}
Expand Down
24 changes: 24 additions & 0 deletions modules/editor/texturetools/editor/actions/createsprite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "createsprite.h"

CreateSprite::CreateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group) :
UndoCommand(QObject::tr("Create Sprite Element").toStdString(), group),
m_element(element),
m_controller(ctrl) {
}

void CreateSprite::undo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
settings->removeElement(m_uuid);
m_controller->selectElement(m_key);
}
}

void CreateSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
m_uuid = settings->setElement(m_element, "");
m_key = m_controller->selectedElement();
m_controller->selectElement({m_uuid});
}
}
25 changes: 25 additions & 0 deletions modules/editor/texturetools/editor/actions/createsprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CREATESPRITE_H
#define CREATESPRITE_H

#include <editor/undostack.h>
#include "../spritecontroller.h"

class SpriteController;

class CreateSprite : public UndoCommand {
public:
CreateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group = nullptr);
void undo() override;
void redo() override;

protected:
TextureImportSettings::Element m_element;

TString m_uuid;
TString m_key;

SpriteController *m_controller;

};

#endif // CREATESPRITE_H
27 changes: 27 additions & 0 deletions modules/editor/texturetools/editor/actions/destroysprite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "destroysprite.h"

DestroySprite::DestroySprite(SpriteController *ctrl, UndoCommand *group) :
UndoCommand(QObject::tr("Destroy Sprite Element").toStdString(), group),
m_key(ctrl->selectedElement()),
m_controller(ctrl) {
}
void DestroySprite::undo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
settings->setElement(m_element, m_key);

m_controller->selectElement(m_key);
}
}
void DestroySprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_key);
if(element != settings->elements().end()) {
m_element = element->second;
}
settings->removeElement(m_key);

m_controller->selectElement({});
}
}
22 changes: 22 additions & 0 deletions modules/editor/texturetools/editor/actions/destroysprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef DESTROYSPRITE_H
#define DESTROYSPRITE_H

#include <editor/undostack.h>
#include "../spritecontroller.h"

class DestroySprite : public UndoCommand {
public:
DestroySprite(SpriteController *ctrl, UndoCommand *group = nullptr);
void undo() override;
void redo() override;

protected:
TString m_key;

TextureImportSettings::Element m_element;

SpriteController *m_controller;

};

#endif // DESTROYSPRITE_H
30 changes: 30 additions & 0 deletions modules/editor/texturetools/editor/actions/renamesprite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "renamesprite.h"

#include "../spritecontroller.h"

RenameSprite::RenameSprite(const TString &oldKey, const TString &newKey, SpriteController *ctrl, UndoCommand *group) :
UndoCommand(QObject::tr("Rename Sprite Element").toStdString(), group),
m_oldKey(oldKey),
m_newKey(newKey),
m_controller(ctrl) {
}

void RenameSprite::undo() {
redo();
}

void RenameSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_oldKey);
if(element != settings->elements().end()) {
TextureImportSettings::Element temp = element->second;
settings->removeElement(m_oldKey);
settings->setElement(temp, m_newKey);

m_controller->selectElement(m_newKey);

std::swap(m_oldKey, m_newKey);
}
}
}
22 changes: 22 additions & 0 deletions modules/editor/texturetools/editor/actions/renamesprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef RENAMESPRITE_H
#define RENAMESPRITE_H

#include <editor/undostack.h>

class SpriteController;

class RenameSprite : public UndoCommand {
public:
RenameSprite(const TString &oldKey, const TString &newKey, SpriteController *ctrl, UndoCommand *group = nullptr);
void undo() override;
void redo() override;

protected:
TString m_newKey;
TString m_oldKey;

SpriteController *m_controller;

};

#endif // RENAMESPRITE_H
19 changes: 19 additions & 0 deletions modules/editor/texturetools/editor/actions/selectsprite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "selectsprite.h"

#include "../spritecontroller.h"

SelectSprite::SelectSprite(const TString &key, SpriteController *ctrl, UndoCommand *group) :
UndoCommand(QObject::tr("Select Sprite Elements").toStdString(), group),
m_key(key),
m_controller(ctrl) {
}

void SelectSprite::undo() {
redo();
}

void SelectSprite::redo() {
TString temp = m_controller->selectedElement();
m_controller->selectElement(m_key);
m_key = temp;
}
21 changes: 21 additions & 0 deletions modules/editor/texturetools/editor/actions/selectsprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef SELECTSPRITE_H
#define SELECTSPRITE_H

#include <editor/undostack.h>

class SpriteController;

class SelectSprite : public UndoCommand {
public:
SelectSprite(const TString &key, SpriteController *ctrl, UndoCommand *group = nullptr);
void undo() override;
void redo() override;

protected:
TString m_key;

SpriteController *m_controller;

};

#endif // SELECTSPRITE_H
27 changes: 27 additions & 0 deletions modules/editor/texturetools/editor/actions/updatesprite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "updatesprite.h"

UpdateSprite::UpdateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group) :
UndoCommand(QObject::tr("Update Sprite Element").toStdString(), group),
m_key(ctrl->selectedElement()),
m_element(element),
m_controller(ctrl) {
}

void UpdateSprite::undo() {
redo();
}

void UpdateSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_key);
if(element != settings->elements().end()) {
TextureImportSettings::Element temp = element->second;
settings->setElement(m_element, m_key);
m_element = temp;

m_controller->selectElement(m_key);
m_controller->updated();
}
}
}
22 changes: 22 additions & 0 deletions modules/editor/texturetools/editor/actions/updatesprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef UPDATESPRITE_H
#define UPDATESPRITE_H

#include <editor/undostack.h>
#include "../spritecontroller.h"

class UpdateSprite : public UndoCommand {
public:
UpdateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group = nullptr);
void undo() override;
void redo() override;

protected:
TString m_key;

TextureImportSettings::Element m_element;

SpriteController *m_controller;

};

#endif // UPDATESPRITE_H
114 changes: 0 additions & 114 deletions modules/editor/texturetools/editor/spritecontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "spritecontroller.h"

#include <QCursor>

#include <components/camera.h>
#include <components/actor.h>
#include <components/transform.h>
Expand Down Expand Up @@ -33,13 +31,6 @@ void SpriteController::setSettings(TextureImportSettings *settings) {
void SpriteController::setSize(uint32_t width, uint32_t height) {
m_width = width;
m_height = height;

Camera *cam = camera();
if(cam) {
cam->transform()->setPosition(Vector3(m_width * 0.5f, m_height * 0.5f, 1.0f));
cam->setOrthoSize(MAX(m_width, m_height));
cam->setFocalDistance(m_height);
}
}

bool SpriteController::isSelected(const TString &key) const {
Expand Down Expand Up @@ -78,108 +69,3 @@ void SpriteController::drawHandles() {

m_spriteTool->update(false, true, Input::isKey(Input::KEY_LEFT_CONTROL));
}

SelectSprite::SelectSprite(const TString &key, SpriteController *ctrl, UndoCommand *group) :
UndoSprite(ctrl, QObject::tr("Select Sprite Elements").toStdString(), group),
m_key(key) {
}
void SelectSprite::undo() {
redo();
}
void SelectSprite::redo() {
TString temp = m_controller->selectedElement();
m_controller->selectElement(m_key);
m_key = temp;
}

CreateSprite::CreateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group) :
UndoSprite(ctrl, QObject::tr("Create Sprite Element").toStdString(), group),
m_element(element) {
}
void CreateSprite::undo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
settings->removeElement(m_uuid);
m_controller->selectElement(m_key);
}
}
void CreateSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
m_uuid = settings->setElement(m_element, "");
m_key = m_controller->selectedElement();
m_controller->selectElement({m_uuid});
}
}

DestroySprite::DestroySprite(SpriteController *ctrl, UndoCommand *group) :
UndoSprite(ctrl, QObject::tr("Destroy Sprite Element").toStdString(), group),
m_key(ctrl->selectedElement()) {
}
void DestroySprite::undo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
settings->setElement(m_element, m_key);

m_controller->selectElement(m_key);
}
}
void DestroySprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_key);
if(element != settings->elements().end()) {
m_element = element->second;
}
settings->removeElement(m_key);

m_controller->selectElement({});
}
}

UpdateSprite::UpdateSprite(const TextureImportSettings::Element &element, SpriteController *ctrl, UndoCommand *group) :
UndoSprite(ctrl, QObject::tr("Update Sprite Element").toStdString(), group),
m_key(ctrl->selectedElement()),
m_element(element) {
}
void UpdateSprite::undo() {
redo();
}
void UpdateSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_key);
if(element != settings->elements().end()) {
TextureImportSettings::Element temp = element->second;
settings->setElement(m_element, m_key);
m_element = temp;

m_controller->selectElement(m_key);
m_controller->updated();
}
}
}

RenameSprite::RenameSprite(const TString &oldKey, const TString &newKey, SpriteController *ctrl, UndoCommand *group) :
UndoSprite(ctrl, QObject::tr("Rename Sprite Element").toStdString(), group),
m_oldKey(oldKey),
m_newKey(newKey) {
}
void RenameSprite::undo() {
redo();
}
void RenameSprite::redo() {
TextureImportSettings *settings = m_controller->settings();
if(settings) {
auto element = settings->elements().find(m_oldKey);
if(element != settings->elements().end()) {
TextureImportSettings::Element temp = element->second;
settings->removeElement(m_oldKey);
settings->setElement(temp, m_newKey);

m_controller->selectElement(m_newKey);

std::swap(m_oldKey, m_newKey);
}
}
}
Loading
Loading