Debian Codegraph @

editor/scene/2d/tiles/tile_set_scenes_collection_source_editor.h

raw symbols SCIP
1 /**************************************************************************/
2 /* tile_set_scenes_collection_source_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 "editor/inspector/editor_inspector.h"
34 #include "scene/gui/box_container.h"
35 #include "scene/resources/2d/tile_set.h"
36
37 class Button;
38 class ItemList;
39 class Label;
40 class EditorFileDialog;
41
42 class TileSetScenesCollectionSourceEditor : public HBoxContainer {
43 GDCLASS(TileSetScenesCollectionSourceEditor, HBoxContainer);
44
45 private:
46 // -- Proxy object for an atlas source, needed by the inspector --
47 class TileSetScenesCollectionProxyObject : public Object {
48 GDCLASS(TileSetScenesCollectionProxyObject, Object);
49
50 private:
51 Ref<TileSet> tile_set;
52 Ref<TileSetScenesCollectionSource> tile_set_scenes_collection_source;
53 int source_id = -1;
54
55 protected:
56 bool _set(const StringName &p_name, const Variant &p_value);
57 bool _get(const StringName &p_name, Variant &r_ret) const;
58 void _get_property_list(List<PropertyInfo> *p_list) const;
59 static void _bind_methods();
60
61 public:
62 void set_id(int p_id);
63 int get_id();
64
65 void edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
66 };
67
68 // -- Proxy object for a tile, needed by the inspector --
69 class SceneTileProxyObject : public Object {
70 GDCLASS(SceneTileProxyObject, Object);
71
72 private:
73 TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
74
75 Ref<TileSetScenesCollectionSource> tile_set_scenes_collection_source;
76 int source_id;
77 int scene_id;
78
79 protected:
80 bool _set(const StringName &p_name, const Variant &p_value);
81 bool _get(const StringName &p_name, Variant &r_ret) const;
82 void _get_property_list(List<PropertyInfo> *p_list) const;
83
84 static void _bind_methods();
85
86 public:
87 // Update the proxied object.
88 void edit(TileSetScenesCollectionSource *p_tile_set_atlas_source, int p_scene_id);
89
90 SceneTileProxyObject(TileSetScenesCollectionSourceEditor *p_tiles_set_scenes_collection_source_editor) {
91 tile_set_scenes_collection_source_editor = p_tiles_set_scenes_collection_source_editor;
92 }
93 };
94
95 private:
96 bool read_only = false;
97
98 Ref<TileSet> tile_set;
99 Ref<TileSetScenesCollectionSource> tile_set_scenes_collection_source;
100 int tile_set_source_id = -1;
101
102 bool tile_set_scenes_collection_source_changed_needs_update = false;
103
104 // Source inspector.
105 TileSetScenesCollectionProxyObject *scenes_collection_source_proxy_object = nullptr;
106 Label *scenes_collection_source_inspector_label = nullptr;
107 EditorInspector *scenes_collection_source_inspector = nullptr;
108
109 // Tile inspector.
110 SceneTileProxyObject *tile_proxy_object = nullptr;
111 Label *tile_inspector_label = nullptr;
112 EditorInspector *tile_inspector = nullptr;
113
114 ItemList *scene_tiles_list = nullptr;
115 Button *scene_tile_add_button = nullptr;
116 Button *scene_tile_delete_button = nullptr;
117 EditorFileDialog *scene_select_dialog = nullptr;
118
119 void _tile_set_scenes_collection_source_changed();
120 void _scenes_collection_source_proxy_object_changed(const String &p_what);
121 void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, int p_idx);
122 void _scenes_list_item_activated(int p_index);
123
124 void _source_add_pressed();
125 void _scene_file_selected(const String &p_path);
126 void _source_delete_pressed();
127
128 // Update methods.
129 void _update_source_inspector();
130 void _update_tile_inspector();
131 void _update_scenes_list();
132 void _update_action_buttons();
133 void _update_all();
134
135 void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
136 bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
137
138 protected:
139 void _notification(int p_what);
140 static void _bind_methods();
141
142 public:
143 void edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
144 TileSetScenesCollectionSourceEditor();
145 ~TileSetScenesCollectionSourceEditor();
146 };