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
10 changes: 7 additions & 3 deletions modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ AbstractNodeGraph::AbstractNodeGraph() :
m_version(0) {
}

GraphNode *AbstractNodeGraph::nodeCreate(const TString &path, int &index) {
return nullptr;
}

void AbstractNodeGraph::nodeDelete(GraphNode *node) {
auto it = m_nodes.begin();
while(it != m_nodes.end()) {
Expand Down Expand Up @@ -212,15 +216,15 @@ void AbstractNodeGraph::load(const TString &path) {

blockSignals(false);

emit graphUpdated();
emitSignal(_SIGNAL(graphUpdated()));

if(version != m_version) {
save(path);
}
}
}

emit graphLoaded();
emitSignal(_SIGNAL(graphLoaded()));
}

void AbstractNodeGraph::save(const TString &path) {
Expand Down Expand Up @@ -334,5 +338,5 @@ const AbstractNodeGraph::LinkList &AbstractNodeGraph::links() const {
}

void AbstractNodeGraph::reportMessage(GraphNode *node, const TString &text) {
emit messageReported(AbstractNodeGraph::node(node), text);

}
17 changes: 8 additions & 9 deletions modules/editor/grapheditor/editor/graph/abstractnodegraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

class Texture;

class NODEGRAPH_EXPORT AbstractNodeGraph : public QObject {
Q_OBJECT
class NODEGRAPH_EXPORT AbstractNodeGraph : public Object {
A_OBJECT(AbstractNodeGraph, Object, Editor)

A_METHODS(
A_SIGNAL(AbstractNodeGraph::graphUpdated),
A_SIGNAL(AbstractNodeGraph::graphLoaded)
)

public:
struct Link {
Expand All @@ -32,9 +37,7 @@ class NODEGRAPH_EXPORT AbstractNodeGraph : public QObject {
public:
AbstractNodeGraph();

AbstractNodeGraph(const AbstractNodeGraph &) { assert(false && "DONT EVER USE THIS"); }

virtual GraphNode *nodeCreate(const TString &path, int &index) = 0;
virtual GraphNode *nodeCreate(const TString &path, int &index);
virtual void nodeDelete(GraphNode *node);

virtual Link *linkCreate(GraphNode *sender, NodePort *oport, GraphNode *receiver, NodePort *iport);
Expand Down Expand Up @@ -70,10 +73,6 @@ class NODEGRAPH_EXPORT AbstractNodeGraph : public QObject {
void graphUpdated();
void graphLoaded();

void messageReported(int node, const TString &text);

void menuVisible(bool visible);

protected:
virtual void loadGraph(const pugi::xml_node &parent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void ChangeNodeProperty::redo() {

auto g = m_controller->graph();

g->graphUpdated();
g->emitSignal(_SIGNAL(graphUpdated()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void CreateLink::undo() {
AbstractNodeGraph::Link *link = g->link(m_index);
if(link) {
g->linkDelete(link);
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}
}

Expand All @@ -32,6 +33,7 @@ void CreateLink::redo() {

AbstractNodeGraph::Link *link = g->linkCreate(snd, op, rcv, ip);
m_index = g->link(link);
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void CreateNode::undo() {
auto g = m_controller->graph();
g->nodeDelete(g->node(m_node));
m_controller->selectNodes(m_list);
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}

void CreateNode::redo() {
Expand Down Expand Up @@ -64,5 +65,6 @@ void CreateNode::redo() {
}

m_controller->selectNodes({m_node});
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void DeleteLinksByPort::undo() {
g->linkCreate(snd, op, rcv, ip);
}
}
emit g->graphUpdated();
g->emitSignal(_SIGNAL(graphUpdated()));
}

void DeleteLinksByPort::redo() {
Expand Down Expand Up @@ -52,6 +52,6 @@ void DeleteLinksByPort::redo() {
}
g->linkDelete(item);
}
emit g->graphUpdated();
g->emitSignal(_SIGNAL(graphUpdated()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ void DeleteNodes::redo() {
g->nodeDelete(it);
}

emit g->graphUpdated();
g->emitSignal(_SIGNAL(graphUpdated()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void PasteNodes::undo() {
g->nodeDelete(g->node(it));
}
m_controller->selectNodes(m_lastSelect);
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}

void PasteNodes::redo() {
Expand Down Expand Up @@ -60,5 +61,6 @@ void PasteNodes::redo() {
}

m_controller->selectNodes(m_list);
emit g->graphUpdated();

g->emitSignal(_SIGNAL(graphUpdated()));
}
37 changes: 25 additions & 12 deletions modules/editor/grapheditor/editor/graph/graphview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ namespace {
const char *gFrame("Frame");
};

class ObjectObserver : public Object {
A_OBJECT(ObjectObserver, Object, Editor)
class GraphViewProxy : public Object {
A_OBJECT(GraphViewProxy, Object, Proxy)

A_METHODS(
A_SLOT(ObjectObserver::onPortPressed),
A_SLOT(ObjectObserver::onPortReleased)
A_SLOT(GraphViewProxy::onPortPressed),
A_SLOT(GraphViewProxy::onPortReleased),
A_SLOT(GraphViewProxy::onGraphUpdated),
A_SLOT(GraphViewProxy::onGraphLoaded)
)

public:
ObjectObserver() :
GraphViewProxy() :
m_view(nullptr) {

}
Expand Down Expand Up @@ -75,6 +77,18 @@ class ObjectObserver : public Object {
}
}

void onGraphUpdated() {
if(m_view) {
m_view->onGraphUpdated();
}
}

void onGraphLoaded() {
if(m_view) {
m_view->onGraphLoaded();
}
}

private:
GraphView *m_view;

Expand All @@ -85,7 +99,7 @@ GraphView::GraphView(QWidget *parent) :
m_scene(nullptr),
m_view(nullptr),
m_createMenu(new QMenu(this)),
m_objectObserver(new ObjectObserver),
m_proxy(new GraphViewProxy),
m_linksRender(nullptr),
m_rubberBand(nullptr),
m_updateLinks(false) {
Expand All @@ -104,7 +118,7 @@ GraphView::GraphView(QWidget *parent) :
firtCall = false;
}

m_objectObserver->setView(this);
m_proxy->setView(this);

connect(static_cast<GraphController *>(m_controller), &GraphController::copied, this, &GraphView::copied);

Expand Down Expand Up @@ -138,9 +152,8 @@ AbstractNodeGraph *GraphView::graph() const {
void GraphView::setGraph(AbstractNodeGraph *graph) {
static_cast<GraphController *>(m_controller)->setGraph(graph);

connect(graph, &AbstractNodeGraph::graphUpdated, this, &GraphView::onGraphUpdated);
connect(graph, &AbstractNodeGraph::graphLoaded, this, &GraphView::onGraphLoaded);
connect(graph, &AbstractNodeGraph::menuVisible, this, &GraphView::onInProgressFlag);
Object::connect(graph, _SIGNAL(graphUpdated()), m_proxy, _SLOT(onGraphUpdated()));
Object::connect(graph, _SIGNAL(graphLoaded()), m_proxy, _SLOT(onGraphLoaded()));

StringList nodeList = graph->nodeList();

Expand Down Expand Up @@ -298,8 +311,8 @@ void GraphView::onGraphUpdated() {
if(actor->parent() == nullptr) {
actor->setParent(m_view);

Object::connect(widget, _SIGNAL(portPressed(int)), m_objectObserver, _SLOT(onPortPressed(int)));
Object::connect(widget, _SIGNAL(portReleased(int)), m_objectObserver, _SLOT(onPortReleased(int)));
Object::connect(widget, _SIGNAL(portPressed(int)), m_proxy, _SLOT(onPortPressed(int)));
Object::connect(widget, _SIGNAL(portReleased(int)), m_proxy, _SLOT(onPortReleased(int)));
}

RectTransform *rect = widget->rectTransform();
Expand Down
10 changes: 5 additions & 5 deletions modules/editor/grapheditor/editor/graph/graphview.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class QMenu;

class ObjectObserver;
class GraphViewProxy;
class NodeWidget;
class LinksRender;
class Frame;
Expand Down Expand Up @@ -54,13 +54,13 @@ class NODEGRAPH_EXPORT GraphView : public Viewport {
public slots:
void onObjectsChanged(const Object::ObjectList &objects, QString property, const Variant &value);

private slots:
void onComponentSelected();

void onGraphUpdated();

void onGraphLoaded();

private slots:
void onComponentSelected();

void onDraw() override;

private:
Expand All @@ -73,7 +73,7 @@ private slots:

QMenu *m_createMenu;

ObjectObserver *m_objectObserver;
GraphViewProxy *m_proxy;

LinksRender *m_linksRender;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <editor/graph/abstractnodegraph.h>

class AnimationControllerGraph : public AbstractNodeGraph {
Q_OBJECT

public:
AnimationControllerGraph();

Expand Down
34 changes: 29 additions & 5 deletions modules/editor/motiontools/editor/animationedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,40 @@

#include "../converter/animationbuilder.h"

class AnimationProxy : public Object {
A_OBJECT(AnimationProxy, Object, Proxy)

A_METHODS(
A_SLOT(AnimationProxy::onGraphUpdated)
)
public:
void setEditor(AnimationEdit *editor) {
m_editor = editor;
}

void onGraphUpdated() {
m_editor->updated();
}

private:
AnimationEdit *m_editor = nullptr;

};

AnimationEdit::AnimationEdit() :
ui(new Ui::AnimationEdit),
m_graph(new AnimationControllerGraph),
m_assetConverter(new AnimationControllerBuilder),
m_stateMachine(nullptr),
m_lastCommand(nullptr) {
m_lastCommand(nullptr),
m_proxy(new AnimationProxy) {

ui->setupUi(this);

connect(m_graph, &AnimationControllerGraph::graphUpdated, this, &AnimationEdit::updated);
m_proxy->setEditor(this);

Object::connect(m_graph, _SIGNAL(graphUpdated), m_proxy, _SLOT(onGraphUpdated()));

connect(ui->schemeWidget, &GraphView::objectsSelected, this, &AnimationEdit::objectsSelected);

ui->schemeWidget->init();
Expand All @@ -32,7 +56,7 @@ AnimationEdit::~AnimationEdit() {
}

bool AnimationEdit::isModified() const {
return (UndoManager::instance()->lastCommand(m_graph) != m_lastCommand);
return (UndoManager::instance()->lastCommand(this) != m_lastCommand);
}

QStringList AnimationEdit::suffixes() const {
Expand Down Expand Up @@ -75,15 +99,15 @@ void AnimationEdit::loadAsset(AssetConverterSettings *settings) {

m_graph->load(settings->source().toStdString());

m_lastCommand = UndoManager::instance()->lastCommand(m_graph);
m_lastCommand = UndoManager::instance()->lastCommand(this);
}
}

void AnimationEdit::saveAsset(const QString &path) {
if(!path.isEmpty() || !m_settings.first()->source().isEmpty()) {
m_graph->save(path.isEmpty() ? m_settings.first()->source().toStdString() : path.toStdString());

m_lastCommand = UndoManager::instance()->lastCommand(m_graph);
m_lastCommand = UndoManager::instance()->lastCommand(this);
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/editor/motiontools/editor/animationedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AssetConverter;

class UndoCommand;

class AnimationProxy;

namespace Ui {
class AnimationEdit;
}
Expand Down Expand Up @@ -54,6 +56,8 @@ private slots:

const UndoCommand *m_lastCommand;

AnimationProxy *m_proxy;

};

#endif // ANIMATIONEDIT_H
2 changes: 1 addition & 1 deletion modules/editor/particletools/converter/effectbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void EffectBuilderSettings::setThumbnailWarmup(float value) {
}

EffectBuilder::EffectBuilder() {
connect(&m_graph, &EffectGraph::effectUpdated, this, &EffectBuilder::effectUpdated);

}

int EffectBuilder::version() {
Expand Down
3 changes: 0 additions & 3 deletions modules/editor/particletools/converter/effectbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class EffectBuilder : public AssetConverter {

void convertOld(const QString &path);

signals:
void effectUpdated();

private:
EffectGraph m_graph;

Expand Down
Loading
Loading