| 
									
										
										
										
											2018-08-29 22:38:13 +02:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  visual_shader_editor_plugin.h                                        */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2020-01-01 11:16:22 +01:00
										 |  |  | /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2018-08-29 22:38:13 +02:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | #ifndef VISUAL_SHADER_EDITOR_PLUGIN_H
 | 
					
						
							|  |  |  | #define VISUAL_SHADER_EDITOR_PLUGIN_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "editor/editor_node.h"
 | 
					
						
							|  |  |  | #include "editor/editor_plugin.h"
 | 
					
						
							|  |  |  | #include "editor/property_editor.h"
 | 
					
						
							|  |  |  | #include "scene/gui/button.h"
 | 
					
						
							|  |  |  | #include "scene/gui/graph_edit.h"
 | 
					
						
							|  |  |  | #include "scene/gui/popup.h"
 | 
					
						
							|  |  |  | #include "scene/gui/tree.h"
 | 
					
						
							|  |  |  | #include "scene/resources/visual_shader.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderNodePlugin : public Reference { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(VisualShaderNodePlugin, Reference); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-08-05 17:13:02 +03:00
										 |  |  | 	virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderEditor : public VBoxContainer { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderEditor, VBoxContainer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	CustomPropertyEditor *property_editor; | 
					
						
							|  |  |  | 	int editing_node; | 
					
						
							|  |  |  | 	int editing_port; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<VisualShader> visual_shader; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 	HSplitContainer *main_box; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	GraphEdit *graph; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	ToolButton *add_node; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 	ToolButton *preview_shader; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	OptionButton *edit_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	PanelContainer *error_panel; | 
					
						
							|  |  |  | 	Label *error_label; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-25 09:22:09 +03:00
										 |  |  | 	bool pending_update_preview; | 
					
						
							| 
									
										
										
										
											2019-08-25 08:42:21 +03:00
										 |  |  | 	bool shader_error; | 
					
						
							|  |  |  | 	VBoxContainer *preview_vbox; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 	TextEdit *preview_text; | 
					
						
							| 
									
										
										
										
											2019-08-25 08:42:21 +03:00
										 |  |  | 	Label *error_text; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	UndoRedo *undo_redo; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	Point2 saved_node_pos; | 
					
						
							|  |  |  | 	bool saved_node_pos_dirty; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *members_dialog; | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 	PopupMenu *popup_menu; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	MenuButton *tools; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 	bool preview_showed; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	enum ToolsMenuOptions { | 
					
						
							|  |  |  | 		EXPAND_ALL, | 
					
						
							|  |  |  | 		COLLAPSE_ALL | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 	enum NodeMenuOptions { | 
					
						
							|  |  |  | 		ADD, | 
					
						
							|  |  |  | 		SEPARATOR, // ignore
 | 
					
						
							|  |  |  | 		COPY, | 
					
						
							| 
									
										
										
										
											2020-02-27 13:55:41 +03:00
										 |  |  | 		PASTE, | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 		DELETE, | 
					
						
							|  |  |  | 		DUPLICATE, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	Tree *members; | 
					
						
							|  |  |  | 	AcceptDialog *alert; | 
					
						
							|  |  |  | 	LineEdit *node_filter; | 
					
						
							|  |  |  | 	RichTextLabel *node_desc; | 
					
						
							| 
									
										
										
										
											2020-02-12 18:39:19 +03:00
										 |  |  | 	Label *highend_label; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _tools_menu_option(int p_idx); | 
					
						
							| 
									
										
										
										
											2019-04-15 07:23:22 +10:00
										 |  |  | 	void _show_members_dialog(bool at_mouse_pos); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _update_graph(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct AddOption { | 
					
						
							|  |  |  | 		String name; | 
					
						
							|  |  |  | 		String category; | 
					
						
							|  |  |  | 		String type; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 		String description; | 
					
						
							|  |  |  | 		int sub_func; | 
					
						
							|  |  |  | 		String sub_func_str; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 		Ref<Script> script; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 		int mode; | 
					
						
							|  |  |  | 		int return_type; | 
					
						
							| 
									
										
										
										
											2019-05-01 17:04:39 +03:00
										 |  |  | 		int func; | 
					
						
							| 
									
										
										
										
											2019-05-19 16:27:00 +03:00
										 |  |  | 		float value; | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 		bool highend; | 
					
						
							| 
									
										
										
										
											2019-08-09 22:51:48 +03:00
										 |  |  | 		bool is_custom; | 
					
						
							| 
									
										
										
										
											2020-02-14 15:11:55 +03:00
										 |  |  | 		int temp_idx; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 		AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_sub_category = String(), const String &p_type = String(), const String &p_description = String(), int p_sub_func = -1, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) { | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			name = p_name; | 
					
						
							|  |  |  | 			type = p_type; | 
					
						
							| 
									
										
										
										
											2020-02-14 15:11:55 +03:00
										 |  |  | 			category = p_category + "/" + p_sub_category; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			description = p_description; | 
					
						
							|  |  |  | 			sub_func = p_sub_func; | 
					
						
							|  |  |  | 			return_type = p_return_type; | 
					
						
							|  |  |  | 			mode = p_mode; | 
					
						
							| 
									
										
										
										
											2019-05-01 17:04:39 +03:00
										 |  |  | 			func = p_func; | 
					
						
							| 
									
										
										
										
											2019-05-19 16:27:00 +03:00
										 |  |  | 			value = p_value; | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 			highend = p_highend; | 
					
						
							| 
									
										
										
										
											2019-08-09 22:51:48 +03:00
										 |  |  | 			is_custom = false; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 		AddOption(const String &p_name, const String &p_category, const String &p_sub_category, const String &p_type, const String &p_description, const String &p_sub_func, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) { | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 			name = p_name; | 
					
						
							|  |  |  | 			type = p_type; | 
					
						
							| 
									
										
										
										
											2020-02-14 15:11:55 +03:00
										 |  |  | 			category = p_category + "/" + p_sub_category; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			description = p_description; | 
					
						
							| 
									
										
										
										
											2019-10-04 10:43:59 +03:00
										 |  |  | 			sub_func = 0; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			sub_func_str = p_sub_func; | 
					
						
							|  |  |  | 			return_type = p_return_type; | 
					
						
							|  |  |  | 			mode = p_mode; | 
					
						
							| 
									
										
										
										
											2019-05-01 17:04:39 +03:00
										 |  |  | 			func = p_func; | 
					
						
							| 
									
										
										
										
											2019-05-19 16:27:00 +03:00
										 |  |  | 			value = p_value; | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 			highend = p_highend; | 
					
						
							| 
									
										
										
										
											2019-08-09 22:51:48 +03:00
										 |  |  | 			is_custom = false; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2020-02-14 15:11:55 +03:00
										 |  |  | 	struct _OptionComparator { | 
					
						
							|  |  |  | 		_FORCE_INLINE_ bool operator()(const AddOption &a, const AddOption &b) const { | 
					
						
							|  |  |  | 			return a.category.count("/") > b.category.count("/") || (a.category + "/" + a.name).naturalnocasecmp_to(b.category + "/" + b.name) < 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Vector<AddOption> add_options; | 
					
						
							| 
									
										
										
										
											2019-09-30 14:25:32 +03:00
										 |  |  | 	int texture_node_option_idx; | 
					
						
							| 
									
										
										
										
											2019-10-02 23:26:56 +03:00
										 |  |  | 	int custom_node_option_idx; | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	List<String> keyword_list; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _draw_color_over_button(Object *obj, Color p_color); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 23:26:56 +03:00
										 |  |  | 	void _add_custom_node(const String &p_path); | 
					
						
							| 
									
										
										
										
											2019-09-30 14:25:32 +03:00
										 |  |  | 	void _add_texture_node(const String &p_path); | 
					
						
							|  |  |  | 	VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _update_options_menu(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-18 13:27:08 -03:00
										 |  |  | 	void _show_preview_text(); | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 	void _update_preview(); | 
					
						
							| 
									
										
										
										
											2019-08-25 13:06:16 +03:00
										 |  |  | 	String _get_description(int p_idx); | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	static VisualShaderEditor *singleton; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node); | 
					
						
							|  |  |  | 	bool updating; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index); | 
					
						
							|  |  |  | 	void _disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _scroll_changed(const Vector2 &p_scroll); | 
					
						
							|  |  |  | 	void _node_selected(Object *p_node); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _delete_request(int); | 
					
						
							| 
									
										
										
										
											2020-02-27 13:55:41 +03:00
										 |  |  | 	void _delete_nodes(); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _removed_from_graph(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _node_changed(int p_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _edit_port_default_input(Object *p_button, int p_node, int p_port); | 
					
						
							|  |  |  | 	void _port_edited(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-26 21:50:38 +03:00
										 |  |  | 	int to_node; | 
					
						
							|  |  |  | 	int to_slot; | 
					
						
							|  |  |  | 	int from_node; | 
					
						
							|  |  |  | 	int from_slot; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position); | 
					
						
							| 
									
										
										
										
											2019-06-26 21:50:38 +03:00
										 |  |  | 	void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _line_edit_changed(const String &p_text, Object *line_edit, int p_node_id); | 
					
						
							|  |  |  | 	void _line_edit_focus_out(Object *line_edit, int p_node_id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 	void _dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int> &r_excluded); | 
					
						
							|  |  |  | 	void _dup_update_excluded(int p_type, Set<int> &r_excluded); | 
					
						
							| 
									
										
										
										
											2019-08-07 16:46:47 +03:00
										 |  |  | 	void _dup_paste_nodes(int p_type, int p_pasted_type, List<int> &r_nodes, Set<int> &r_excluded, const Vector2 &p_offset, bool p_select); | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _duplicate_nodes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 	Vector2 selection_center; | 
					
						
							|  |  |  | 	int copy_type; // shader type
 | 
					
						
							|  |  |  | 	List<int> copy_nodes_buffer; | 
					
						
							|  |  |  | 	Set<int> copy_nodes_excluded_buffer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _clear_buffer(); | 
					
						
							|  |  |  | 	void _copy_nodes(); | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 	void _paste_nodes(bool p_use_custom_position = false, const Vector2 &p_custom_position = Vector2()); | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 07:33:00 +01:00
										 |  |  | 	Vector<Ref<VisualShaderNodePlugin>> plugins; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _mode_selected(int p_id); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	void _rebuild(); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _input_select_item(Ref<VisualShaderNodeInput> input, String name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-26 15:08:25 +02:00
										 |  |  | 	void _add_input_port(int p_node, int p_port, int p_port_type, const String &p_name); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	void _remove_input_port(int p_node, int p_port); | 
					
						
							|  |  |  | 	void _change_input_port_type(int p_type, int p_node, int p_port); | 
					
						
							|  |  |  | 	void _change_input_port_name(const String &p_text, Object *line_edit, int p_node, int p_port); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-26 15:08:25 +02:00
										 |  |  | 	void _add_output_port(int p_node, int p_port, int p_port_type, const String &p_name); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	void _remove_output_port(int p_node, int p_port); | 
					
						
							|  |  |  | 	void _change_output_port_type(int p_type, int p_node, int p_port); | 
					
						
							|  |  |  | 	void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-22 07:39:08 +03:00
										 |  |  | 	void _expression_focus_out(Object *text_edit, int p_node); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _set_node_size(int p_type, int p_node, const Size2 &p_size); | 
					
						
							|  |  |  | 	void _node_resized(const Vector2 &p_new_size, int p_type, int p_node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _preview_select_port(int p_node, int p_port); | 
					
						
							| 
									
										
										
										
											2019-07-10 11:54:12 +02:00
										 |  |  | 	void _graph_gui_input(const Ref<InputEvent> &p_event); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	void _member_filter_changed(const String &p_text); | 
					
						
							| 
									
										
										
										
											2019-04-15 07:23:22 +10:00
										 |  |  | 	void _sbox_input(const Ref<InputEvent> &p_ie); | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	void _member_selected(); | 
					
						
							|  |  |  | 	void _member_unselected(); | 
					
						
							|  |  |  | 	void _member_create(); | 
					
						
							| 
									
										
										
										
											2019-06-26 21:50:38 +03:00
										 |  |  | 	void _member_cancel(); | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 	Vector2 menu_point; | 
					
						
							|  |  |  | 	void _node_menu_id_pressed(int p_idx); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); | 
					
						
							|  |  |  | 	bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; | 
					
						
							|  |  |  | 	void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-26 15:08:25 +02:00
										 |  |  | 	bool _is_available(int p_mode); | 
					
						
							| 
									
										
										
										
											2019-04-26 10:53:40 +03:00
										 |  |  | 	void _update_created_node(GraphNode *node); | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-10-02 23:26:56 +03:00
										 |  |  | 	void update_custom_nodes(); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); | 
					
						
							|  |  |  | 	void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	static VisualShaderEditor *get_singleton() { return singleton; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-09 22:51:48 +03:00
										 |  |  | 	void clear_custom_types(); | 
					
						
							| 
									
										
										
										
											2020-02-14 15:11:55 +03:00
										 |  |  | 	void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual Size2 get_minimum_size() const; | 
					
						
							|  |  |  | 	void edit(VisualShader *p_visual_shader); | 
					
						
							|  |  |  | 	VisualShaderEditor(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderEditorPlugin : public EditorPlugin { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderEditorPlugin, EditorPlugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	VisualShaderEditor *visual_shader_editor; | 
					
						
							|  |  |  | 	EditorNode *editor; | 
					
						
							|  |  |  | 	Button *button; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual String get_name() const { return "VisualShader"; } | 
					
						
							|  |  |  | 	bool has_main_screen() const { return false; } | 
					
						
							|  |  |  | 	virtual void edit(Object *p_object); | 
					
						
							|  |  |  | 	virtual bool handles(Object *p_object) const; | 
					
						
							|  |  |  | 	virtual void make_visible(bool p_visible); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	VisualShaderEditorPlugin(EditorNode *p_node); | 
					
						
							|  |  |  | 	~VisualShaderEditorPlugin(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderNodePluginDefault : public VisualShaderNodePlugin { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(VisualShaderNodePluginDefault, VisualShaderNodePlugin); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-08-05 17:13:02 +03:00
										 |  |  | 	virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class EditorPropertyShaderMode : public EditorProperty { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(EditorPropertyShaderMode, EditorProperty); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	OptionButton *options; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _option_selected(int p_which); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	void setup(const Vector<String> &p_options); | 
					
						
							|  |  |  | 	virtual void update_property(); | 
					
						
							|  |  |  | 	void set_option_button_clip(bool p_enable); | 
					
						
							|  |  |  | 	EditorPropertyShaderMode(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class EditorInspectorShaderModePlugin : public EditorInspectorPlugin { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(EditorInspectorShaderModePlugin, EditorInspectorPlugin); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual bool can_handle(Object *p_object); | 
					
						
							|  |  |  | 	virtual void parse_begin(Object *p_object); | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 	virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	virtual void parse_end(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderNodePortPreview : public Control { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(VisualShaderNodePortPreview, Control); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	Ref<VisualShader> shader; | 
					
						
							|  |  |  | 	VisualShader::Type type; | 
					
						
							|  |  |  | 	int node; | 
					
						
							|  |  |  | 	int port; | 
					
						
							|  |  |  | 	void _shader_changed(); //must regen
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual Size2 get_minimum_size() const; | 
					
						
							|  |  |  | 	void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port); | 
					
						
							|  |  |  | 	VisualShaderNodePortPreview(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-28 14:51:51 +03:00
										 |  |  | class VisualShaderConversionPlugin : public EditorResourceConversionPlugin { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderConversionPlugin, EditorResourceConversionPlugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual String converts_to() const; | 
					
						
							|  |  |  | 	virtual bool handles(const Ref<Resource> &p_resource) const; | 
					
						
							|  |  |  | 	virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | #endif // VISUAL_SHADER_EDITOR_PLUGIN_H
 |