Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/groups_editor.h
9896 views
1
/**************************************************************************/
2
/* groups_editor.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 "scene/gui/dialogs.h"
34
35
class Button;
36
class CheckBox;
37
class CheckButton;
38
class EditorValidationPanel;
39
class Label;
40
class LineEdit;
41
class PopupMenu;
42
class Tree;
43
class TreeItem;
44
45
class GroupsEditor : public VBoxContainer {
46
GDCLASS(GroupsEditor, VBoxContainer);
47
48
const String GLOBAL_GROUP_PREFIX = "global_group/";
49
50
bool updating_tree = false;
51
bool updating_groups = false;
52
bool groups_dirty = false;
53
bool update_groups_and_tree_queued = false;
54
55
Node *node = nullptr;
56
Node *scene_root_node = nullptr;
57
SceneTree *scene_tree = nullptr;
58
59
ConfirmationDialog *add_group_dialog = nullptr;
60
LineEdit *add_group_name = nullptr;
61
LineEdit *add_group_description = nullptr;
62
CheckButton *global_group_button = nullptr;
63
EditorValidationPanel *add_validation_panel = nullptr;
64
65
ConfirmationDialog *rename_group_dialog = nullptr;
66
LineEdit *rename_group = nullptr;
67
CheckBox *rename_check_box = nullptr;
68
EditorValidationPanel *rename_validation_panel = nullptr;
69
70
ConfirmationDialog *remove_group_dialog = nullptr;
71
CheckBox *remove_check_box = nullptr;
72
Label *remove_label = nullptr;
73
74
PopupMenu *menu = nullptr;
75
76
LineEdit *filter = nullptr;
77
Button *add = nullptr;
78
Tree *tree = nullptr;
79
80
HashMap<ObjectID, HashMap<StringName, bool>> scene_groups_cache;
81
HashMap<StringName, bool> scene_groups_for_caching;
82
83
HashMap<StringName, bool> scene_groups;
84
HashMap<StringName, String> global_groups;
85
86
void _update_scene_groups(const ObjectID &p_id);
87
void _cache_scene_groups(const ObjectID &p_id);
88
89
void _show_add_group_dialog();
90
void _show_rename_group_dialog();
91
void _show_remove_group_dialog();
92
93
void _check_add();
94
void _check_rename();
95
void _validate_name(const String &p_name, EditorValidationPanel *p_validation_panel);
96
97
void _update_tree();
98
99
void _update_groups();
100
void _load_scene_groups(Node *p_node);
101
102
void _add_scene_group(const String &p_name);
103
void _rename_scene_group(const String &p_old_name, const String &p_new_name);
104
void _remove_scene_group(const String &p_name);
105
106
bool _has_group(const String &p_name);
107
void _set_group_checked(const String &p_name, bool p_checked);
108
109
void _confirm_add();
110
void _confirm_rename();
111
void _confirm_delete();
112
113
void _item_edited();
114
void _item_mouse_selected(const Vector2 &p_pos, MouseButton p_mouse_button);
115
void _modify_group(Object *p_item, int p_column, int p_id, MouseButton p_mouse_button);
116
void _menu_id_pressed(int p_id);
117
118
void _update_groups_and_tree();
119
void _queue_update_groups_and_tree();
120
121
void _groups_gui_input(Ref<InputEvent> p_event);
122
123
void _node_removed(Node *p_node);
124
125
protected:
126
void _notification(int p_what);
127
static void _bind_methods();
128
129
public:
130
enum ModifyButton {
131
DELETE_GROUP,
132
COPY_GROUP,
133
RENAME_GROUP,
134
CONVERT_GROUP,
135
};
136
137
void set_current(Node *p_node);
138
139
GroupsEditor();
140
};
141
142