diff options
Diffstat (limited to 'editor/editor_properties.h')
-rw-r--r-- | editor/editor_properties.h | 193 |
1 files changed, 129 insertions, 64 deletions
diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 754d444309..1f40a7fe7b 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,6 +33,7 @@ #include "editor/create_dialog.h" #include "editor/editor_inspector.h" +#include "editor/editor_locale_dialog.h" #include "editor/editor_resource_picker.h" #include "editor/editor_spin_slider.h" #include "editor/property_selector.h" @@ -51,10 +52,10 @@ public: class EditorPropertyText : public EditorProperty { GDCLASS(EditorPropertyText, EditorProperty); - LineEdit *text; + LineEdit *text = nullptr; - bool updating; - bool string_name; + bool updating = false; + bool string_name = false; void _text_changed(const String &p_string); void _text_submitted(const String &p_string); @@ -71,11 +72,11 @@ public: class EditorPropertyMultilineText : public EditorProperty { GDCLASS(EditorPropertyMultilineText, EditorProperty); - TextEdit *text; + TextEdit *text = nullptr; - AcceptDialog *big_text_dialog; - TextEdit *big_text; - Button *open_big_text; + AcceptDialog *big_text_dialog = nullptr; + TextEdit *big_text = nullptr; + Button *open_big_text = nullptr; void _big_text_changed(); void _text_changed(); @@ -94,15 +95,15 @@ public: class EditorPropertyTextEnum : public EditorProperty { GDCLASS(EditorPropertyTextEnum, EditorProperty); - HBoxContainer *default_layout; - HBoxContainer *edit_custom_layout; + HBoxContainer *default_layout = nullptr; + HBoxContainer *edit_custom_layout = nullptr; - OptionButton *option_button; - Button *edit_button; + OptionButton *option_button = nullptr; + Button *edit_button = nullptr; - LineEdit *custom_value_edit; - Button *accept_button; - Button *cancel_button; + LineEdit *custom_value_edit = nullptr; + Button *accept_button = nullptr; + Button *cancel_button = nullptr; Vector<String> options; bool string_name = false; @@ -130,12 +131,12 @@ public: class EditorPropertyPath : public EditorProperty { GDCLASS(EditorPropertyPath, EditorProperty); Vector<String> extensions; - bool folder; - bool global; - bool save_mode; - EditorFileDialog *dialog; - LineEdit *path; - Button *path_edit; + bool folder = false; + bool global = false; + bool save_mode = false; + EditorFileDialog *dialog = nullptr; + LineEdit *path = nullptr; + Button *path_edit = nullptr; void _path_selected(const String &p_path); void _path_pressed(); @@ -153,12 +154,32 @@ public: EditorPropertyPath(); }; +class EditorPropertyLocale : public EditorProperty { + GDCLASS(EditorPropertyLocale, EditorProperty); + EditorLocaleDialog *dialog = nullptr; + LineEdit *locale = nullptr; + Button *locale_edit = nullptr; + + void _locale_selected(const String &p_locale); + void _locale_pressed(); + void _locale_focus_exited(); + +protected: + static void _bind_methods(); + void _notification(int p_what); + +public: + void setup(const String &p_hit_string); + virtual void update_property() override; + EditorPropertyLocale(); +}; + class EditorPropertyClassName : public EditorProperty { GDCLASS(EditorPropertyClassName, EditorProperty); private: - CreateDialog *dialog; - Button *property; + CreateDialog *dialog = nullptr; + Button *property = nullptr; String selected_type; String base_type; void _property_selected(); @@ -191,8 +212,8 @@ public: private: Type hint; - PropertySelector *selector; - Button *property; + PropertySelector *selector = nullptr; + Button *property = nullptr; String hint_text; void _property_selected(const String &p_selected); @@ -210,7 +231,7 @@ public: class EditorPropertyCheck : public EditorProperty { GDCLASS(EditorPropertyCheck, EditorProperty); - CheckBox *checkbox; + CheckBox *checkbox = nullptr; void _checkbox_pressed(); @@ -225,7 +246,7 @@ public: class EditorPropertyEnum : public EditorProperty { GDCLASS(EditorPropertyEnum, EditorProperty); - OptionButton *options; + OptionButton *options = nullptr; void _option_selected(int p_which); @@ -242,7 +263,7 @@ public: class EditorPropertyFlags : public EditorProperty { GDCLASS(EditorPropertyFlags, EditorProperty); - VBoxContainer *vbox; + VBoxContainer *vbox = nullptr; Vector<CheckBox *> flags; Vector<int> flag_indices; @@ -258,7 +279,46 @@ public: EditorPropertyFlags(); }; -class EditorPropertyLayersGrid; +///////////////////// LAYERS ///////////////////////// + +class EditorPropertyLayersGrid : public Control { + GDCLASS(EditorPropertyLayersGrid, Control); + +private: + Vector<Rect2> flag_rects; + Rect2 expand_rect; + bool expand_hovered = false; + bool expanded = false; + int expansion_rows = 0; + int hovered_index = -1; + bool read_only = false; + int renamed_layer_index = -1; + PopupMenu *layer_rename = nullptr; + ConfirmationDialog *rename_dialog = nullptr; + LineEdit *rename_dialog_text = nullptr; + + void _rename_pressed(int p_menu); + void _rename_operation_confirm(); + Size2 get_grid_size() const; + +protected: + void _notification(int p_what); + static void _bind_methods(); + +public: + uint32_t value = 0; + int layer_group_size = 0; + int layer_count = 0; + Vector<String> names; + Vector<String> tooltips; + + void set_read_only(bool p_read_only); + virtual Size2 get_minimum_size() const override; + virtual String get_tooltip(const Point2 &p_pos) const override; + void gui_input(const Ref<InputEvent> &p_ev) override; + void set_flag(uint32_t p_flag); + EditorPropertyLayersGrid(); +}; class EditorPropertyLayers : public EditorProperty { GDCLASS(EditorPropertyLayers, EditorProperty); @@ -274,14 +334,16 @@ public: }; private: - EditorPropertyLayersGrid *grid; + EditorPropertyLayersGrid *grid = nullptr; void _grid_changed(uint32_t p_grid); + String basename; LayerType layer_type; - PopupMenu *layers; - Button *button; + PopupMenu *layers = nullptr; + Button *button = nullptr; void _button_pressed(); void _menu_pressed(int p_menu); + void _refresh_names(); protected: virtual void _set_read_only(bool p_read_only) override; @@ -289,14 +351,15 @@ protected: public: void setup(LayerType p_layer_type); + void set_layer_name(int p_index, const String &p_name); virtual void update_property() override; EditorPropertyLayers(); }; class EditorPropertyInteger : public EditorProperty { GDCLASS(EditorPropertyInteger, EditorProperty); - EditorSpinSlider *spin; - bool setting; + EditorSpinSlider *spin = nullptr; + bool setting = false; void _value_changed(int64_t p_val); protected: @@ -311,7 +374,7 @@ public: class EditorPropertyObjectID : public EditorProperty { GDCLASS(EditorPropertyObjectID, EditorProperty); - Button *edit; + Button *edit = nullptr; String base_type; void _edit_pressed(); @@ -327,7 +390,7 @@ public: class EditorPropertyFloat : public EditorProperty { GDCLASS(EditorPropertyFloat, EditorProperty); - EditorSpinSlider *spin; + EditorSpinSlider *spin = nullptr; bool setting = false; bool angle_in_radians = false; void _value_changed(double p_val); @@ -344,14 +407,14 @@ public: class EditorPropertyEasing : public EditorProperty { GDCLASS(EditorPropertyEasing, EditorProperty); - Control *easing_draw; - PopupMenu *preset; - EditorSpinSlider *spin; - bool setting; + Control *easing_draw = nullptr; + PopupMenu *preset = nullptr; + EditorSpinSlider *spin = nullptr; + bool setting = false; - bool dragging; - bool full; - bool flip; + bool dragging = false; + bool full = false; + bool flip = false; enum { EASING_ZERO, @@ -387,7 +450,7 @@ public: class EditorPropertyVector2 : public EditorProperty { GDCLASS(EditorPropertyVector2, EditorProperty); EditorSpinSlider *spin[2]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -404,7 +467,7 @@ public: class EditorPropertyRect2 : public EditorProperty { GDCLASS(EditorPropertyRect2, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -441,7 +504,7 @@ public: class EditorPropertyVector2i : public EditorProperty { GDCLASS(EditorPropertyVector2i, EditorProperty); EditorSpinSlider *spin[2]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -458,7 +521,7 @@ public: class EditorPropertyRect2i : public EditorProperty { GDCLASS(EditorPropertyRect2i, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -475,7 +538,7 @@ public: class EditorPropertyVector3i : public EditorProperty { GDCLASS(EditorPropertyVector3i, EditorProperty); EditorSpinSlider *spin[3]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -492,7 +555,7 @@ public: class EditorPropertyPlane : public EditorProperty { GDCLASS(EditorPropertyPlane, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -509,7 +572,7 @@ public: class EditorPropertyQuaternion : public EditorProperty { GDCLASS(EditorPropertyQuaternion, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -526,7 +589,7 @@ public: class EditorPropertyAABB : public EditorProperty { GDCLASS(EditorPropertyAABB, EditorProperty); EditorSpinSlider *spin[6]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -543,7 +606,7 @@ public: class EditorPropertyTransform2D : public EditorProperty { GDCLASS(EditorPropertyTransform2D, EditorProperty); EditorSpinSlider *spin[6]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -560,7 +623,7 @@ public: class EditorPropertyBasis : public EditorProperty { GDCLASS(EditorPropertyBasis, EditorProperty); EditorSpinSlider *spin[9]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -577,7 +640,7 @@ public: class EditorPropertyTransform3D : public EditorProperty { GDCLASS(EditorPropertyTransform3D, EditorProperty); EditorSpinSlider *spin[12]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -594,7 +657,7 @@ public: class EditorPropertyColor : public EditorProperty { GDCLASS(EditorPropertyColor, EditorProperty); - ColorPickerButton *picker; + ColorPickerButton *picker = nullptr; void _color_changed(const Color &p_color); void _popup_closed(); void _picker_created(); @@ -614,17 +677,21 @@ public: class EditorPropertyNodePath : public EditorProperty { GDCLASS(EditorPropertyNodePath, EditorProperty); - Button *assign; - Button *clear; - SceneTreeDialog *scene_tree; + Button *assign = nullptr; + Button *clear = nullptr; + SceneTreeDialog *scene_tree = nullptr; NodePath base_hint; - bool use_path_from_scene_root; + bool use_path_from_scene_root = false; Vector<StringName> valid_types; void _node_selected(const NodePath &p_path); void _node_assign(); void _node_clear(); + bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + bool is_drop_valid(const Dictionary &p_drag_data) const; + protected: virtual void _set_read_only(bool p_read_only) override; static void _bind_methods(); @@ -638,7 +705,7 @@ public: class EditorPropertyRID : public EditorProperty { GDCLASS(EditorPropertyRID, EditorProperty); - Label *label; + Label *label = nullptr; public: virtual void update_property() override; @@ -662,7 +729,7 @@ class EditorPropertyResource : public EditorProperty { void _viewport_selected(const NodePath &p_path); - void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool); + void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool p_advance); void _sub_inspector_resource_selected(const RES &p_resource, const String &p_property); void _sub_inspector_object_id_selected(int p_id); @@ -696,9 +763,7 @@ class EditorInspectorDefaultPlugin : public EditorInspectorPlugin { public: virtual bool can_handle(Object *p_object) override; - virtual void parse_begin(Object *p_object) override; 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 uint32_t p_usage, const bool p_wide = false) override; - virtual void parse_end() override; 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 uint32_t p_usage, const bool p_wide = false); }; |