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.cpp110
1 files changed, 71 insertions, 39 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 30fb561fbe..e14beabfa2 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -922,16 +922,29 @@ EditorPropertyFloat::EditorPropertyFloat() {
void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
- Ref<InputEventMouseButton> mb = p_ev;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
- preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
- preset->popup();
- }
- if (mb.is_valid() && mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
- _setup_spin();
+ const Ref<InputEventMouseButton> mb = p_ev;
+ if (mb.is_valid()) {
+ if (mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
+ _setup_spin();
+ }
+
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
+ preset->popup();
+
+ // Ensure the easing doesn't appear as being dragged
+ dragging = false;
+ easing_draw->update();
+ }
+
+ if (mb->get_button_index() == BUTTON_LEFT) {
+ dragging = mb->is_pressed();
+ // Update to display the correct dragging color
+ easing_draw->update();
+ }
}
- Ref<InputEventMouseMotion> mm = p_ev;
+ const Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
@@ -969,13 +982,19 @@ void EditorPropertyEasing::_draw_easing() {
Rect2 r(Point2(), s);
r = r.grow(3);
- int points = 48;
+ const int points = 48;
float prev = 1.0;
- float exp = get_edited_object()->get(get_edited_property());
+ const float exp = get_edited_object()->get(get_edited_property());
- Ref<Font> f = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ const Ref<Font> f = get_font("font", "Label");
+ const Color font_color = get_color("font_color", "Label");
+ Color line_color;
+ if (dragging) {
+ line_color = get_color("accent_color", "Editor");
+ } else {
+ line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9);
+ }
Vector<Point2> lines;
for (int i = 1; i <= points; i++) {
@@ -983,7 +1002,7 @@ void EditorPropertyEasing::_draw_easing() {
float ifl = i / float(points);
float iflp = (i - 1) / float(points);
- float h = 1.0 - Math::ease(ifl, exp);
+ const float h = 1.0 - Math::ease(ifl, exp);
if (flip) {
ifl = 1.0 - ifl;
@@ -995,8 +1014,8 @@ void EditorPropertyEasing::_draw_easing() {
prev = h;
}
- easing_draw->draw_multiline(lines, color, 1.0, true);
- f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), color);
+ easing_draw->draw_multiline(lines, line_color, 1.0, true);
+ f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), font_color);
}
void EditorPropertyEasing::update_property() {
@@ -1033,6 +1052,9 @@ void EditorPropertyEasing::_spin_value_changed(double p_value) {
void EditorPropertyEasing::_spin_focus_exited() {
spin->hide();
+ // Ensure the easing doesn't appear as being dragged
+ dragging = false;
+ easing_draw->update();
}
void EditorPropertyEasing::setup(bool p_full, bool p_flip) {
@@ -1095,6 +1117,7 @@ EditorPropertyEasing::EditorPropertyEasing() {
spin->hide();
add_child(spin);
+ dragging = false;
flip = false;
full = false;
}
@@ -1861,6 +1884,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) {
@@ -2038,7 +2078,7 @@ void EditorPropertyResource::_file_selected(const String &p_path) {
RES res = ResourceLoader::load(p_path);
- ERR_FAIL_COND(res.is_null());
+ ERR_FAIL_COND_MSG(res.is_null(), "Cannot load resource from path '" + p_path + "'.");
List<PropertyInfo> prop_list;
get_edited_object()->get_property_list(&prop_list);
@@ -2182,7 +2222,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;
@@ -2315,7 +2362,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;
@@ -2376,19 +2424,11 @@ void EditorPropertyResource::_update_menu_items() {
inheritors_array.push_back(t);
- int id = TYPE_BASE_ID + idx;
+ if (!icon.is_valid())
+ icon = get_icon(has_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
- if (!icon.is_valid() && has_icon(t, "EditorIcons")) {
- icon = get_icon(t, "EditorIcons");
- }
-
- if (icon.is_valid()) {
-
- menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
- } else {
-
- menu->add_item(vformat(TTR("New %s"), t), id);
- }
+ int id = TYPE_BASE_ID + idx;
+ menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
idx++;
}
@@ -2592,14 +2632,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);
- */
}
}
@@ -2628,7 +2660,7 @@ void EditorPropertyResource::update_property() {
assign->set_text(TTR("[empty]"));
} 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());