-Work in progress visual shader editor *DOES NOT WORK YET*

This commit is contained in:
Juan Linietsky 2015-01-03 16:52:37 -03:00
parent eb1f978b1c
commit fbdd925d9b
51 changed files with 4587 additions and 2172 deletions

View file

@ -29,122 +29,121 @@
#ifndef SHADER_GRAPH_EDITOR_PLUGIN_H
#define SHADER_GRAPH_EDITOR_PLUGIN_H
#if 0
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/resources/shader.h"
#include "servers/visual/shader_graph.h"
#include "scene/gui/tree.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/popup.h"
#include "tools/editor/property_editor.h"
#include "scene/resources/shader_graph.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class ShaderEditor : public Control {
OBJ_TYPE(ShaderEditor, Control );
class ShaderGraphView : public Node {
enum MenuAction {
OBJ_TYPE(ShaderGraphView,Node);
GRAPH_ADD_NODE,
GRAPH_CLEAR,
NODE_DISCONNECT,
NODE_ERASE,
};
enum ClickType {
CLICK_NONE,
CLICK_NODE,
CLICK_INPUT_SLOT,
CLICK_OUTPUT_SLOT,
CLICK_PARAMETER
};
CustomPropertyEditor *ped_popup;
bool block_update;
PopupMenu *node_popup;
Popup *add_popup;
PopupMenu *vertex_popup;
PopupMenu *fragment_popup;
PopupMenu *post_popup;
Tree *add_types;
Button *add_confirm;
HScrollBar *h_scroll;
VScrollBar *v_scroll;
GraphEdit *graph_edit;
Ref<ShaderGraph> graph;
int edited_id;
Ref<Shader> shader;
List<int> order;
Set<int> active_nodes;
ShaderGraph shader_graph;
int last_x,last_y;
uint32_t last_id;
ShaderGraph::ShaderType type;
CustomPropertyEditor *property_editor;
void _update_graph();
void _create_node(int p_id);
Point2 offset;
ClickType click_type;
Point2 click_pos;
int click_node;
int click_slot;
Point2 click_motion;
ClickType rclick_type;
int rclick_node;
int rclick_slot;
Size2 _get_maximum_size();
Size2 get_node_size(int p_node) const;
void _draw_node(int p_node);
void _add_node_from_text(const String& p_text);
void _update_scrollbars();
void _scroll_moved();
void _node_param_changed();
void _node_add_callback();
void _node_add(VisualServer::ShaderNodeType p_type);
void _node_edit_property(int p_node);
void _node_menu_item(int p_item);
void _vertex_item(int p_item);
void _fragment_item(int p_item);
void _post_item(int p_item);
void _connection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
void _node_removed(int p_id);
void _node_moved(const Vector2& p_from, const Vector2& p_to,int p_id);
void _move_node(int p_id,const Vector2& p_to);
ClickType _locate_click(const Point2& p_click,int *p_node_id,int *p_slot_index) const;
Point2 _get_slot_pos(int p_node_id,bool p_input,int p_slot);
void _scalar_const_changed(double p_value,int p_id);
void _vec_const_changed(double p_value, int p_id, Array p_arr);
void _rgb_const_changed(const Color& p_color, int p_id);
void _xform_const_changed(int p_id,Node* p_button);
void _scalar_op_changed(int p_op, int p_id);
void _vec_op_changed(int p_op, int p_id);
void _vec_scalar_op_changed(int p_op, int p_id);
void _rgb_op_changed(int p_op, int p_id);
void _xform_inv_rev_changed(bool p_enabled, int p_id);
void _scalar_func_changed(int p_func, int p_id);
void _vec_func_changed(int p_func, int p_id);
void _scalar_input_changed(double p_value,int p_id);
void _vec_input_changed(double p_value, int p_id, Array p_arr);
void _xform_input_changed(int p_id,Node* p_button);
void _rgb_input_changed(const Color& p_color, int p_id);
void _tex_input_change(int p_id,Node* p_button);
void _cube_input_change(int p_id);
void _input_name_changed(const String& p_name,int p_id,Node* p_line_edit);
void _tex_edited(int p_id,Node* p_button);
void _cube_edited(int p_id,Node* p_button);
void _variant_edited();
void _comment_edited(int p_id,Node* p_button);
Error validate_graph();
void _read_shader_graph();
void _write_shader_graph();
virtual bool has_point(const Point2& p_point) const;
Map<int,GraphNode*> node_map;
protected:
void _notification(int p_what);
void _input_event(InputEvent p_event);
static void _bind_methods();
public:
void edit(Ref<Shader> p_shader);
ShaderEditor();
void add_node(int p_type);
GraphEdit *get_graph_edit() { return graph_edit; }
void set_graph(Ref<ShaderGraph> p_graph);
ShaderGraphView(ShaderGraph::ShaderType p_type=ShaderGraph::SHADER_TYPE_FRAGMENT);
};
class ShaderEditorPlugin : public EditorPlugin {
class ShaderGraphEditor : public VBoxContainer {
OBJ_TYPE( ShaderEditorPlugin, EditorPlugin );
OBJ_TYPE(ShaderGraphEditor,VBoxContainer);
ShaderEditor *shader_editor;
MenuButton *menu;
TabContainer *tabs;
ShaderGraphView *graph_edits[ShaderGraph::SHADER_TYPE_MAX];
static const char* node_names[ShaderGraph::NODE_TYPE_MAX];
void _add_node(int p_type);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void edit(Ref<ShaderGraph> p_shader);
ShaderGraphEditor();
};
class ShaderGraphEditorPlugin : public EditorPlugin {
OBJ_TYPE( ShaderGraphEditorPlugin, EditorPlugin );
ShaderGraphEditor *shader_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "Shader"; }
virtual String get_name() const { return "ShaderGraph"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
ShaderEditorPlugin(EditorNode *p_node);
~ShaderEditorPlugin();
ShaderGraphEditorPlugin(EditorNode *p_node);
~ShaderGraphEditorPlugin();
};
#endif
#endif // SHADER_GRAPH_EDITOR_PLUGIN_H