Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/groups_editor.h
21002 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
LocalVector<Node *> selection;
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
VBoxContainer *holder = nullptr;
77
LineEdit *filter = nullptr;
78
Button *add = nullptr;
79
Tree *tree = nullptr;
80
Label *select_a_node = nullptr;
81
82
HashMap<ObjectID, HashMap<StringName, bool>> scene_groups_cache;
83
HashMap<StringName, bool> scene_groups_for_caching;
84
85
HashMap<StringName, bool> scene_groups;
86
HashMap<StringName, String> global_groups;
87
88
void _update_scene_groups(const ObjectID &p_id);
89
void _cache_scene_groups(const ObjectID &p_id);
90
91
void _show_add_group_dialog();
92
void _show_rename_group_dialog();
93
void _show_remove_group_dialog();
94
95
void _check_add();
96
void _check_rename();
97
void _validate_name(const String &p_name, EditorValidationPanel *p_validation_panel);
98
99
void _update_tree();
100
101
void _update_groups();
102
void _load_scene_groups(Node *p_node);
103
104
void _add_scene_group(const String &p_name);
105
void _rename_scene_group(const String &p_old_name, const String &p_new_name);
106
void _remove_scene_group(const String &p_name);
107
108
bool _has_group(const String &p_name);
109
void _set_group_checked(const String &p_name, bool p_checked);
110
111
void _confirm_add();
112
void _confirm_rename();
113
void _confirm_delete();
114
115
void _item_edited();
116
void _item_mouse_selected(const Vector2 &p_pos, MouseButton p_mouse_button);
117
void _modify_group(Object *p_item, int p_column, int p_id, MouseButton p_mouse_button);
118
void _menu_id_pressed(int p_id);
119
120
void _update_groups_and_tree();
121
void _queue_update_groups_and_tree();
122
123
void _groups_gui_input(Ref<InputEvent> p_event);
124
125
void _node_removed(Node *p_node);
126
127
void _add_to_group(const StringName &p_name, bool p_persist, const Array &p_nodes);
128
void _remove_from_group(const StringName &p_name, const Array &p_nodes);
129
void _get_group_mask(const StringName &p_name, Array &r_nodes, bool p_invert);
130
bool _can_edit(const StringName &p_group);
131
132
protected:
133
void _notification(int p_what);
134
static void _bind_methods();
135
136
public:
137
enum ModifyButton {
138
DELETE_GROUP,
139
COPY_GROUP,
140
RENAME_GROUP,
141
CONVERT_GROUP,
142
};
143
144
void set_selection(const Vector<Node *> &p_nodes);
145
146
GroupsEditor();
147
};
148
149