summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_themes.cpp4
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/property_editor.cpp24
-rw-r--r--editor/scene_tree_dock.cpp62
-rw-r--r--editor/scene_tree_dock.h8
5 files changed, 95 insertions, 5 deletions
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index bf15f43d32..4e44251f35 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -247,6 +247,10 @@ Ref<Theme> create_editor_theme() {
theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("TreeArrowRight", "EditorIcons"));
theme->set_icon("select_arrow", "Tree", theme->get_icon("Dropdown", "EditorIcons"));
theme->set_stylebox("bg_focus", "Tree", focus_sbt);
+ theme->set_stylebox("custom_button", "Tree", style_button);
+ theme->set_stylebox("custom_button_pressed", "Tree", style_button);
+ theme->set_stylebox("custom_button_hover", "Tree", style_button);
+ theme->set_color("custom_button_font_highlight", "Tree", HIGHLIGHT_COLOR_LIGHT);
Ref<StyleBox> style_tree_btn = make_flat_stylebox(light_color_1, 2, 4, 2, 4);
theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index a4e8ef70ce..4eab20ee7e 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1469,7 +1469,7 @@ ProjectListFilter::ProjectListFilter() {
_current_filter = FILTER_NAME;
filter_option = memnew(OptionButton);
- filter_option->set_custom_minimum_size(Size2(80, 10));
+ filter_option->set_custom_minimum_size(Size2(80 * EDSCALE, 10 * EDSCALE));
filter_option->set_clip_text(true);
filter_option->connect("item_selected", this, "_filter_option_selected");
add_child(filter_option);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 1c8a1c0ee0..b113d1b7ad 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -2310,6 +2310,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) {
p_item->set_text(1, "<null>");
p_item->set_icon(1, Ref<Texture>());
+ p_item->set_custom_as_button(1, false);
Dictionary d = p_item->get_metadata(0);
int hint = d.has("hint") ? d["hint"].operator int() : -1;
@@ -2319,6 +2320,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
}
} else {
+ p_item->set_custom_as_button(1, true);
RES res = obj->get(p_name).operator RefPtr();
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
@@ -3540,17 +3542,21 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
- item->add_button(1, get_icon("EditResource", "EditorIcons"));
+ //item->add_button(1, get_icon("EditResource", "EditorIcons"));
String type;
if (p.hint == PROPERTY_HINT_RESOURCE_TYPE)
type = p.hint_string;
- if (obj->get(p.name).get_type() == Variant::NIL || obj->get(p.name).operator RefPtr().is_null()) {
+ RES res = obj->get(p.name).operator RefPtr();
+
+ if (obj->get(p.name).get_type() == Variant::NIL || res.is_null()) {
item->set_text(1, "<null>");
item->set_icon(1, Ref<Texture>());
+ item->set_custom_as_button(1, false);
- } else {
- RES res = obj->get(p.name).operator RefPtr();
+ } else if (res.is_valid()) {
+
+ item->set_custom_as_button(1, true);
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
@@ -3854,6 +3860,16 @@ void PropertyEditor::_item_edited() {
_edit_set(name, NodePath(item->get_text(1)), refresh_all);
} break;
+ case Variant::OBJECT: {
+ if (!item->is_custom_set_as_button(1))
+ break;
+
+ RES res = obj->get(name);
+ if (res.is_valid()) {
+ emit_signal("resource_selected", res.get_ref_ptr(), name);
+ }
+
+ } break;
case Variant::DICTIONARY: {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 0f05cc79ff..da2d22b900 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -658,6 +658,21 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
}
} break;
+
+ default: {
+
+ if (p_tool >= EDIT_SUBRESOURCE_BASE) {
+
+ int idx = p_tool - EDIT_SUBRESOURCE_BASE;
+
+ ERR_FAIL_INDEX(idx, subresources.size());
+
+ Object *obj = ObjectDB::get_instance(subresources[idx]);
+ ERR_FAIL_COND(!obj);
+
+ editor->push_item(obj);
+ }
+ }
}
}
@@ -1662,6 +1677,47 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) {
_do_reparent(to_node, to_pos, nodes, true);
}
+void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
+
+ if (p_depth > 8)
+ return;
+
+ List<PropertyInfo> pinfo;
+ p_obj->get_property_list(&pinfo);
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ continue;
+ if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE)
+ continue;
+
+ Variant value = p_obj->get(E->get().name);
+ if (value.get_type() != Variant::OBJECT)
+ continue;
+ Object *obj = value;
+ if (!obj)
+ continue;
+
+ Ref<Texture> icon;
+
+ if (has_icon(obj->get_class(), "EditorIcons"))
+ icon = get_icon(obj->get_class(), "EditorIcons");
+ else
+ icon = get_icon("Object", "EditorIcons");
+
+ if (menu->get_item_count() == 0) {
+ menu->add_item(TTR("Sub-Resources:"));
+ menu->set_item_disabled(0, true);
+ }
+ int index = menu->get_item_count();
+ menu->add_icon_item(icon, E->get().name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size());
+ menu->set_item_h_offset(index, p_depth * 10 * EDSCALE);
+ subresources.push_back(obj->get_instance_ID());
+
+ _add_children_to_popup(obj, p_depth + 1);
+ }
+}
+
void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (!EditorNode::get_singleton()->get_edited_scene()) {
@@ -1683,6 +1739,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->clear();
if (selection.size() == 1) {
+
+ subresources.clear();
+ _add_children_to_popup(selection.front()->get(), 0);
+ if (menu->get_item_count() > 0)
+ menu->add_separator();
+
menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
menu->add_separator();
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index f190025dd6..79e01e7571 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -73,6 +73,12 @@ class SceneTreeDock : public VBoxContainer {
TOOL_BUTTON_MAX
};
+ enum {
+ EDIT_SUBRESOURCE_BASE = 100
+ };
+
+ Vector<ObjectID> subresources;
+
bool restore_script_editor_on_drag;
int current_option;
@@ -114,6 +120,8 @@ class SceneTreeDock : public VBoxContainer {
Node *edited_scene;
EditorNode *editor;
+ void _add_children_to_popup(Object *p_obj, int p_depth);
+
Node *_duplicate(Node *p_node, Map<Node *, Node *> &duplimap);
void _node_reparent(NodePath p_path, bool p_keep_global_xform);
void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform);