| 
									
										
										
										
											2018-08-29 22:38:13 +02:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  visual_shader_editor_plugin.h                                        */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2022-01-03 21:27:34 +01:00
										 |  |  | /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2022 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_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2022-11-11 20:12:48 +01:00
										 |  |  | #include "editor/editor_properties.h"
 | 
					
						
							| 
									
										
										
										
											2022-07-31 21:14:15 +03:00
										 |  |  | #include "editor/plugins/editor_resource_conversion_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2022-11-19 12:45:49 +01:00
										 |  |  | #include "scene/resources/syntax_highlighter.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | #include "scene/resources/visual_shader.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-19 12:45:49 +01:00
										 |  |  | class CodeEdit; | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | class CurveEditor; | 
					
						
							|  |  |  | class GraphEdit; | 
					
						
							|  |  |  | class GraphNode; | 
					
						
							| 
									
										
										
										
											2022-11-19 12:45:49 +01:00
										 |  |  | class MenuButton; | 
					
						
							|  |  |  | class PopupPanel; | 
					
						
							|  |  |  | class RichTextLabel; | 
					
						
							|  |  |  | class Tree; | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | class VisualShaderEditor; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 18:03:15 +02:00
										 |  |  | class VisualShaderNodePlugin : public RefCounted { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderNodePlugin, RefCounted); | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	VisualShaderEditor *vseditor = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-03 01:43:50 +02:00
										 |  |  | 	GDVIRTUAL2RC(Object *, _create_editor, Ref<Resource>, Ref<VisualShaderNode>) | 
					
						
							| 
									
										
										
										
											2021-08-21 22:52:44 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | 	void set_editor(VisualShaderEditor *p_editor); | 
					
						
							| 
									
										
										
										
											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
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 18:03:15 +02:00
										 |  |  | class VisualShaderGraphPlugin : public RefCounted { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderGraphPlugin, RefCounted); | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | 	VisualShaderEditor *editor = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	struct InputPort { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		Button *default_input_button = nullptr; | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	struct Port { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		TextureButton *preview_button = nullptr; | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct Link { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		VisualShader::Type type = VisualShader::Type::TYPE_MAX; | 
					
						
							|  |  |  | 		VisualShaderNode *visual_node = nullptr; | 
					
						
							|  |  |  | 		GraphNode *graph_node = nullptr; | 
					
						
							| 
									
										
										
										
											2021-04-05 13:16:16 +02:00
										 |  |  | 		bool preview_visible = false; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		int preview_pos = 0; | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 		HashMap<int, InputPort> input_ports; | 
					
						
							|  |  |  | 		HashMap<int, Port> output_ports; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		VBoxContainer *preview_box = nullptr; | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 		LineEdit *parameter_name = nullptr; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		CodeEdit *expression_edit = nullptr; | 
					
						
							| 
									
										
										
										
											2021-07-04 11:56:21 +03:00
										 |  |  | 		CurveEditor *curve_editors[3] = { nullptr, nullptr, nullptr }; | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<VisualShader> visual_shader; | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	HashMap<int, Link> links; | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	List<VisualShader::Connection> connections; | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	bool dirty = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 19:09:29 +02:00
										 |  |  | 	Color vector_expanded_color[4]; | 
					
						
							| 
									
										
										
										
											2020-12-20 18:45:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | 	void set_editor(VisualShaderEditor *p_editor); | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	void register_shader(VisualShader *p_visual_shader); | 
					
						
							| 
									
										
										
										
											2022-04-07 13:23:40 +03:00
										 |  |  | 	void set_connections(const List<VisualShader::Connection> &p_connections); | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node); | 
					
						
							|  |  |  | 	void register_output_port(int p_id, int p_port, TextureButton *p_button); | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void register_parameter_name(int p_id, LineEdit *p_parameter_name); | 
					
						
							| 
									
										
										
										
											2020-10-01 11:10:51 +03:00
										 |  |  | 	void register_default_input_button(int p_node_id, int p_port_id, Button *p_button); | 
					
						
							| 
									
										
										
										
											2020-10-15 14:47:27 +03:00
										 |  |  | 	void register_expression_edit(int p_node_id, CodeEdit *p_expression_edit); | 
					
						
							| 
									
										
										
										
											2021-07-04 11:56:21 +03:00
										 |  |  | 	void register_curve_editor(int p_node_id, int p_index, CurveEditor *p_curve_editor); | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	void clear_links(); | 
					
						
							|  |  |  | 	void set_shader_type(VisualShader::Type p_type); | 
					
						
							|  |  |  | 	bool is_preview_visible(int p_id) const; | 
					
						
							|  |  |  | 	bool is_dirty() const; | 
					
						
							|  |  |  | 	void make_dirty(bool p_enabled); | 
					
						
							| 
									
										
										
										
											2020-09-21 14:32:59 +03:00
										 |  |  | 	void update_node(VisualShader::Type p_type, int p_id); | 
					
						
							|  |  |  | 	void update_node_deferred(VisualShader::Type p_type, int p_node_id); | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	void add_node(VisualShader::Type p_type, int p_id); | 
					
						
							|  |  |  | 	void remove_node(VisualShader::Type p_type, int p_id); | 
					
						
							|  |  |  | 	void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); | 
					
						
							|  |  |  | 	void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); | 
					
						
							|  |  |  | 	void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id); | 
					
						
							|  |  |  | 	void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position); | 
					
						
							|  |  |  | 	void refresh_node_ports(VisualShader::Type p_type, int p_node); | 
					
						
							|  |  |  | 	void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value); | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void update_parameter_refs(); | 
					
						
							|  |  |  | 	void set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name); | 
					
						
							| 
									
										
										
										
											2020-10-04 12:11:58 +03:00
										 |  |  | 	void update_curve(int p_node_id); | 
					
						
							| 
									
										
										
										
											2021-07-14 00:06:44 +02:00
										 |  |  | 	void update_curve_xyz(int p_node_id); | 
					
						
							| 
									
										
										
										
											2020-10-15 14:47:27 +03:00
										 |  |  | 	void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression); | 
					
						
							| 
									
										
										
										
											2020-10-01 11:10:51 +03:00
										 |  |  | 	int get_constant_index(float p_constant) const; | 
					
						
							| 
									
										
										
										
											2022-12-07 21:50:28 +03:00
										 |  |  | 	Ref<Script> get_node_script(int p_node_id) const; | 
					
						
							| 
									
										
										
										
											2020-10-01 18:19:36 +03:00
										 |  |  | 	void update_node_size(int p_node_id); | 
					
						
							| 
									
										
										
										
											2020-12-20 18:45:53 +03:00
										 |  |  | 	void update_theme(); | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	VisualShader::Type get_shader_type() const; | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	VisualShaderGraphPlugin(); | 
					
						
							|  |  |  | 	~VisualShaderGraphPlugin(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | class VisualShaderEditedProperty : public RefCounted { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderEditedProperty, RefCounted); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	Variant edited_property; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	void set_edited_property(Variant p_variant); | 
					
						
							|  |  |  | 	Variant get_edited_property() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	VisualShaderEditedProperty() {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | class VisualShaderEditor : public VBoxContainer { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderEditor, VBoxContainer); | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	friend class VisualShaderGraphPlugin; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | 	PopupPanel *property_editor_popup = nullptr; | 
					
						
							|  |  |  | 	EditorProperty *property_editor = nullptr; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	int editing_node = -1; | 
					
						
							|  |  |  | 	int editing_port = -1; | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | 	Ref<VisualShaderEditedProperty> edited_property_holder; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Ref<VisualShader> visual_shader; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	GraphEdit *graph = nullptr; | 
					
						
							|  |  |  | 	Button *add_node = nullptr; | 
					
						
							| 
									
										
										
										
											2022-11-16 22:05:09 +03:00
										 |  |  | 	MenuButton *varying_button = nullptr; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	Button *preview_shader = nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-07 10:28:13 +03:00
										 |  |  | 	OptionButton *edit_type = nullptr; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	OptionButton *edit_type_standard = nullptr; | 
					
						
							|  |  |  | 	OptionButton *edit_type_particles = nullptr; | 
					
						
							|  |  |  | 	OptionButton *edit_type_sky = nullptr; | 
					
						
							|  |  |  | 	OptionButton *edit_type_fog = nullptr; | 
					
						
							|  |  |  | 	CheckBox *custom_mode_box = nullptr; | 
					
						
							| 
									
										
										
										
											2020-09-15 10:57:40 +03:00
										 |  |  | 	bool custom_mode_enabled = false; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	bool pending_update_preview = false; | 
					
						
							|  |  |  | 	bool shader_error = false; | 
					
						
							|  |  |  | 	Window *preview_window = nullptr; | 
					
						
							|  |  |  | 	VBoxContainer *preview_vbox = nullptr; | 
					
						
							|  |  |  | 	CodeEdit *preview_text = nullptr; | 
					
						
							|  |  |  | 	Ref<CodeHighlighter> syntax_highlighter = nullptr; | 
					
						
							|  |  |  | 	PanelContainer *error_panel = nullptr; | 
					
						
							|  |  |  | 	Label *error_label = nullptr; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 21:50:28 +03:00
										 |  |  | 	bool _block_update_options_menu = false; | 
					
						
							|  |  |  | 	bool _block_rebuild_shader = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 	Point2 saved_node_pos; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	bool saved_node_pos_dirty = false; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	ConfirmationDialog *members_dialog = nullptr; | 
					
						
							| 
									
										
										
										
											2021-07-13 08:52:52 +03:00
										 |  |  | 	VisualShaderNode::PortType members_input_port_type = VisualShaderNode::PORT_TYPE_MAX; | 
					
						
							|  |  |  | 	VisualShaderNode::PortType members_output_port_type = VisualShaderNode::PORT_TYPE_MAX; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	PopupMenu *popup_menu = nullptr; | 
					
						
							| 
									
										
										
										
											2021-07-03 11:11:10 +03:00
										 |  |  | 	PopupMenu *constants_submenu = nullptr; | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	MenuButton *tools = nullptr; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	ConfirmationDialog *add_varying_dialog = nullptr; | 
					
						
							|  |  |  | 	OptionButton *varying_type = nullptr; | 
					
						
							|  |  |  | 	LineEdit *varying_name = nullptr; | 
					
						
							|  |  |  | 	OptionButton *varying_mode = nullptr; | 
					
						
							|  |  |  | 	Label *varying_error_label = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ConfirmationDialog *remove_varying_dialog = nullptr; | 
					
						
							|  |  |  | 	Tree *varyings = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-21 11:33:55 +03:00
										 |  |  | 	PopupPanel *comment_title_change_popup = nullptr; | 
					
						
							|  |  |  | 	LineEdit *comment_title_change_edit = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	PopupPanel *comment_desc_change_popup = nullptr; | 
					
						
							|  |  |  | 	TextEdit *comment_desc_change_edit = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-10 13:33:14 +03:00
										 |  |  | 	bool preview_first = true; | 
					
						
							|  |  |  | 	bool preview_showed = false; | 
					
						
							| 
									
										
										
										
											2021-04-17 20:16:03 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enum ShaderModeFlags { | 
					
						
							|  |  |  | 		MODE_FLAGS_SPATIAL_CANVASITEM = 1, | 
					
						
							|  |  |  | 		MODE_FLAGS_SKY = 2, | 
					
						
							| 
									
										
										
										
											2021-10-29 16:42:33 +03:00
										 |  |  | 		MODE_FLAGS_PARTICLES = 4, | 
					
						
							|  |  |  | 		MODE_FLAGS_FOG = 8, | 
					
						
							| 
									
										
										
										
											2021-04-17 20:16:03 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int mode = MODE_FLAGS_SPATIAL_CANVASITEM; | 
					
						
							| 
									
										
										
										
											2020-09-06 10:43:14 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enum TypeFlags { | 
					
						
							|  |  |  | 		TYPE_FLAGS_VERTEX = 1, | 
					
						
							|  |  |  | 		TYPE_FLAGS_FRAGMENT = 2, | 
					
						
							|  |  |  | 		TYPE_FLAGS_LIGHT = 4, | 
					
						
							| 
									
										
										
										
											2020-09-07 10:28:13 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum ParticlesTypeFlags { | 
					
						
							|  |  |  | 		TYPE_FLAGS_EMIT = 1, | 
					
						
							|  |  |  | 		TYPE_FLAGS_PROCESS = 2, | 
					
						
							| 
									
										
										
										
											2020-09-15 10:57:40 +03:00
										 |  |  | 		TYPE_FLAGS_COLLIDE = 4, | 
					
						
							|  |  |  | 		TYPE_FLAGS_EMIT_CUSTOM = 8, | 
					
						
							|  |  |  | 		TYPE_FLAGS_PROCESS_CUSTOM = 16, | 
					
						
							| 
									
										
										
										
											2020-09-06 10:43:14 +03:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2019-08-18 12:29:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-17 20:16:03 +03:00
										 |  |  | 	enum SkyTypeFlags { | 
					
						
							|  |  |  | 		TYPE_FLAGS_SKY = 1, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-29 16:42:33 +03:00
										 |  |  | 	enum FogTypeFlags { | 
					
						
							|  |  |  | 		TYPE_FLAGS_FOG = 1, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											2021-10-30 16:12:14 +03:00
										 |  |  | 		CUT, | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 		COPY, | 
					
						
							| 
									
										
										
										
											2020-02-27 13:55:41 +03:00
										 |  |  | 		PASTE, | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 		DELETE, | 
					
						
							|  |  |  | 		DUPLICATE, | 
					
						
							| 
									
										
										
										
											2021-10-30 16:12:14 +03:00
										 |  |  | 		CLEAR_COPY_BUFFER, | 
					
						
							| 
									
										
										
										
											2020-12-30 11:45:31 +03:00
										 |  |  | 		SEPARATOR2, // ignore
 | 
					
						
							| 
									
										
										
										
											2021-07-03 11:11:10 +03:00
										 |  |  | 		FLOAT_CONSTANTS, | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 		CONVERT_CONSTANTS_TO_PARAMETERS, | 
					
						
							|  |  |  | 		CONVERT_PARAMETERS_TO_CONSTANTS, | 
					
						
							| 
									
										
										
										
											2021-04-04 17:50:19 +03:00
										 |  |  | 		SEPARATOR3, // ignore
 | 
					
						
							| 
									
										
										
										
											2021-02-21 11:33:55 +03:00
										 |  |  | 		SET_COMMENT_TITLE, | 
					
						
							|  |  |  | 		SET_COMMENT_DESCRIPTION, | 
					
						
							| 
									
										
										
										
											2020-02-27 12:10:09 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	enum class VaryingMenuOptions { | 
					
						
							|  |  |  | 		ADD, | 
					
						
							|  |  |  | 		REMOVE, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	Tree *members = nullptr; | 
					
						
							|  |  |  | 	AcceptDialog *alert = nullptr; | 
					
						
							|  |  |  | 	LineEdit *node_filter = nullptr; | 
					
						
							|  |  |  | 	RichTextLabel *node_desc = nullptr; | 
					
						
							|  |  |  | 	Label *highend_label = nullptr; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _tools_menu_option(int p_idx); | 
					
						
							| 
									
										
										
										
											2021-07-13 08:52:52 +03:00
										 |  |  | 	void _show_members_dialog(bool at_mouse_pos, VisualShaderNode::PortType p_input_port_type = VisualShaderNode::PORT_TYPE_MAX, VisualShaderNode::PortType p_output_port_type = VisualShaderNode::PORT_TYPE_MAX); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	void _varying_menu_id_pressed(int p_idx); | 
					
						
							|  |  |  | 	void _show_add_varying_dialog(); | 
					
						
							|  |  |  | 	void _show_remove_varying_dialog(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 22:58:37 +03:00
										 |  |  | 	void _update_nodes(); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2022-01-28 14:36:35 +03:00
										 |  |  | 		Vector<Variant> ops; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 		Ref<Script> script; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		int mode = 0; | 
					
						
							|  |  |  | 		int return_type = 0; | 
					
						
							|  |  |  | 		int func = 0; | 
					
						
							|  |  |  | 		bool highend = false; | 
					
						
							|  |  |  | 		bool is_custom = false; | 
					
						
							|  |  |  | 		int temp_idx = 0; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-07 15:00:49 +03:00
										 |  |  | 		AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_type = String(), const String &p_description = String(), const Vector<Variant> &p_ops = Vector<Variant>(), int p_return_type = -1, int p_mode = -1, int p_func = -1, bool p_highend = false) { | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			name = p_name; | 
					
						
							|  |  |  | 			type = p_type; | 
					
						
							| 
									
										
										
										
											2022-09-07 15:00:49 +03:00
										 |  |  | 			category = p_category; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			description = p_description; | 
					
						
							| 
									
										
										
										
											2022-01-28 14:36:35 +03:00
										 |  |  | 			ops = p_ops; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 			return_type = p_return_type; | 
					
						
							|  |  |  | 			mode = p_mode; | 
					
						
							| 
									
										
										
										
											2019-05-01 17:04:39 +03:00
										 |  |  | 			func = p_func; | 
					
						
							| 
									
										
										
										
											2019-07-12 17:36:23 +03:00
										 |  |  | 			highend = p_highend; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2020-09-29 15:27:36 +03:00
										 |  |  | 	int cubemap_node_option_idx; | 
					
						
							|  |  |  | 	int texture2d_node_option_idx; | 
					
						
							|  |  |  | 	int texture2d_array_node_option_idx; | 
					
						
							|  |  |  | 	int texture3d_node_option_idx; | 
					
						
							| 
									
										
										
										
											2019-10-02 23:26:56 +03:00
										 |  |  | 	int custom_node_option_idx; | 
					
						
							| 
									
										
										
										
											2020-10-04 12:11:58 +03:00
										 |  |  | 	int curve_node_option_idx; | 
					
						
							| 
									
										
										
										
											2021-07-14 00:06:44 +02:00
										 |  |  | 	int curve_xyz_node_option_idx; | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 	List<String> keyword_list; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	List<VisualShaderNodeParameterRef> uniform_refs; | 
					
						
							| 
									
										
										
										
											2020-09-21 14:32:59 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _draw_color_over_button(Object *obj, Color p_color); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-28 14:36:35 +03:00
										 |  |  | 	void _setup_node(VisualShaderNode *p_node, const Vector<Variant> &p_ops); | 
					
						
							|  |  |  | 	void _add_node(int p_idx, const Vector<Variant> &p_ops, String p_resource_path = "", int p_node_idx = -1); | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	void _add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type); | 
					
						
							|  |  |  | 	void _remove_varying(const String &p_name); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _update_options_menu(); | 
					
						
							| 
									
										
										
										
											2020-09-12 11:01:48 +03:00
										 |  |  | 	void _set_mode(int p_which); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-18 13:27:08 -03:00
										 |  |  | 	void _show_preview_text(); | 
					
						
							| 
									
										
										
										
											2021-01-10 13:33:14 +03:00
										 |  |  | 	void _preview_close_requested(); | 
					
						
							|  |  |  | 	void _preview_size_changed(); | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-27 14:05:19 +03:00
										 |  |  | 	struct DragOp { | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 		VisualShader::Type type = VisualShader::Type::TYPE_MAX; | 
					
						
							|  |  |  | 		int node = 0; | 
					
						
							| 
									
										
										
										
											2020-09-27 14:05:19 +03:00
										 |  |  | 		Vector2 from; | 
					
						
							|  |  |  | 		Vector2 to; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	List<DragOp> drag_buffer; | 
					
						
							|  |  |  | 	bool drag_dirty = false; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node); | 
					
						
							| 
									
										
										
										
											2020-09-27 14:05:19 +03:00
										 |  |  | 	void _nodes_dragged(); | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	bool updating = false; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 10:18:37 +03:00
										 |  |  | 	void _delete_nodes(int p_type, const List<int> &p_nodes); | 
					
						
							|  |  |  | 	void _delete_node_request(int p_type, int p_node); | 
					
						
							| 
									
										
										
										
											2022-05-17 13:13:35 +03:00
										 |  |  | 	void _delete_nodes_request(const TypedArray<StringName> &p_nodes); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _node_changed(int p_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _edit_port_default_input(Object *p_button, int p_node, int p_port); | 
					
						
							| 
									
										
										
										
											2022-08-01 21:01:48 +03:00
										 |  |  | 	void _port_edited(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	int to_node = -1; | 
					
						
							|  |  |  | 	int to_slot = -1; | 
					
						
							|  |  |  | 	int from_node = -1; | 
					
						
							|  |  |  | 	int from_slot = -1; | 
					
						
							| 
									
										
										
										
											2019-06-26 21:50:38 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 	HashSet<int> selected_constants; | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	HashSet<int> selected_parameters; | 
					
						
							| 
									
										
										
										
											2021-02-21 11:33:55 +03:00
										 |  |  | 	int selected_comment = -1; | 
					
						
							| 
									
										
										
										
											2021-07-03 11:11:10 +03:00
										 |  |  | 	int selected_float_constant = -1; | 
					
						
							| 
									
										
										
										
											2020-12-30 11:45:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void _convert_constants_to_parameters(bool p_vice_versa); | 
					
						
							| 
									
										
										
										
											2020-12-30 11:45:31 +03:00
										 |  |  | 	void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to); | 
					
						
							|  |  |  | 	void _update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void _update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); | 
					
						
							| 
									
										
										
										
											2020-12-30 11:45:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-21 11:33:55 +03:00
										 |  |  | 	void _comment_title_popup_show(const Point2 &p_position, int p_node_id); | 
					
						
							|  |  |  | 	void _comment_title_popup_hide(); | 
					
						
							|  |  |  | 	void _comment_title_popup_focus_out(); | 
					
						
							|  |  |  | 	void _comment_title_text_changed(const String &p_new_text); | 
					
						
							| 
									
										
										
										
											2021-06-16 09:43:34 -07:00
										 |  |  | 	void _comment_title_text_submitted(const String &p_new_text); | 
					
						
							| 
									
										
										
										
											2021-02-21 11:33:55 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _comment_desc_popup_show(const Point2 &p_position, int p_node_id); | 
					
						
							|  |  |  | 	void _comment_desc_popup_hide(); | 
					
						
							|  |  |  | 	void _comment_desc_confirm(); | 
					
						
							|  |  |  | 	void _comment_desc_text_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void _parameter_line_edit_changed(const String &p_text, int p_node_id); | 
					
						
							|  |  |  | 	void _parameter_line_edit_focus_out(Object *line_edit, int p_node_id); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 16:12:14 +03:00
										 |  |  | 	struct CopyItem { | 
					
						
							|  |  |  | 		int id; | 
					
						
							|  |  |  | 		Ref<VisualShaderNode> node; | 
					
						
							|  |  |  | 		Vector2 position; | 
					
						
							|  |  |  | 		Vector2 size; | 
					
						
							|  |  |  | 		String group_inputs; | 
					
						
							|  |  |  | 		String group_outputs; | 
					
						
							|  |  |  | 		String expression; | 
					
						
							| 
									
										
										
										
											2022-02-07 22:58:37 +03:00
										 |  |  | 		bool disabled = false; | 
					
						
							| 
									
										
										
										
											2021-10-30 16:12:14 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _dup_copy_nodes(int p_type, List<CopyItem> &r_nodes, List<VisualShader::Connection> &r_connections); | 
					
						
							|  |  |  | 	void _dup_paste_nodes(int p_type, List<CopyItem> &r_items, const List<VisualShader::Connection> &p_connections, const Vector2 &p_offset, bool p_duplicate); | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _duplicate_nodes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 09:59:20 +03:00
										 |  |  | 	static Vector2 selection_center; | 
					
						
							|  |  |  | 	static List<CopyItem> copy_items_buffer; | 
					
						
							|  |  |  | 	static List<VisualShader::Connection> copy_connections_buffer; | 
					
						
							| 
									
										
										
										
											2019-07-12 20:36:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 16:12:14 +03:00
										 |  |  | 	void _clear_copy_buffer(); | 
					
						
							|  |  |  | 	void _copy_nodes(bool p_cut); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2020-09-09 17:40:27 +03:00
										 |  |  | 	Ref<VisualShaderGraphPlugin> graph_plugin; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _mode_selected(int p_id); | 
					
						
							| 
									
										
										
										
											2020-09-15 10:57:40 +03:00
										 |  |  | 	void _custom_mode_toggled(bool p_enabled); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _input_select_item(Ref<VisualShaderNodeInput> input, String name); | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void _parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name); | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-03 11:11:10 +03:00
										 |  |  | 	void _float_constant_selected(int p_which); | 
					
						
							| 
									
										
										
										
											2020-10-01 11:10:51 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-07 10:28:13 +03:00
										 |  |  | 	VisualShader::Type get_current_shader_type() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2020-12-02 12:49:46 +03:00
										 |  |  | 	void _change_input_port_name(const String &p_text, Object *p_line_edit, int p_node, int p_port); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2020-12-02 12:49:46 +03:00
										 |  |  | 	void _change_output_port_name(const String &p_text, Object *p_line_edit, int p_node, int p_port); | 
					
						
							| 
									
										
										
										
											2020-12-20 18:45:53 +03:00
										 |  |  | 	void _expand_output_port(int p_node, int p_port, bool p_expand); | 
					
						
							| 
									
										
										
										
											2019-05-12 15:09:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-24 15:50:35 +01:00
										 |  |  | 	void _expression_focus_out(Object *code_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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	void _varying_create(); | 
					
						
							|  |  |  | 	void _varying_name_changed(const String &p_text); | 
					
						
							|  |  |  | 	void _varying_deleted(); | 
					
						
							|  |  |  | 	void _varying_selected(); | 
					
						
							|  |  |  | 	void _varying_unselected(); | 
					
						
							|  |  |  | 	void _update_varying_tree(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2022-08-27 12:22:43 +03:00
										 |  |  | 	void _update_parameters(bool p_update_refs); | 
					
						
							|  |  |  | 	void _update_parameter_refs(HashSet<String> &p_names); | 
					
						
							| 
									
										
										
										
											2022-01-09 17:02:13 +03:00
										 |  |  | 	void _update_varyings(); | 
					
						
							| 
									
										
										
										
											2019-02-22 20:38:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 21:50:28 +03:00
										 |  |  | 	void _update_options_menu_deferred(); | 
					
						
							|  |  |  | 	void _rebuild_shader_deferred(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-10 13:33:14 +03:00
										 |  |  | 	void _visibility_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); | 
					
						
							|  |  |  | 	void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-10 08:31:07 +03:00
										 |  |  | 	VisualShaderGraphPlugin *get_graph_plugin() { return graph_plugin.ptr(); } | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 21:50:28 +03:00
										 |  |  | 	Dictionary get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node); | 
					
						
							|  |  |  | 	void update_custom_type(const Ref<Resource> &p_resource); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Size2 get_minimum_size() const override; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void edit(VisualShader *p_visual_shader); | 
					
						
							|  |  |  | 	VisualShaderEditor(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VisualShaderNodePluginDefault : public VisualShaderNodePlugin { | 
					
						
							| 
									
										
										
										
											2019-03-19 14:35:57 -04:00
										 |  |  | 	GDCLASS(VisualShaderNodePluginDefault, VisualShaderNodePlugin); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) override; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 14:39:53 -05:00
										 |  |  | class EditorPropertyVisualShaderMode : public EditorProperty { | 
					
						
							|  |  |  | 	GDCLASS(EditorPropertyVisualShaderMode, EditorProperty); | 
					
						
							| 
									
										
										
										
											2022-01-07 10:59:15 +03:00
										 |  |  | 	OptionButton *options = nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _option_selected(int p_which); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	void setup(const Vector<String> &p_options); | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual void update_property() override; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void set_option_button_clip(bool p_enable); | 
					
						
							| 
									
										
										
										
											2022-08-15 14:39:53 -05:00
										 |  |  | 	EditorPropertyVisualShaderMode(); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 14:39:53 -05:00
										 |  |  | class EditorInspectorVisualShaderModePlugin : public EditorInspectorPlugin { | 
					
						
							|  |  |  | 	GDCLASS(EditorInspectorVisualShaderModePlugin, EditorInspectorPlugin); | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual bool can_handle(Object *p_object) override; | 
					
						
							| 
									
										
										
										
											2021-06-30 21:24:34 -04:00
										 |  |  | 	virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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; | 
					
						
							| 
									
										
										
										
											2020-11-24 10:12:55 +01:00
										 |  |  | 	VisualShader::Type type = VisualShader::Type::TYPE_MAX; | 
					
						
							|  |  |  | 	int node = 0; | 
					
						
							|  |  |  | 	int port = 0; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void _shader_changed(); //must regen
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 	static void _bind_methods(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual Size2 get_minimum_size() const override; | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | 	void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-28 14:51:51 +03:00
										 |  |  | class VisualShaderConversionPlugin : public EditorResourceConversionPlugin { | 
					
						
							|  |  |  | 	GDCLASS(VisualShaderConversionPlugin, EditorResourceConversionPlugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual String converts_to() const override; | 
					
						
							|  |  |  | 	virtual bool handles(const Ref<Resource> &p_resource) const override; | 
					
						
							|  |  |  | 	virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override; | 
					
						
							| 
									
										
										
										
											2019-06-28 14:51:51 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-14 18:15:42 -03:00
										 |  |  | #endif // VISUAL_SHADER_EDITOR_PLUGIN_H
 |