| 
									
										
										
										
											2023-01-05 13:25:55 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  shader_editor_plugin.h                                                */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* 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-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #ifndef SHADER_EDITOR_PLUGIN_H
 | 
					
						
							|  |  |  | #define SHADER_EDITOR_PLUGIN_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-21 01:11:35 -07:00
										 |  |  | #include "editor/plugins/editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | class HSplitContainer; | 
					
						
							| 
									
										
										
										
											2022-09-02 23:15:21 -05:00
										 |  |  | class ItemList; | 
					
						
							| 
									
										
										
										
											2022-11-11 20:12:48 +01:00
										 |  |  | class MenuButton; | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | class ShaderCreateDialog; | 
					
						
							| 
									
										
										
										
											2024-07-12 11:56:49 -07:00
										 |  |  | class ShaderEditor; | 
					
						
							| 
									
										
										
										
											2022-09-02 23:15:21 -05:00
										 |  |  | class TabContainer; | 
					
						
							|  |  |  | class TextShaderEditor; | 
					
						
							| 
									
										
										
										
											2022-07-31 23:07:10 +02:00
										 |  |  | class VBoxContainer; | 
					
						
							| 
									
										
										
										
											2022-09-02 23:15:21 -05:00
										 |  |  | class VisualShaderEditor; | 
					
						
							| 
									
										
										
										
											2022-11-02 15:23:25 +01:00
										 |  |  | class WindowWrapper; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-17 20:44:38 +01:00
										 |  |  | #ifdef MINGW_ENABLED
 | 
					
						
							|  |  |  | #undef FILE_OPEN
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | class ShaderEditorPlugin : public EditorPlugin { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	GDCLASS(ShaderEditorPlugin, EditorPlugin); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	struct EditedShader { | 
					
						
							|  |  |  | 		Ref<Shader> shader; | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | 		Ref<ShaderInclude> shader_inc; | 
					
						
							| 
									
										
										
										
											2024-07-12 11:56:49 -07:00
										 |  |  | 		ShaderEditor *shader_editor = nullptr; | 
					
						
							| 
									
										
										
										
											2023-11-08 19:14:01 +01:00
										 |  |  | 		String path; | 
					
						
							| 
									
										
										
										
											2024-01-02 16:00:11 +01:00
										 |  |  | 		String name; | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	LocalVector<EditedShader> edited_shaders; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum { | 
					
						
							|  |  |  | 		FILE_NEW, | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | 		FILE_NEW_INCLUDE, | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 		FILE_OPEN, | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | 		FILE_OPEN_INCLUDE, | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 		FILE_SAVE, | 
					
						
							|  |  |  | 		FILE_SAVE_AS, | 
					
						
							|  |  |  | 		FILE_INSPECT, | 
					
						
							|  |  |  | 		FILE_CLOSE, | 
					
						
							| 
									
										
										
										
											2024-08-18 00:54:58 -04:00
										 |  |  | 		CLOSE_ALL, | 
					
						
							|  |  |  | 		CLOSE_OTHER_TABS, | 
					
						
							|  |  |  | 		SHOW_IN_FILE_SYSTEM, | 
					
						
							|  |  |  | 		COPY_PATH, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum PopupMenuType { | 
					
						
							|  |  |  | 		FILE, | 
					
						
							|  |  |  | 		CONTEXT, | 
					
						
							|  |  |  | 		CONTEXT_VALID_ITEM, | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	HSplitContainer *main_split = nullptr; | 
					
						
							| 
									
										
										
										
											2022-07-31 23:07:10 +02:00
										 |  |  | 	VBoxContainer *left_panel = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	ItemList *shader_list = nullptr; | 
					
						
							|  |  |  | 	TabContainer *shader_tabs = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Button *button = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	MenuButton *file_menu = nullptr; | 
					
						
							| 
									
										
										
										
											2024-08-18 00:54:58 -04:00
										 |  |  | 	PopupMenu *context_menu = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-02 15:23:25 +01:00
										 |  |  | 	WindowWrapper *window_wrapper = nullptr; | 
					
						
							|  |  |  | 	Button *make_floating = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	ShaderCreateDialog *shader_create_dialog = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-17 20:16:58 -06:00
										 |  |  | 	float text_shader_zoom_factor = 1.0f; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-18 00:54:58 -04:00
										 |  |  | 	Ref<Resource> _get_current_shader(); | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	void _update_shader_list(); | 
					
						
							|  |  |  | 	void _shader_selected(int p_index); | 
					
						
							| 
									
										
										
										
											2022-07-28 18:28:38 +02:00
										 |  |  | 	void _shader_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index); | 
					
						
							| 
									
										
										
										
											2024-08-18 00:54:58 -04:00
										 |  |  | 	void _setup_popup_menu(PopupMenuType p_type, PopupMenu *p_menu); | 
					
						
							|  |  |  | 	void _make_script_list_context_menu(); | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 	void _menu_item_pressed(int p_index); | 
					
						
							|  |  |  | 	void _resource_saved(Object *obj); | 
					
						
							|  |  |  | 	void _close_shader(int p_index); | 
					
						
							| 
									
										
										
										
											2023-04-09 20:43:55 +02:00
										 |  |  | 	void _close_builtin_shaders_from_scene(const String &p_scene); | 
					
						
							| 
									
										
										
										
											2023-10-11 17:49:29 +08:00
										 |  |  | 	void _file_removed(const String &p_removed_file); | 
					
						
							| 
									
										
										
										
											2024-01-02 12:53:18 +01:00
										 |  |  | 	void _res_saved_callback(const Ref<Resource> &p_res); | 
					
						
							| 
									
										
										
										
											2024-08-18 00:54:58 -04:00
										 |  |  | 	void _set_file_specific_items_disabled(bool p_disabled); | 
					
						
							| 
									
										
										
										
											2022-05-27 11:02:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _shader_created(Ref<Shader> p_shader); | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | 	void _shader_include_created(Ref<ShaderInclude> p_shader_inc); | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 	void _update_shader_list_status(); | 
					
						
							| 
									
										
										
										
											2022-08-10 04:12:31 +02:00
										 |  |  | 	void _move_shader_tab(int p_from, int p_to); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-02 15:23:25 +01:00
										 |  |  | 	void _window_changed(bool p_visible); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-17 20:16:58 -06:00
										 |  |  | 	void _set_text_shader_zoom_factor(float p_zoom_factor); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-09 20:43:55 +02:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-12-09 11:02:07 +03:00
										 |  |  | 	virtual String get_name() const override { return "Shader"; } | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual void edit(Object *p_object) override; | 
					
						
							|  |  |  | 	virtual bool handles(Object *p_object) const override; | 
					
						
							|  |  |  | 	virtual void make_visible(bool p_visible) override; | 
					
						
							|  |  |  | 	virtual void selected_notify() override; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-12 11:56:49 -07:00
										 |  |  | 	ShaderEditor *get_shader_editor(const Ref<Shader> &p_for_shader); | 
					
						
							| 
									
										
										
										
											2018-10-27 12:24:41 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-11 04:17:03 +02:00
										 |  |  | 	virtual void set_window_layout(Ref<ConfigFile> p_layout) override; | 
					
						
							|  |  |  | 	virtual void get_window_layout(Ref<ConfigFile> p_layout) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-05 15:45:41 +02:00
										 |  |  | 	virtual String get_unsaved_status(const String &p_for_scene) const override; | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual void save_external_data() override; | 
					
						
							|  |  |  | 	virtual void apply_changes() override; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 10:36:51 +01:00
										 |  |  | 	ShaderEditorPlugin(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	~ShaderEditorPlugin(); | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-23 23:41:51 +02:00
										 |  |  | #endif // SHADER_EDITOR_PLUGIN_H
 |