Debian Codegraph @

editor/shader/shader_create_dialog.h

raw symbols SCIP
1 /**************************************************************************/
2 /* shader_create_dialog.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 #pragma once
32
33 #include "editor/settings/editor_settings.h"
34 #include "scene/gui/check_box.h"
35 #include "scene/gui/dialogs.h"
36 #include "scene/gui/grid_container.h"
37 #include "scene/gui/line_edit.h"
38 #include "scene/gui/option_button.h"
39 #include "scene/gui/panel_container.h"
40
41 class EditorFileDialog;
42 class EditorValidationPanel;
43
44 class ShaderCreateDialog : public ConfirmationDialog {
45 GDCLASS(ShaderCreateDialog, ConfirmationDialog);
46
47 enum {
48 MSG_ID_SHADER,
49 MSG_ID_PATH,
50 MSG_ID_BUILT_IN,
51 };
52
53 struct ShaderTypeData {
54 List<String> extensions;
55 String default_extension;
56 bool use_templates = false;
57 };
58
59 List<ShaderTypeData> type_data;
60
61 GridContainer *gc = nullptr;
62 EditorValidationPanel *validation_panel = nullptr;
63 OptionButton *type_menu = nullptr;
64 OptionButton *mode_menu = nullptr;
65 OptionButton *template_menu = nullptr;
66 CheckBox *internal = nullptr;
67 LineEdit *file_path = nullptr;
68 Button *path_button = nullptr;
69 EditorFileDialog *file_browse = nullptr;
70 AcceptDialog *alert = nullptr;
71
72 String initial_base_path;
73 String path_error;
74 bool is_new_shader_created = true;
75 bool is_path_valid = false;
76 bool is_built_in = false;
77 bool built_in_enabled = true;
78 bool load_enabled = false;
79 bool re_check_path = false;
80 int current_type = -1;
81 int current_mode = 0;
82 int current_template = 0;
83
84 virtual void _update_language_info();
85
86 void _path_hbox_sorted();
87 void _path_changed(const String &p_path = String());
88 void _path_submitted(const String &p_path = String());
89 void _type_changed(int p_type = 0);
90 void _built_in_toggled(bool p_enabled);
91 void _template_changed(int p_template = 0);
92 void _mode_changed(int p_mode = 0);
93 void _browse_path();
94 void _file_selected(const String &p_file);
95 void _refresh_type_icons();
96 String _validate_path(const String &p_path);
97 virtual void ok_pressed() override;
98 void _create_new();
99 void _load_exist();
100 void _update_dialog();
101
102 protected:
103 void _notification(int p_what);
104 static void _bind_methods();
105
106 public:
107 void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, const String &p_preferred_type = "", int p_preferred_mode = -1);
108 ShaderCreateDialog();
109 };