summaryrefslogtreecommitdiff
path: root/editor/editor_properties.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties.h')
-rw-r--r--editor/editor_properties.h147
1 files changed, 70 insertions, 77 deletions
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index be3e9db8ed..0cb21bb391 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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_resource_picker.h"
#include "editor/editor_spin_slider.h"
#include "editor/property_selector.h"
#include "editor/scene_tree_editor.h"
@@ -41,7 +42,7 @@
class EditorPropertyNil : public EditorProperty {
GDCLASS(EditorPropertyNil, EditorProperty);
- LineEdit *text;
+ LineEdit *text = nullptr;
public:
virtual void update_property() override;
@@ -55,7 +56,7 @@ class EditorPropertyText : public EditorProperty {
bool updating;
bool string_name;
void _text_changed(const String &p_string);
- void _text_entered(const String &p_string);
+ void _text_submitted(const String &p_string);
protected:
static void _bind_methods();
@@ -90,16 +91,35 @@ public:
class EditorPropertyTextEnum : public EditorProperty {
GDCLASS(EditorPropertyTextEnum, EditorProperty);
- OptionButton *options;
+ HBoxContainer *default_layout;
+ HBoxContainer *edit_custom_layout;
+
+ OptionButton *option_button;
+ Button *edit_button;
+
+ LineEdit *custom_value_edit;
+ Button *accept_button;
+ Button *cancel_button;
+
+ Vector<String> options;
+ bool string_name = false;
+ bool loose_mode = false;
+
+ void _emit_changed_value(String p_string);
void _option_selected(int p_which);
- bool string_name;
+
+ void _edit_custom_value();
+ void _custom_value_submitted(String p_value);
+ void _custom_value_accepted();
+ void _custom_value_cancelled();
protected:
static void _bind_methods();
+ void _notification(int p_what);
public:
- void setup(const Vector<String> &p_options, bool p_string_name = false);
+ void setup(const Vector<String> &p_options, bool p_string_name = false, bool p_loose_mode = false);
virtual void update_property() override;
EditorPropertyTextEnum();
};
@@ -239,8 +259,10 @@ public:
enum LayerType {
LAYER_PHYSICS_2D,
LAYER_RENDER_2D,
+ LAYER_NAVIGATION_2D,
LAYER_PHYSICS_3D,
LAYER_RENDER_3D,
+ LAYER_NAVIGATION_3D,
};
private:
@@ -295,7 +317,8 @@ public:
class EditorPropertyFloat : public EditorProperty {
GDCLASS(EditorPropertyFloat, EditorProperty);
EditorSpinSlider *spin;
- bool setting;
+ bool setting = false;
+ bool angle_in_radians = false;
void _value_changed(double p_val);
protected:
@@ -303,7 +326,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false);
EditorPropertyFloat();
};
@@ -360,7 +383,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyVector2(bool p_force_wide = false);
};
@@ -376,14 +399,15 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyRect2(bool p_force_wide = false);
};
class EditorPropertyVector3 : public EditorProperty {
GDCLASS(EditorPropertyVector3, EditorProperty);
EditorSpinSlider *spin[3];
- bool setting;
+ bool setting = false;
+ bool angle_in_radians = false;
void _value_changed(double p_val, const String &p_name);
protected:
@@ -394,7 +418,7 @@ public:
virtual void update_property() override;
virtual void update_using_vector(Vector3 p_vector);
virtual Vector3 get_vector();
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String(), bool p_angle_in_radians = false);
EditorPropertyVector3(bool p_force_wide = false);
};
@@ -410,7 +434,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider);
+ void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
EditorPropertyVector2i(bool p_force_wide = false);
};
@@ -426,7 +450,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider);
+ void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
EditorPropertyRect2i(bool p_force_wide = false);
};
@@ -442,7 +466,7 @@ protected:
public:
virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_no_slider);
+ void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String());
EditorPropertyVector3i(bool p_force_wide = false);
};
@@ -458,12 +482,12 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyPlane(bool p_force_wide = false);
};
-class EditorPropertyQuat : public EditorProperty {
- GDCLASS(EditorPropertyQuat, EditorProperty);
+class EditorPropertyQuaternion : public EditorProperty {
+ GDCLASS(EditorPropertyQuaternion, EditorProperty);
EditorSpinSlider *spin[4];
bool setting;
void _value_changed(double p_val, const String &p_name);
@@ -474,8 +498,8 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
- EditorPropertyQuat();
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ EditorPropertyQuaternion();
};
class EditorPropertyAABB : public EditorProperty {
@@ -490,7 +514,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyAABB();
};
@@ -506,7 +530,7 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyTransform2D();
};
@@ -522,12 +546,12 @@ protected:
public:
virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
EditorPropertyBasis();
};
-class EditorPropertyTransform : public EditorProperty {
- GDCLASS(EditorPropertyTransform, EditorProperty);
+class EditorPropertyTransform3D : public EditorProperty {
+ GDCLASS(EditorPropertyTransform3D, EditorProperty);
EditorSpinSlider *spin[12];
bool setting;
void _value_changed(double p_val, const String &p_name);
@@ -538,9 +562,9 @@ protected:
public:
virtual void update_property() override;
- virtual void update_using_transform(Transform p_transform);
- void setup(double p_min, double p_max, double p_step, bool p_no_slider);
- EditorPropertyTransform();
+ virtual void update_using_transform(Transform3D p_transform);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ EditorPropertyTransform3D();
};
class EditorPropertyColor : public EditorProperty {
@@ -549,6 +573,9 @@ class EditorPropertyColor : public EditorProperty {
void _color_changed(const Color &p_color);
void _popup_closed();
void _picker_created();
+ void _picker_opening();
+
+ Color last_color;
protected:
static void _bind_methods();
@@ -594,63 +621,27 @@ public:
class EditorPropertyResource : public EditorProperty {
GDCLASS(EditorPropertyResource, EditorProperty);
- enum MenuOption {
-
- OBJ_MENU_LOAD = 0,
- OBJ_MENU_EDIT = 1,
- OBJ_MENU_CLEAR = 2,
- OBJ_MENU_MAKE_UNIQUE = 3,
- OBJ_MENU_SAVE = 4,
- OBJ_MENU_COPY = 5,
- OBJ_MENU_PASTE = 6,
- OBJ_MENU_NEW_SCRIPT = 7,
- OBJ_MENU_EXTEND_SCRIPT = 8,
- OBJ_MENU_SHOW_IN_FILE_SYSTEM = 9,
- TYPE_BASE_ID = 100,
- CONVERT_BASE_ID = 1000
+ EditorResourcePicker *resource_picker = nullptr;
+ SceneTreeDialog *scene_tree = nullptr;
- };
-
- Button *assign;
- TextureRect *preview;
- Button *edit;
- PopupMenu *menu;
- EditorFileDialog *file;
- Vector<String> inheritors_array;
- EditorInspector *sub_inspector;
- VBoxContainer *sub_inspector_vbox;
-
- bool use_sub_inspector;
- bool dropping;
- String base_type;
+ bool use_sub_inspector = false;
+ EditorInspector *sub_inspector = nullptr;
+ VBoxContainer *sub_inspector_vbox = nullptr;
+ bool updating_theme = false;
+ bool opened_editor = false;
- SceneTreeDialog *scene_tree;
+ void _resource_selected(const RES &p_resource);
+ void _resource_changed(const RES &p_resource);
- void _file_selected(const String &p_path);
- void _menu_option(int p_which);
- void _resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj);
- void _resource_selected();
void _viewport_selected(const NodePath &p_path);
- void _update_menu_items();
-
- void _update_menu();
-
void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool);
void _sub_inspector_resource_selected(const RES &p_resource, const String &p_property);
void _sub_inspector_object_id_selected(int p_id);
- void _button_draw();
- Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
- bool _is_drop_valid(const Dictionary &p_drag_data) const;
- 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);
-
- void _button_input(const Ref<InputEvent> &p_event);
void _open_editor_pressed();
void _fold_other_editors(Object *p_self);
-
- bool opened_editor;
+ void _update_property_bg();
protected:
static void _bind_methods();
@@ -658,7 +649,7 @@ protected:
public:
virtual void update_property() override;
- void setup(const String &p_base_type);
+ void setup(Object *p_object, const String &p_path, const String &p_base_type);
void collapse_all_folding() override;
void expand_all_folding() override;
@@ -677,8 +668,10 @@ 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, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false) 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);
};
#endif // EDITOR_PROPERTIES_H