summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp63
1 files changed, 42 insertions, 21 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 9ec9df2ee9..c134786b89 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 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 */
@@ -31,8 +31,10 @@
#include "editor_properties.h"
#include "editor/editor_resource_preview.h"
+#include "editor/filesystem_dock.h"
#include "editor_node.h"
#include "editor_properties_array_dict.h"
+#include "editor_scale.h"
#include "scene/main/viewport.h"
///////////////////// NULL /////////////////////////
@@ -803,10 +805,10 @@ EditorPropertyLayers::EditorPropertyLayers() {
///////////////////// INT /////////////////////////
-void EditorPropertyInteger::_value_changed(double val) {
+void EditorPropertyInteger::_value_changed(int64_t val) {
if (setting)
return;
- emit_changed(get_edited_property(), (int64_t)val);
+ emit_changed(get_edited_property(), val);
}
void EditorPropertyInteger::update_property() {
@@ -814,14 +816,19 @@ void EditorPropertyInteger::update_property() {
setting = true;
spin->set_value(val);
setting = false;
+#ifdef DEBUG_ENABLED
+ // If spin (currently EditorSplinSlider : Range) is changed so that it can use int64_t, then the below warning wouldn't be a problem.
+ if (val != (int64_t)(double)(val)) {
+ WARN_PRINT("Cannot reliably represent '" + itos(val) + "' in the inspector, value is too large.");
+ }
+#endif
}
void EditorPropertyInteger::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyInteger::_value_changed);
}
-void EditorPropertyInteger::setup(int p_min, int p_max, int p_step, bool p_allow_greater, bool p_allow_lesser) {
+void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser) {
spin->set_min(p_min);
spin->set_max(p_max);
spin->set_step(p_step);
@@ -979,8 +986,6 @@ void EditorPropertyEasing::_draw_easing() {
RID ci = easing_draw->get_canvas_item();
Size2 s = easing_draw->get_size();
- Rect2 r(Point2(), s);
- r = r.grow(3);
const int points = 48;
@@ -1884,6 +1889,23 @@ void EditorPropertyColor::_bind_methods() {
void EditorPropertyColor::update_property() {
picker->set_pick_color(get_edited_object()->get(get_edited_property()));
+ const Color color = picker->get_pick_color();
+
+ // Add a tooltip to display each channel's values without having to click the ColorPickerButton
+ if (picker->is_editing_alpha()) {
+ picker->set_tooltip(vformat(
+ "R: %s\nG: %s\nB: %s\nA: %s",
+ rtos(color.r).pad_decimals(2),
+ rtos(color.g).pad_decimals(2),
+ rtos(color.b).pad_decimals(2),
+ rtos(color.a).pad_decimals(2)));
+ } else {
+ picker->set_tooltip(vformat(
+ "R: %s\nG: %s\nB: %s",
+ rtos(color.r).pad_decimals(2),
+ rtos(color.g).pad_decimals(2),
+ rtos(color.b).pad_decimals(2)));
+ }
}
void EditorPropertyColor::setup(bool p_show_alpha) {
@@ -2205,7 +2227,14 @@ void EditorPropertyResource::_menu_option(int p_which) {
case OBJ_MENU_NEW_SCRIPT: {
if (Object::cast_to<Node>(get_edited_object())) {
- EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()));
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), false);
+ }
+
+ } break;
+ case OBJ_MENU_EXTEND_SCRIPT: {
+
+ if (Object::cast_to<Node>(get_edited_object())) {
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), true);
}
} break;
@@ -2338,7 +2367,8 @@ void EditorPropertyResource::_update_menu_items() {
menu->clear();
if (get_edited_property() == "script" && base_type == "Script" && Object::cast_to<Node>(get_edited_object())) {
- menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
menu->add_separator();
} else if (base_type != "") {
int idx = 0;
@@ -2607,14 +2637,6 @@ void EditorPropertyResource::update_property() {
get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this);
}
opened_editor = true;
- /*
- Button *open_in_editor = memnew(Button);
- open_in_editor->set_text(TTR("Open Editor"));
- open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
- sub_inspector_vbox->add_child(open_in_editor);
- open_in_editor->connect("pressed", this, "_open_editor_pressed");
- open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
- */
}
}
@@ -2641,10 +2663,9 @@ void EditorPropertyResource::update_property() {
if (res == RES()) {
assign->set_icon(Ref<Texture>());
assign->set_text(TTR("[empty]"));
- assign->set_tooltip("");
} else {
- assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Node"));
+ assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Object"));
if (res->get_name() != String()) {
assign->set_text(res->get_name());
@@ -2917,7 +2938,7 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
- double default_float_step = EDITOR_GET("interface/inspector/default_float_step");
+ float default_float_step = EDITOR_GET("interface/inspector/default_float_step");
switch (p_type) {