summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_inspector.h')
-rw-r--r--editor/editor_inspector.h133
1 files changed, 127 insertions, 6 deletions
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 8c522f00ef..b71efe8f19 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -32,8 +32,12 @@
#define EDITOR_INSPECTOR_H
#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/panel_container.h"
#include "scene/gui/scroll_container.h"
+#include "scene/gui/texture_rect.h"
class UndoRedo;
@@ -115,9 +119,11 @@ private:
protected:
void _notification(int p_what);
static void _bind_methods();
+ virtual void _set_read_only(bool p_read_only);
virtual void gui_input(const Ref<InputEvent> &p_event) override;
virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override;
+ const Color *_get_property_colors();
public:
void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);
@@ -250,9 +256,7 @@ class EditorInspectorSection : public Container {
String label;
String section;
- Object *object;
- VBoxContainer *vbox;
- bool vbox_added; //optimization
+ bool vbox_added; // Optimization.
Color bg_color;
bool foldable;
@@ -262,6 +266,9 @@ class EditorInspectorSection : public Container {
void _test_unfold();
protected:
+ Object *object;
+ VBoxContainer *vbox;
+
void _notification(int p_what);
static void _bind_methods();
virtual void gui_input(const Ref<InputEvent> &p_event) override;
@@ -280,6 +287,118 @@ public:
~EditorInspectorSection();
};
+class EditorInspectorArray : public EditorInspectorSection {
+ GDCLASS(EditorInspectorArray, EditorInspectorSection);
+
+ UndoRedo *undo_redo;
+
+ enum Mode {
+ MODE_NONE,
+ MODE_USE_COUNT_PROPERTY,
+ MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION,
+ } mode;
+ StringName count_property;
+ StringName array_element_prefix;
+
+ int count = 0;
+
+ VBoxContainer *elements_vbox;
+
+ Control *control_dropping;
+ bool dropping = false;
+
+ Button *add_button;
+
+ AcceptDialog *resize_dialog;
+ int new_size = 0;
+ LineEdit *new_size_line_edit;
+
+ // Pagination
+ int page_lenght = 5;
+ int page = 0;
+ int max_page = 0;
+ int begin_array_index = 0;
+ int end_array_index = 0;
+ HBoxContainer *hbox_pagination;
+ Button *first_page_button;
+ Button *prev_page_button;
+ LineEdit *page_line_edit;
+ Label *page_count_label;
+ Button *next_page_button;
+ Button *last_page_button;
+
+ enum MenuOptions {
+ OPTION_MOVE_UP = 0,
+ OPTION_MOVE_DOWN,
+ OPTION_NEW_BEFORE,
+ OPTION_NEW_AFTER,
+ OPTION_REMOVE,
+ OPTION_CLEAR_ARRAY,
+ OPTION_RESIZE_ARRAY,
+ };
+ int popup_array_index_pressed = -1;
+ PopupMenu *rmb_popup;
+
+ struct ArrayElement {
+ PanelContainer *panel;
+ MarginContainer *margin;
+ HBoxContainer *hbox;
+ TextureRect *move_texture_rect;
+ VBoxContainer *vbox;
+ };
+ LocalVector<ArrayElement> array_elements;
+
+ Ref<StyleBoxFlat> odd_style;
+ Ref<StyleBoxFlat> even_style;
+
+ int _get_array_count();
+ void _add_button_pressed();
+
+ void _first_page_button_pressed();
+ void _prev_page_button_pressed();
+ void _page_line_edit_text_submitted(String p_text);
+ void _next_page_button_pressed();
+ void _last_page_button_pressed();
+
+ void _rmb_popup_id_pressed(int p_id);
+
+ void _control_dropping_draw();
+
+ void _vbox_visibility_changed();
+
+ void _panel_draw(int p_index);
+ void _panel_gui_input(Ref<InputEvent> p_event, int p_index);
+ void _move_element(int p_element_index, int p_to_pos);
+ void _clear_array();
+ void _resize_array(int p_size);
+ Array _extract_properties_as_array(const List<PropertyInfo> &p_list);
+ int _drop_position() const;
+
+ void _new_size_line_edit_text_changed(String p_text);
+ void _new_size_line_edit_text_submitted(String p_text);
+ void _resize_dialog_confirmed();
+
+ void _update_elements_visibility();
+ void _setup();
+
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void set_undo_redo(UndoRedo *p_undo_redo);
+
+ void setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable);
+ void setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable);
+ VBoxContainer *get_vbox(int p_index);
+
+ EditorInspectorArray();
+};
+
class EditorInspector : public ScrollContainer {
GDCLASS(EditorInspector, ScrollContainer);
@@ -339,9 +458,8 @@ class EditorInspector : public ScrollContainer {
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
- void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
- void _property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
- void _multiple_properties_changed(Vector<String> p_paths, Array p_values);
+ void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false);
+ void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false);
void _property_keyed(const String &p_path, bool p_advance);
void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
void _property_deleted(const String &p_path);
@@ -354,6 +472,9 @@ class EditorInspector : public ScrollContainer {
void _node_removed(Node *p_node);
+ Map<StringName, int> per_array_page;
+ void _page_change_request(int p_new_page, const StringName &p_array_prefix);
+
void _changed_callback();
void _edit_request_change(Object *p_object, const String &p_prop);