2017-11-24 06:09:51 +00:00
|
|
|
/*************************************************************************/
|
2014-02-10 01:10:30 +00:00
|
|
|
/* property_editor.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef PROPERTY_EDITOR_H
|
|
|
|
#define PROPERTY_EDITOR_H
|
|
|
|
|
2021-09-23 11:08:50 +00:00
|
|
|
#include "editor/editor_locale_dialog.h"
|
2017-08-26 15:46:49 +00:00
|
|
|
#include "editor/scene_tree_editor.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/button.h"
|
2016-05-03 21:20:09 +00:00
|
|
|
#include "scene/gui/check_box.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/check_button.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/color_picker.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/grid_container.h"
|
|
|
|
#include "scene/gui/label.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/menu_button.h"
|
2016-01-23 14:20:54 +00:00
|
|
|
#include "scene/gui/split_container.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/text_edit.h"
|
|
|
|
#include "scene/gui/texture_rect.h"
|
|
|
|
#include "scene/gui/tree.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-08-03 14:28:20 +00:00
|
|
|
class CreateDialog;
|
2022-02-12 01:46:22 +00:00
|
|
|
class EditorFileDialog;
|
|
|
|
class PropertyValueEvaluator;
|
2016-08-23 22:29:07 +00:00
|
|
|
class PropertySelector;
|
|
|
|
|
2021-06-04 16:03:15 +00:00
|
|
|
class EditorResourceConversionPlugin : public RefCounted {
|
|
|
|
GDCLASS(EditorResourceConversionPlugin, RefCounted);
|
2017-09-22 12:20:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2021-08-22 01:52:44 +00:00
|
|
|
GDVIRTUAL0RC(String, _converts_to)
|
2022-05-02 23:43:50 +00:00
|
|
|
GDVIRTUAL1RC(bool, _handles, Ref<Resource>)
|
|
|
|
GDVIRTUAL1RC(Ref<Resource>, _convert, Ref<Resource>)
|
2021-08-22 01:52:44 +00:00
|
|
|
|
2017-09-22 12:20:28 +00:00
|
|
|
public:
|
|
|
|
virtual String converts_to() const;
|
|
|
|
virtual bool handles(const Ref<Resource> &p_resource) const;
|
2018-07-25 01:11:03 +00:00
|
|
|
virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
|
2017-09-22 12:20:28 +00:00
|
|
|
};
|
|
|
|
|
2020-03-12 12:37:40 +00:00
|
|
|
class CustomPropertyEditor : public PopupPanel {
|
|
|
|
GDCLASS(CustomPropertyEditor, PopupPanel);
|
2015-08-30 00:09:11 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum {
|
2017-03-05 15:44:50 +00:00
|
|
|
MAX_VALUE_EDITORS = 12,
|
|
|
|
MAX_ACTION_BUTTONS = 5,
|
|
|
|
OBJ_MENU_LOAD = 0,
|
|
|
|
OBJ_MENU_EDIT = 1,
|
|
|
|
OBJ_MENU_CLEAR = 2,
|
|
|
|
OBJ_MENU_MAKE_UNIQUE = 3,
|
|
|
|
OBJ_MENU_COPY = 4,
|
|
|
|
OBJ_MENU_PASTE = 5,
|
2017-08-26 15:46:49 +00:00
|
|
|
OBJ_MENU_NEW_SCRIPT = 6,
|
2019-10-21 04:57:10 +00:00
|
|
|
OBJ_MENU_EXTEND_SCRIPT = 7,
|
|
|
|
OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
|
2017-09-22 12:20:28 +00:00
|
|
|
TYPE_BASE_ID = 100,
|
|
|
|
CONVERT_BASE_ID = 1000
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EASING_LINEAR,
|
|
|
|
EASING_EASE_IN,
|
|
|
|
EASING_EASE_OUT,
|
|
|
|
EASING_ZERO,
|
|
|
|
EASING_IN_OUT,
|
|
|
|
EASING_OUT_IN
|
|
|
|
};
|
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
PopupMenu *menu = nullptr;
|
|
|
|
SceneTreeDialog *scene_tree = nullptr;
|
|
|
|
EditorFileDialog *file = nullptr;
|
|
|
|
EditorLocaleDialog *locale = nullptr;
|
|
|
|
ConfirmationDialog *error = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
String name;
|
|
|
|
Variant::Type type;
|
|
|
|
Variant v;
|
2017-03-02 09:42:05 +00:00
|
|
|
List<String> field_names;
|
2022-05-02 14:28:25 +00:00
|
|
|
int hint = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
String hint_text;
|
2020-06-10 14:31:58 +00:00
|
|
|
HBoxContainer *value_hboxes[MAX_VALUE_EDITORS / 4];
|
2022-04-04 13:06:57 +00:00
|
|
|
VBoxContainer *value_vbox = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
LineEdit *value_editor[MAX_VALUE_EDITORS];
|
2017-03-02 09:42:05 +00:00
|
|
|
int focused_value_editor;
|
2014-02-10 01:10:30 +00:00
|
|
|
Label *value_label[MAX_VALUE_EDITORS];
|
2016-01-23 14:20:54 +00:00
|
|
|
HScrollBar *scroll[4];
|
2022-04-04 13:06:57 +00:00
|
|
|
HBoxContainer *action_hboxes = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
Button *action_buttons[MAX_ACTION_BUTTONS];
|
2022-04-04 13:06:57 +00:00
|
|
|
MenuButton *type_button = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
Vector<String> inheritors_array;
|
2022-04-04 13:06:57 +00:00
|
|
|
TextureRect *texture_preview = nullptr;
|
|
|
|
ColorPicker *color_picker = nullptr;
|
|
|
|
TextEdit *text_edit = nullptr;
|
2022-02-15 14:56:58 +00:00
|
|
|
bool read_only = false;
|
2022-05-02 14:28:25 +00:00
|
|
|
bool picking_viewport = false;
|
2022-04-04 13:06:57 +00:00
|
|
|
GridContainer *checks20gc = nullptr;
|
2016-05-03 21:20:09 +00:00
|
|
|
CheckBox *checks20[20];
|
2022-04-04 13:06:57 +00:00
|
|
|
SpinBox *spinbox = nullptr;
|
|
|
|
HSlider *slider = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Control *easing_draw = nullptr;
|
|
|
|
CreateDialog *create_dialog = nullptr;
|
|
|
|
PropertySelector *property_select = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Object *owner = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-02-15 14:56:58 +00:00
|
|
|
bool updating = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
PropertyValueEvaluator *evaluator = nullptr;
|
2016-05-01 08:33:32 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _text_edit_changed();
|
|
|
|
void _file_selected(String p_file);
|
2021-09-23 11:08:50 +00:00
|
|
|
void _locale_selected(String p_locale);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _modified(String p_string);
|
2018-09-13 19:53:14 +00:00
|
|
|
|
|
|
|
real_t _parse_real_expression(String text);
|
|
|
|
|
2015-08-30 00:09:11 +00:00
|
|
|
void _range_modified(double p_value);
|
2014-02-27 14:16:00 +00:00
|
|
|
void _focus_enter();
|
|
|
|
void _focus_exit();
|
2014-02-10 01:10:30 +00:00
|
|
|
void _action_pressed(int p_which);
|
|
|
|
void _type_create_selected(int p_idx);
|
2016-08-03 14:28:20 +00:00
|
|
|
void _create_dialog_callback();
|
2016-08-23 22:29:07 +00:00
|
|
|
void _create_selected_property(const String &p_prop);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _color_changed(const Color &p_color);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _draw_easing();
|
|
|
|
void _menu_option(int p_which);
|
2015-08-30 00:09:11 +00:00
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
void _drag_easing(const Ref<InputEvent> &p_ev);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _node_path_selected(NodePath p_path);
|
|
|
|
void show_value_editors(int p_amount);
|
2017-03-05 15:44:50 +00:00
|
|
|
void config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings);
|
|
|
|
void config_action_buttons(const List<String> &p_strings);
|
2015-10-10 12:09:09 +00:00
|
|
|
|
2017-03-02 09:42:05 +00:00
|
|
|
void _emit_changed_whole_or_field();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
2015-08-30 00:09:11 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2016-05-11 14:46:08 +00:00
|
|
|
void hide_menu();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Variant get_variant() const;
|
|
|
|
String get_name() const;
|
2015-08-30 00:09:11 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_read_only(bool p_read_only) { read_only = p_read_only; }
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text);
|
2015-08-30 00:09:11 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
CustomPropertyEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|