1 | /**************************************************************************/ |
2 | /* editor_properties.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 | #ifndef EDITOR_PROPERTIES_H |
32 | #define EDITOR_PROPERTIES_H |
33 | |
34 | #include "editor/editor_inspector.h" |
35 | |
36 | class CheckBox; |
37 | class ColorPickerButton; |
38 | class CreateDialog; |
39 | class EditorFileDialog; |
40 | class EditorLocaleDialog; |
41 | class EditorResourcePicker; |
42 | class EditorSpinSlider; |
43 | class PropertySelector; |
44 | class SceneTreeDialog; |
45 | class TextEdit; |
46 | class TextureButton; |
47 | |
48 | class EditorPropertyNil : public EditorProperty { |
49 | GDCLASS(EditorPropertyNil, EditorProperty); |
50 | LineEdit *text = nullptr; |
51 | |
52 | public: |
53 | virtual void update_property() override; |
54 | EditorPropertyNil(); |
55 | }; |
56 | |
57 | class EditorPropertyText : public EditorProperty { |
58 | GDCLASS(EditorPropertyText, EditorProperty); |
59 | LineEdit *text = nullptr; |
60 | |
61 | bool updating = false; |
62 | bool string_name = false; |
63 | void _text_changed(const String &p_string); |
64 | void _text_submitted(const String &p_string); |
65 | |
66 | protected: |
67 | virtual void _set_read_only(bool p_read_only) override; |
68 | static void _bind_methods(); |
69 | |
70 | public: |
71 | void set_string_name(bool p_enabled); |
72 | virtual void update_property() override; |
73 | void set_placeholder(const String &p_string); |
74 | void set_secret(bool p_enabled); |
75 | EditorPropertyText(); |
76 | }; |
77 | |
78 | class EditorPropertyMultilineText : public EditorProperty { |
79 | GDCLASS(EditorPropertyMultilineText, EditorProperty); |
80 | TextEdit *text = nullptr; |
81 | |
82 | AcceptDialog *big_text_dialog = nullptr; |
83 | TextEdit *big_text = nullptr; |
84 | Button *open_big_text = nullptr; |
85 | |
86 | void _big_text_changed(); |
87 | void _text_changed(); |
88 | void _open_big_text(); |
89 | bool expression = false; |
90 | |
91 | protected: |
92 | virtual void _set_read_only(bool p_read_only) override; |
93 | void _notification(int p_what); |
94 | static void _bind_methods(); |
95 | |
96 | public: |
97 | virtual void update_property() override; |
98 | EditorPropertyMultilineText(bool p_expression = false); |
99 | }; |
100 | |
101 | class EditorPropertyTextEnum : public EditorProperty { |
102 | GDCLASS(EditorPropertyTextEnum, EditorProperty); |
103 | |
104 | HBoxContainer *default_layout = nullptr; |
105 | HBoxContainer *edit_custom_layout = nullptr; |
106 | |
107 | OptionButton *option_button = nullptr; |
108 | Button *edit_button = nullptr; |
109 | |
110 | LineEdit *custom_value_edit = nullptr; |
111 | Button *accept_button = nullptr; |
112 | Button *cancel_button = nullptr; |
113 | |
114 | Vector<String> options; |
115 | bool string_name = false; |
116 | bool loose_mode = false; |
117 | |
118 | void _emit_changed_value(String p_string); |
119 | void _option_selected(int p_which); |
120 | |
121 | void _edit_custom_value(); |
122 | void _custom_value_submitted(String p_value); |
123 | void _custom_value_accepted(); |
124 | void _custom_value_canceled(); |
125 | |
126 | protected: |
127 | virtual void _set_read_only(bool p_read_only) override; |
128 | static void _bind_methods(); |
129 | void _notification(int p_what); |
130 | |
131 | public: |
132 | void setup(const Vector<String> &p_options, bool p_string_name = false, bool p_loose_mode = false); |
133 | virtual void update_property() override; |
134 | EditorPropertyTextEnum(); |
135 | }; |
136 | |
137 | class EditorPropertyPath : public EditorProperty { |
138 | GDCLASS(EditorPropertyPath, EditorProperty); |
139 | Vector<String> extensions; |
140 | bool folder = false; |
141 | bool global = false; |
142 | bool save_mode = false; |
143 | EditorFileDialog *dialog = nullptr; |
144 | LineEdit *path = nullptr; |
145 | Button *path_edit = nullptr; |
146 | |
147 | void _path_selected(const String &p_path); |
148 | void _path_pressed(); |
149 | void _path_focus_exited(); |
150 | void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
151 | bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
152 | |
153 | protected: |
154 | virtual void _set_read_only(bool p_read_only) override; |
155 | static void _bind_methods(); |
156 | void _notification(int p_what); |
157 | |
158 | public: |
159 | void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global); |
160 | void set_save_mode(); |
161 | virtual void update_property() override; |
162 | EditorPropertyPath(); |
163 | }; |
164 | |
165 | class EditorPropertyLocale : public EditorProperty { |
166 | GDCLASS(EditorPropertyLocale, EditorProperty); |
167 | EditorLocaleDialog *dialog = nullptr; |
168 | LineEdit *locale = nullptr; |
169 | Button *locale_edit = nullptr; |
170 | |
171 | void _locale_selected(const String &p_locale); |
172 | void _locale_pressed(); |
173 | void _locale_focus_exited(); |
174 | |
175 | protected: |
176 | static void _bind_methods(); |
177 | void _notification(int p_what); |
178 | |
179 | public: |
180 | void setup(const String &p_hit_string); |
181 | virtual void update_property() override; |
182 | EditorPropertyLocale(); |
183 | }; |
184 | |
185 | class EditorPropertyClassName : public EditorProperty { |
186 | GDCLASS(EditorPropertyClassName, EditorProperty); |
187 | |
188 | private: |
189 | CreateDialog *dialog = nullptr; |
190 | Button *property = nullptr; |
191 | String selected_type; |
192 | String base_type; |
193 | void _property_selected(); |
194 | void _dialog_created(); |
195 | |
196 | protected: |
197 | virtual void _set_read_only(bool p_read_only) override; |
198 | static void _bind_methods(); |
199 | |
200 | public: |
201 | void setup(const String &p_base_type, const String &p_selected_type); |
202 | virtual void update_property() override; |
203 | EditorPropertyClassName(); |
204 | }; |
205 | |
206 | class EditorPropertyCheck : public EditorProperty { |
207 | GDCLASS(EditorPropertyCheck, EditorProperty); |
208 | CheckBox *checkbox = nullptr; |
209 | |
210 | void _checkbox_pressed(); |
211 | |
212 | protected: |
213 | virtual void _set_read_only(bool p_read_only) override; |
214 | static void _bind_methods(); |
215 | |
216 | public: |
217 | virtual void update_property() override; |
218 | EditorPropertyCheck(); |
219 | }; |
220 | |
221 | class EditorPropertyEnum : public EditorProperty { |
222 | GDCLASS(EditorPropertyEnum, EditorProperty); |
223 | OptionButton *options = nullptr; |
224 | |
225 | void _option_selected(int p_which); |
226 | |
227 | protected: |
228 | virtual void _set_read_only(bool p_read_only) override; |
229 | static void _bind_methods(); |
230 | |
231 | public: |
232 | void setup(const Vector<String> &p_options); |
233 | virtual void update_property() override; |
234 | void set_option_button_clip(bool p_enable); |
235 | EditorPropertyEnum(); |
236 | }; |
237 | |
238 | class EditorPropertyFlags : public EditorProperty { |
239 | GDCLASS(EditorPropertyFlags, EditorProperty); |
240 | VBoxContainer *vbox = nullptr; |
241 | Vector<CheckBox *> flags; |
242 | Vector<uint32_t> flag_values; |
243 | |
244 | void _flag_toggled(int p_index); |
245 | |
246 | protected: |
247 | virtual void _set_read_only(bool p_read_only) override; |
248 | static void _bind_methods(); |
249 | |
250 | public: |
251 | void setup(const Vector<String> &p_options); |
252 | virtual void update_property() override; |
253 | EditorPropertyFlags(); |
254 | }; |
255 | |
256 | ///////////////////// LAYERS ///////////////////////// |
257 | |
258 | class EditorPropertyLayersGrid : public Control { |
259 | GDCLASS(EditorPropertyLayersGrid, Control); |
260 | |
261 | private: |
262 | Vector<Rect2> flag_rects; |
263 | Rect2 expand_rect; |
264 | bool expand_hovered = false; |
265 | bool expanded = false; |
266 | int expansion_rows = 0; |
267 | uint32_t hovered_index = INT32_MAX; // Nothing is hovered. |
268 | bool read_only = false; |
269 | int renamed_layer_index = -1; |
270 | PopupMenu *layer_rename = nullptr; |
271 | ConfirmationDialog *rename_dialog = nullptr; |
272 | LineEdit *rename_dialog_text = nullptr; |
273 | |
274 | void _rename_pressed(int ); |
275 | void _rename_operation_confirm(); |
276 | void _update_hovered(const Vector2 &p_position); |
277 | void _on_hover_exit(); |
278 | void _update_flag(bool p_replace); |
279 | Size2 get_grid_size() const; |
280 | |
281 | protected: |
282 | void _notification(int p_what); |
283 | static void _bind_methods(); |
284 | |
285 | public: |
286 | uint32_t value = 0; |
287 | int layer_group_size = 0; |
288 | uint32_t layer_count = 0; |
289 | Vector<String> names; |
290 | Vector<String> tooltips; |
291 | |
292 | void set_read_only(bool p_read_only); |
293 | virtual Size2 get_minimum_size() const override; |
294 | virtual String get_tooltip(const Point2 &p_pos) const override; |
295 | void gui_input(const Ref<InputEvent> &p_ev) override; |
296 | void set_flag(uint32_t p_flag); |
297 | EditorPropertyLayersGrid(); |
298 | }; |
299 | |
300 | class EditorPropertyLayers : public EditorProperty { |
301 | GDCLASS(EditorPropertyLayers, EditorProperty); |
302 | |
303 | public: |
304 | enum LayerType { |
305 | LAYER_PHYSICS_2D, |
306 | LAYER_RENDER_2D, |
307 | LAYER_NAVIGATION_2D, |
308 | LAYER_PHYSICS_3D, |
309 | LAYER_RENDER_3D, |
310 | LAYER_NAVIGATION_3D, |
311 | LAYER_AVOIDANCE, |
312 | }; |
313 | |
314 | private: |
315 | EditorPropertyLayersGrid *grid = nullptr; |
316 | void _grid_changed(uint32_t p_grid); |
317 | String basename; |
318 | LayerType layer_type; |
319 | PopupMenu *layers = nullptr; |
320 | TextureButton *button = nullptr; |
321 | |
322 | void _button_pressed(); |
323 | void (int ); |
324 | void _refresh_names(); |
325 | |
326 | protected: |
327 | void _notification(int p_what); |
328 | virtual void _set_read_only(bool p_read_only) override; |
329 | static void _bind_methods(); |
330 | |
331 | public: |
332 | void setup(LayerType p_layer_type); |
333 | void set_layer_name(int p_index, const String &p_name); |
334 | String get_layer_name(int p_index) const; |
335 | virtual void update_property() override; |
336 | EditorPropertyLayers(); |
337 | }; |
338 | |
339 | class EditorPropertyInteger : public EditorProperty { |
340 | GDCLASS(EditorPropertyInteger, EditorProperty); |
341 | EditorSpinSlider *spin = nullptr; |
342 | bool setting = false; |
343 | void _value_changed(int64_t p_val); |
344 | |
345 | protected: |
346 | virtual void _set_read_only(bool p_read_only) override; |
347 | static void _bind_methods(); |
348 | |
349 | public: |
350 | virtual void update_property() override; |
351 | void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_hide_slider, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix = String()); |
352 | EditorPropertyInteger(); |
353 | }; |
354 | |
355 | class EditorPropertyObjectID : public EditorProperty { |
356 | GDCLASS(EditorPropertyObjectID, EditorProperty); |
357 | Button *edit = nullptr; |
358 | String base_type; |
359 | void _edit_pressed(); |
360 | |
361 | protected: |
362 | virtual void _set_read_only(bool p_read_only) override; |
363 | static void _bind_methods(); |
364 | |
365 | public: |
366 | virtual void update_property() override; |
367 | void setup(const String &p_base_type); |
368 | EditorPropertyObjectID(); |
369 | }; |
370 | |
371 | class EditorPropertySignal : public EditorProperty { |
372 | GDCLASS(EditorPropertySignal, EditorProperty); |
373 | Button *edit = nullptr; |
374 | String base_type; |
375 | void _edit_pressed(); |
376 | |
377 | protected: |
378 | static void _bind_methods(); |
379 | |
380 | public: |
381 | virtual void update_property() override; |
382 | EditorPropertySignal(); |
383 | }; |
384 | |
385 | class EditorPropertyCallable : public EditorProperty { |
386 | GDCLASS(EditorPropertyCallable, EditorProperty); |
387 | Button *edit = nullptr; |
388 | String base_type; |
389 | |
390 | protected: |
391 | static void _bind_methods(); |
392 | |
393 | public: |
394 | virtual void update_property() override; |
395 | EditorPropertyCallable(); |
396 | }; |
397 | |
398 | class EditorPropertyFloat : public EditorProperty { |
399 | GDCLASS(EditorPropertyFloat, EditorProperty); |
400 | EditorSpinSlider *spin = nullptr; |
401 | bool setting = false; |
402 | bool angle_in_radians = false; |
403 | void _value_changed(double p_val); |
404 | |
405 | protected: |
406 | virtual void _set_read_only(bool p_read_only) override; |
407 | static void _bind_methods(); |
408 | |
409 | public: |
410 | virtual void update_property() override; |
411 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false); |
412 | EditorPropertyFloat(); |
413 | }; |
414 | |
415 | class EditorPropertyEasing : public EditorProperty { |
416 | GDCLASS(EditorPropertyEasing, EditorProperty); |
417 | Control *easing_draw = nullptr; |
418 | PopupMenu *preset = nullptr; |
419 | EditorSpinSlider *spin = nullptr; |
420 | bool setting = false; |
421 | |
422 | bool dragging = false; |
423 | bool full = false; |
424 | bool flip = false; |
425 | bool positive_only = false; |
426 | |
427 | enum { |
428 | EASING_ZERO, |
429 | EASING_LINEAR, |
430 | EASING_IN, |
431 | EASING_OUT, |
432 | EASING_IN_OUT, |
433 | EASING_OUT_IN, |
434 | EASING_MAX |
435 | |
436 | }; |
437 | |
438 | void _drag_easing(const Ref<InputEvent> &p_ev); |
439 | void _draw_easing(); |
440 | void _set_preset(int); |
441 | |
442 | void _setup_spin(); |
443 | void _spin_value_changed(double p_value); |
444 | void _spin_focus_exited(); |
445 | |
446 | void _notification(int p_what); |
447 | |
448 | protected: |
449 | virtual void _set_read_only(bool p_read_only) override; |
450 | static void _bind_methods(); |
451 | |
452 | public: |
453 | virtual void update_property() override; |
454 | void setup(bool p_positive_only, bool p_flip); |
455 | EditorPropertyEasing(); |
456 | }; |
457 | |
458 | class EditorPropertyRect2 : public EditorProperty { |
459 | GDCLASS(EditorPropertyRect2, EditorProperty); |
460 | EditorSpinSlider *spin[4]; |
461 | bool setting = false; |
462 | void _value_changed(double p_val, const String &p_name); |
463 | |
464 | protected: |
465 | virtual void _set_read_only(bool p_read_only) override; |
466 | void _notification(int p_what); |
467 | static void _bind_methods(); |
468 | |
469 | public: |
470 | virtual void update_property() override; |
471 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
472 | EditorPropertyRect2(bool p_force_wide = false); |
473 | }; |
474 | |
475 | class EditorPropertyRect2i : public EditorProperty { |
476 | GDCLASS(EditorPropertyRect2i, EditorProperty); |
477 | EditorSpinSlider *spin[4]; |
478 | bool setting = false; |
479 | void _value_changed(double p_val, const String &p_name); |
480 | |
481 | protected: |
482 | virtual void _set_read_only(bool p_read_only) override; |
483 | void _notification(int p_what); |
484 | static void _bind_methods(); |
485 | |
486 | public: |
487 | virtual void update_property() override; |
488 | void setup(int p_min, int p_max, const String &p_suffix = String()); |
489 | EditorPropertyRect2i(bool p_force_wide = false); |
490 | }; |
491 | |
492 | class EditorPropertyPlane : public EditorProperty { |
493 | GDCLASS(EditorPropertyPlane, EditorProperty); |
494 | EditorSpinSlider *spin[4]; |
495 | bool setting = false; |
496 | void _value_changed(double p_val, const String &p_name); |
497 | |
498 | protected: |
499 | virtual void _set_read_only(bool p_read_only) override; |
500 | void _notification(int p_what); |
501 | static void _bind_methods(); |
502 | |
503 | public: |
504 | virtual void update_property() override; |
505 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
506 | EditorPropertyPlane(bool p_force_wide = false); |
507 | }; |
508 | |
509 | class EditorPropertyQuaternion : public EditorProperty { |
510 | GDCLASS(EditorPropertyQuaternion, EditorProperty); |
511 | BoxContainer *default_layout = nullptr; |
512 | EditorSpinSlider *spin[4]; |
513 | bool setting = false; |
514 | |
515 | Button *warning = nullptr; |
516 | AcceptDialog *warning_dialog = nullptr; |
517 | |
518 | Label *euler_label = nullptr; |
519 | VBoxContainer *edit_custom_bc = nullptr; |
520 | EditorSpinSlider *euler[3]; |
521 | Button *edit_button = nullptr; |
522 | |
523 | Vector3 edit_euler; |
524 | |
525 | void _value_changed(double p_val, const String &p_name); |
526 | void _edit_custom_value(); |
527 | void _custom_value_changed(double p_val); |
528 | void _warning_pressed(); |
529 | |
530 | bool is_grabbing_euler(); |
531 | |
532 | protected: |
533 | virtual void _set_read_only(bool p_read_only) override; |
534 | void _notification(int p_what); |
535 | static void _bind_methods(); |
536 | |
537 | public: |
538 | virtual void update_property() override; |
539 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String(), bool p_hide_editor = false); |
540 | EditorPropertyQuaternion(); |
541 | }; |
542 | |
543 | class EditorPropertyAABB : public EditorProperty { |
544 | GDCLASS(EditorPropertyAABB, EditorProperty); |
545 | EditorSpinSlider *spin[6]; |
546 | bool setting = false; |
547 | void _value_changed(double p_val, const String &p_name); |
548 | |
549 | protected: |
550 | virtual void _set_read_only(bool p_read_only) override; |
551 | void _notification(int p_what); |
552 | static void _bind_methods(); |
553 | |
554 | public: |
555 | virtual void update_property() override; |
556 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
557 | EditorPropertyAABB(); |
558 | }; |
559 | |
560 | class EditorPropertyTransform2D : public EditorProperty { |
561 | GDCLASS(EditorPropertyTransform2D, EditorProperty); |
562 | EditorSpinSlider *spin[6]; |
563 | bool setting = false; |
564 | void _value_changed(double p_val, const String &p_name); |
565 | |
566 | protected: |
567 | virtual void _set_read_only(bool p_read_only) override; |
568 | void _notification(int p_what); |
569 | static void _bind_methods(); |
570 | |
571 | public: |
572 | virtual void update_property() override; |
573 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
574 | EditorPropertyTransform2D(bool p_include_origin = true); |
575 | }; |
576 | |
577 | class EditorPropertyBasis : public EditorProperty { |
578 | GDCLASS(EditorPropertyBasis, EditorProperty); |
579 | EditorSpinSlider *spin[9]; |
580 | bool setting = false; |
581 | void _value_changed(double p_val, const String &p_name); |
582 | |
583 | protected: |
584 | virtual void _set_read_only(bool p_read_only) override; |
585 | void _notification(int p_what); |
586 | static void _bind_methods(); |
587 | |
588 | public: |
589 | virtual void update_property() override; |
590 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
591 | EditorPropertyBasis(); |
592 | }; |
593 | |
594 | class EditorPropertyTransform3D : public EditorProperty { |
595 | GDCLASS(EditorPropertyTransform3D, EditorProperty); |
596 | EditorSpinSlider *spin[12]; |
597 | bool setting = false; |
598 | void _value_changed(double p_val, const String &p_name); |
599 | |
600 | protected: |
601 | virtual void _set_read_only(bool p_read_only) override; |
602 | void _notification(int p_what); |
603 | static void _bind_methods(); |
604 | |
605 | public: |
606 | virtual void update_property() override; |
607 | virtual void update_using_transform(Transform3D p_transform); |
608 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
609 | EditorPropertyTransform3D(); |
610 | }; |
611 | |
612 | class EditorPropertyProjection : public EditorProperty { |
613 | GDCLASS(EditorPropertyProjection, EditorProperty); |
614 | EditorSpinSlider *spin[16]; |
615 | bool setting = false; |
616 | void _value_changed(double p_val, const String &p_name); |
617 | |
618 | protected: |
619 | virtual void _set_read_only(bool p_read_only) override; |
620 | void _notification(int p_what); |
621 | static void _bind_methods(); |
622 | |
623 | public: |
624 | virtual void update_property() override; |
625 | virtual void update_using_transform(Projection p_transform); |
626 | void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); |
627 | EditorPropertyProjection(); |
628 | }; |
629 | |
630 | class EditorPropertyColor : public EditorProperty { |
631 | GDCLASS(EditorPropertyColor, EditorProperty); |
632 | ColorPickerButton *picker = nullptr; |
633 | void _color_changed(const Color &p_color); |
634 | void (); |
635 | void _picker_created(); |
636 | void _picker_opening(); |
637 | |
638 | Color last_color; |
639 | |
640 | protected: |
641 | virtual void _set_read_only(bool p_read_only) override; |
642 | void _notification(int p_what); |
643 | |
644 | public: |
645 | virtual void update_property() override; |
646 | void setup(bool p_show_alpha); |
647 | EditorPropertyColor(); |
648 | }; |
649 | |
650 | class EditorPropertyNodePath : public EditorProperty { |
651 | GDCLASS(EditorPropertyNodePath, EditorProperty); |
652 | Button *assign = nullptr; |
653 | Button *clear = nullptr; |
654 | SceneTreeDialog *scene_tree = nullptr; |
655 | NodePath base_hint; |
656 | bool use_path_from_scene_root = false; |
657 | bool editing_node = false; |
658 | |
659 | Vector<StringName> valid_types; |
660 | void _node_selected(const NodePath &p_path); |
661 | void _node_assign(); |
662 | void _node_clear(); |
663 | Node *get_base_node(); |
664 | |
665 | bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
666 | void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
667 | bool is_drop_valid(const Dictionary &p_drag_data) const; |
668 | |
669 | virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const override; |
670 | |
671 | protected: |
672 | virtual void _set_read_only(bool p_read_only) override; |
673 | static void _bind_methods(); |
674 | void _notification(int p_what); |
675 | |
676 | public: |
677 | virtual void update_property() override; |
678 | void setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root = true, bool p_editing_node = false); |
679 | EditorPropertyNodePath(); |
680 | }; |
681 | |
682 | class EditorPropertyRID : public EditorProperty { |
683 | GDCLASS(EditorPropertyRID, EditorProperty); |
684 | Label *label = nullptr; |
685 | |
686 | public: |
687 | virtual void update_property() override; |
688 | EditorPropertyRID(); |
689 | }; |
690 | |
691 | class EditorPropertyResource : public EditorProperty { |
692 | GDCLASS(EditorPropertyResource, EditorProperty); |
693 | |
694 | EditorResourcePicker *resource_picker = nullptr; |
695 | SceneTreeDialog *scene_tree = nullptr; |
696 | |
697 | bool use_sub_inspector = false; |
698 | EditorInspector *sub_inspector = nullptr; |
699 | VBoxContainer *sub_inspector_vbox = nullptr; |
700 | bool updating_theme = false; |
701 | bool opened_editor = false; |
702 | |
703 | void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect); |
704 | void _resource_changed(const Ref<Resource> &p_resource); |
705 | |
706 | void _viewport_selected(const NodePath &p_path); |
707 | |
708 | void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance); |
709 | void _sub_inspector_resource_selected(const Ref<Resource> &p_resource, const String &p_property); |
710 | void _sub_inspector_object_id_selected(int p_id); |
711 | |
712 | void _open_editor_pressed(); |
713 | void _update_property_bg(); |
714 | void _update_preferred_shader(); |
715 | |
716 | protected: |
717 | virtual void _set_read_only(bool p_read_only) override; |
718 | void _notification(int p_what); |
719 | |
720 | public: |
721 | virtual void update_property() override; |
722 | void setup(Object *p_object, const String &p_path, const String &p_base_type); |
723 | |
724 | void collapse_all_folding() override; |
725 | void expand_all_folding() override; |
726 | void expand_revertable() override; |
727 | |
728 | void set_use_sub_inspector(bool p_enable); |
729 | void fold_resource(); |
730 | |
731 | EditorPropertyResource(); |
732 | }; |
733 | |
734 | /////////////////////////////////////////////////// |
735 | /// \brief The EditorInspectorDefaultPlugin class |
736 | /// |
737 | class EditorInspectorDefaultPlugin : public EditorInspectorPlugin { |
738 | GDCLASS(EditorInspectorDefaultPlugin, EditorInspectorPlugin); |
739 | |
740 | public: |
741 | virtual bool can_handle(Object *p_object) override; |
742 | virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override; |
743 | |
744 | static EditorProperty *get_editor_for_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false); |
745 | }; |
746 | |
747 | #endif // EDITOR_PROPERTIES_H |
748 | |