1 | /**************************************************************************/ |
2 | /* shader_file_editor_plugin.h */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
10 | /* */ |
11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
12 | /* a copy of this software and associated documentation files (the */ |
13 | /* "Software"), to deal in the Software without restriction, including */ |
14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
17 | /* the following conditions: */ |
18 | /* */ |
19 | /* The above copyright notice and this permission notice shall be */ |
20 | /* included in all copies or substantial portions of the Software. */ |
21 | /* */ |
22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
29 | /**************************************************************************/ |
30 | |
31 | #ifndef SHADER_FILE_EDITOR_PLUGIN_H |
32 | #define SHADER_FILE_EDITOR_PLUGIN_H |
33 | |
34 | #include "editor/code_editor.h" |
35 | #include "editor/editor_plugin.h" |
36 | #include "scene/gui/menu_button.h" |
37 | #include "scene/gui/panel_container.h" |
38 | #include "scene/gui/rich_text_label.h" |
39 | #include "scene/gui/tab_container.h" |
40 | #include "scene/gui/text_edit.h" |
41 | #include "scene/main/timer.h" |
42 | #include "servers/rendering/rendering_device_binds.h" |
43 | |
44 | class ItemList; |
45 | |
46 | class ShaderFileEditor : public PanelContainer { |
47 | GDCLASS(ShaderFileEditor, PanelContainer); |
48 | |
49 | Ref<RDShaderFile> shader_file; |
50 | |
51 | HBoxContainer *stage_hb = nullptr; |
52 | ItemList *versions = nullptr; |
53 | Button *stages[RD::SHADER_STAGE_MAX]; |
54 | RichTextLabel *error_text = nullptr; |
55 | |
56 | void _update_version(const StringName &p_version_txt, const RenderingDevice::ShaderStage p_stage); |
57 | void _version_selected(int p_stage); |
58 | void _editor_settings_changed(); |
59 | |
60 | void _update_options(); |
61 | void _shader_changed(); |
62 | |
63 | protected: |
64 | void _notification(int p_what); |
65 | static void _bind_methods(); |
66 | |
67 | public: |
68 | static ShaderFileEditor *singleton; |
69 | void edit(const Ref<RDShaderFile> &p_shader); |
70 | |
71 | ShaderFileEditor(); |
72 | }; |
73 | |
74 | class ShaderFileEditorPlugin : public EditorPlugin { |
75 | GDCLASS(ShaderFileEditorPlugin, EditorPlugin); |
76 | |
77 | ShaderFileEditor *shader_editor = nullptr; |
78 | Button *button = nullptr; |
79 | |
80 | public: |
81 | virtual String get_name() const override { return "ShaderFile" ; } |
82 | bool has_main_screen() const override { return false; } |
83 | virtual void edit(Object *p_object) override; |
84 | virtual bool handles(Object *p_object) const override; |
85 | virtual void make_visible(bool p_visible) override; |
86 | |
87 | ShaderFileEditor *get_shader_editor() const { return shader_editor; } |
88 | |
89 | ShaderFileEditorPlugin(); |
90 | ~ShaderFileEditorPlugin(); |
91 | }; |
92 | |
93 | #endif // SHADER_FILE_EDITOR_PLUGIN_H |
94 | |