NodeEditor -> GraphEditor
This commit is contained in:
parent
fa004284e6
commit
306419cd65
@ -1,10 +1,10 @@
|
|||||||
#include "gui.hpp"
|
#include "gui.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "NodeEditor.hpp"
|
#include "GraphEditor.hpp"
|
||||||
|
|
||||||
namespace GraphC::gui {
|
namespace GraphC::gui {
|
||||||
|
|
||||||
void NodeEditor::drawNode(const GraphModel::Node& node){
|
void GraphEditor::drawNode(const GraphModel::Node& node){
|
||||||
ImNodes::BeginNode(node.id);
|
ImNodes::BeginNode(node.id);
|
||||||
ImNodes::BeginNodeTitleBar();
|
ImNodes::BeginNodeTitleBar();
|
||||||
ImGui::TextUnformatted(node.title.c_str());
|
ImGui::TextUnformatted(node.title.c_str());
|
||||||
@ -81,7 +81,7 @@ void NodeEditor::drawNode(const GraphModel::Node& node){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphModel::Node* NodeEditor::CreateExampleNode(std::string title){
|
GraphModel::Node* GraphEditor::CreateExampleNode(std::string title){
|
||||||
GraphModel::Node* n = graph.createNode(GraphModel::Node(graph.id_gen.getNext(), title));
|
GraphModel::Node* n = graph.createNode(GraphModel::Node(graph.id_gen.getNext(), title));
|
||||||
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Input, "In"));
|
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Input, "In"));
|
||||||
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Output, "Out"));
|
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Output, "Out"));
|
||||||
@ -89,7 +89,7 @@ GraphModel::Node* NodeEditor::CreateExampleNode(std::string title){
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeEditor::NodeEditor(std::string _title)
|
GraphEditor::GraphEditor(std::string _title)
|
||||||
: title(_title)
|
: title(_title)
|
||||||
{
|
{
|
||||||
// CreateExampleNode("Node A");
|
// CreateExampleNode("Node A");
|
||||||
@ -102,15 +102,15 @@ NodeEditor::NodeEditor(std::string _title)
|
|||||||
std::cout<<graph.getAttributes().generateGraphVizCode()<<std::endl;
|
std::cout<<graph.getAttributes().generateGraphVizCode()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeEditor::show(){
|
void GraphEditor::show(){
|
||||||
editor_open = true;
|
editor_open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeEditor::hide(){
|
void GraphEditor::hide(){
|
||||||
editor_open = false;
|
editor_open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeEditor::draw(){
|
void GraphEditor::draw(){
|
||||||
if(!editor_open)
|
if(!editor_open)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace GraphC::gui {
|
namespace GraphC::gui {
|
||||||
|
|
||||||
class NodeEditor {
|
class GraphEditor {
|
||||||
std::string title=nullptr;
|
std::string title=nullptr;
|
||||||
bool editor_open=false;
|
bool editor_open=false;
|
||||||
ImNodesContext* editor_context=nullptr;
|
ImNodesContext* editor_context=nullptr;
|
||||||
@ -16,7 +16,7 @@ class NodeEditor {
|
|||||||
GraphModel::Node* CreateExampleNode(std::string title);
|
GraphModel::Node* CreateExampleNode(std::string title);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NodeEditor(std::string _title);
|
GraphEditor(std::string _title);
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void show();
|
void show();
|
||||||
@ -75,7 +75,7 @@ void GUI::init(const char* window_title){
|
|||||||
ImNodes::CreateContext();
|
ImNodes::CreateContext();
|
||||||
ImNodes::StyleColorsDark();
|
ImNodes::StyleColorsDark();
|
||||||
ImNodes::PushAttributeFlag(ImNodesAttributeFlags_EnableLinkDetachWithDragClick);
|
ImNodes::PushAttributeFlag(ImNodesAttributeFlags_EnableLinkDetachWithDragClick);
|
||||||
node_editor = new NodeEditor("node editor");
|
node_editor = new GraphEditor("node editor");
|
||||||
node_editor->show();
|
node_editor->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "../../dependencies/SDL2/include/SDL_opengl.h"
|
#include "../../dependencies/SDL2/include/SDL_opengl.h"
|
||||||
#include "../../dependencies/imgui/imgui.h"
|
#include "../../dependencies/imgui/imgui.h"
|
||||||
#include "../format.hpp"
|
#include "../format.hpp"
|
||||||
#include "NodeEditor.hpp"
|
#include "GraphEditor.hpp"
|
||||||
#include "imgui_extensions.hpp"
|
#include "imgui_extensions.hpp"
|
||||||
#include "fonts.hpp"
|
#include "fonts.hpp"
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
@ -36,7 +36,7 @@ private:
|
|||||||
bool show_metrics_window = false;
|
bool show_metrics_window = false;
|
||||||
SDL_Window* sdl_window;
|
SDL_Window* sdl_window;
|
||||||
SDL_GLContext gl_context;
|
SDL_GLContext gl_context;
|
||||||
NodeEditor* node_editor = nullptr;
|
GraphEditor* node_editor = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init(const char* window_title);
|
void init(const char* window_title);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user