Debian Codegraph @

editor/settings/editor_feature_profile.h

raw symbols SCIP
1 /**************************************************************************/
2 /* editor_feature_profile.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 "core/object/ref_counted.h"
34 #include "editor/doc/editor_help.h"
35 #include "scene/gui/dialogs.h"
36 #include "scene/gui/option_button.h"
37 #include "scene/gui/split_container.h"
38 #include "scene/gui/tree.h"
39
40 class EditorFileDialog;
41
42 class EditorFeatureProfile : public RefCounted {
43 GDCLASS(EditorFeatureProfile, RefCounted);
44
45 public:
46 enum Feature {
47 FEATURE_3D,
48 FEATURE_SCRIPT,
49 FEATURE_ASSET_LIB,
50 FEATURE_SCENE_TREE,
51 #ifndef DISABLE_DEPRECATED
52 FEATURE_NODE_DOCK,
53 #endif
54 FEATURE_FILESYSTEM_DOCK,
55 FEATURE_IMPORT_DOCK,
56 FEATURE_HISTORY_DOCK,
57 FEATURE_GAME,
58 FEATURE_SIGNALS_DOCK,
59 FEATURE_GROUPS_DOCK,
60 FEATURE_MAX
61 };
62
63 private:
64 HashSet<StringName> disabled_classes;
65 HashSet<StringName> disabled_editors;
66 HashMap<StringName, HashSet<StringName>> disabled_properties;
67
68 HashSet<StringName> collapsed_classes;
69
70 bool features_disabled[FEATURE_MAX];
71 static const char *feature_names[FEATURE_MAX];
72 static const char *feature_descriptions[FEATURE_MAX];
73 static const char *feature_identifiers[FEATURE_MAX];
74
75 String _get_feature_name(Feature p_feature) { return get_feature_name(p_feature); }
76
77 protected:
78 static void _bind_methods();
79
80 public:
81 void set_disable_class(const StringName &p_class, bool p_disabled);
82 bool is_class_disabled(const StringName &p_class) const;
83
84 void set_disable_class_editor(const StringName &p_class, bool p_disabled);
85 bool is_class_editor_disabled(const StringName &p_class) const;
86
87 void set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled);
88 bool is_class_property_disabled(const StringName &p_class, const StringName &p_property) const;
89 bool has_class_properties_disabled(const StringName &p_class) const;
90
91 void set_item_collapsed(const StringName &p_class, bool p_collapsed);
92 bool is_item_collapsed(const StringName &p_class) const;
93
94 void set_disable_feature(Feature p_feature, bool p_disable);
95 bool is_feature_disabled(Feature p_feature) const;
96
97 Error save_to_file(const String &p_path);
98 Error load_from_file(const String &p_path);
99
100 static String get_feature_name(Feature p_feature);
101 static String get_feature_description(Feature p_feature);
102
103 EditorFeatureProfile();
104 };
105
106 VARIANT_ENUM_CAST(EditorFeatureProfile::Feature)
107
108 class EditorFeatureProfileManager : public AcceptDialog {
109 GDCLASS(EditorFeatureProfileManager, AcceptDialog);
110
111 enum Action {
112 PROFILE_CLEAR,
113 PROFILE_SET,
114 PROFILE_IMPORT,
115 PROFILE_EXPORT,
116 PROFILE_NEW,
117 PROFILE_ERASE,
118 PROFILE_MAX
119 };
120
121 enum ClassOptions {
122 CLASS_OPTION_DISABLE_EDITOR
123 };
124
125 ConfirmationDialog *erase_profile_dialog = nullptr;
126 ConfirmationDialog *new_profile_dialog = nullptr;
127 LineEdit *new_profile_name = nullptr;
128
129 LineEdit *current_profile_name = nullptr;
130 OptionButton *profile_list = nullptr;
131 Button *profile_actions[PROFILE_MAX];
132
133 HSplitContainer *h_split = nullptr;
134
135 VBoxContainer *class_list_vbc = nullptr;
136 Tree *class_list = nullptr;
137 VBoxContainer *property_list_vbc = nullptr;
138 Tree *property_list = nullptr;
139 EditorHelpBit *description_bit = nullptr;
140 Label *no_profile_selected_help = nullptr;
141
142 EditorFileDialog *import_profiles = nullptr;
143 EditorFileDialog *export_profile = nullptr;
144
145 void _profile_action(int p_action);
146 void _profile_selected(int p_what);
147 void _hide_requested();
148
149 String current_profile;
150 void _update_profile_list(const String &p_select_profile = String());
151 void _update_selected_profile();
152 void _update_profile_tree_from(TreeItem *p_edited);
153 void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index = -1);
154
155 Ref<EditorFeatureProfile> current;
156 Ref<EditorFeatureProfile> edited;
157
158 void _erase_selected_profile();
159 void _create_new_profile();
160 String _get_selected_profile();
161
162 void _import_profiles(const Vector<String> &p_paths);
163 void _export_profile(const String &p_path);
164
165 bool updating_features = false;
166
167 void _class_list_item_selected();
168 void _class_list_item_edited();
169 void _class_list_item_collapsed(Object *p_item);
170 void _property_item_edited();
171 void _save_and_update();
172
173 Timer *update_timer = nullptr;
174 void _emit_current_profile_changed();
175
176 static EditorFeatureProfileManager *singleton;
177
178 protected:
179 static void _bind_methods();
180 void _notification(int p_what);
181
182 public:
183 Ref<EditorFeatureProfile> get_current_profile();
184 String get_current_profile_name() const;
185 void set_current_profile(const String &p_profile_name, bool p_validate_profile);
186 void notify_changed();
187
188 static EditorFeatureProfileManager *get_singleton() { return singleton; }
189 EditorFeatureProfileManager();
190 };