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.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 9ff34f8fb4..cf478f20e5 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -35,7 +35,7 @@
#include "editor_node.h"
#include "editor_properties_array_dict.h"
#include "editor_scale.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
///////////////////// NULL /////////////////////////
@@ -140,9 +140,9 @@ void EditorPropertyMultilineText::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons");
+ Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons");
open_big_text->set_icon(df);
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
text->set_custom_minimum_size(Vector2(0, font->get_height() * 6));
} break;
@@ -165,8 +165,8 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() {
open_big_text = memnew(ToolButton);
open_big_text->connect("pressed", callable_mp(this, &EditorPropertyMultilineText::_open_big_text));
hb->add_child(open_big_text);
- big_text_dialog = NULL;
- big_text = NULL;
+ big_text_dialog = nullptr;
+ big_text = nullptr;
}
///////////////////// TEXT ENUM /////////////////////////
@@ -240,10 +240,10 @@ void EditorPropertyPath::_path_pressed() {
}
if (folder) {
- dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
dialog->set_current_dir(full_path);
} else {
- dialog->set_mode(save_mode ? EditorFileDialog::MODE_SAVE_FILE : EditorFileDialog::MODE_OPEN_FILE);
+ dialog->set_file_mode(save_mode ? EditorFileDialog::FILE_MODE_SAVE_FILE : EditorFileDialog::FILE_MODE_OPEN_FILE);
for (int i = 0; i < extensions.size(); i++) {
String e = extensions[i].strip_edges();
if (e != String()) {
@@ -278,7 +278,7 @@ void EditorPropertyPath::set_save_mode() {
void EditorPropertyPath::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- path_edit->set_icon(get_icon("Folder", "EditorIcons"));
+ path_edit->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
}
@@ -303,7 +303,7 @@ EditorPropertyPath::EditorPropertyPath() {
path_edit->set_clip_text(true);
path_hb->add_child(path_edit);
add_focusable(path);
- dialog = NULL;
+ dialog = nullptr;
path_edit->connect("pressed", callable_mp(this, &EditorPropertyPath::_path_pressed));
folder = false;
global = false;
@@ -448,7 +448,7 @@ void EditorPropertyMember::_bind_methods() {
}
EditorPropertyMember::EditorPropertyMember() {
- selector = NULL;
+ selector = nullptr;
property = memnew(Button);
property->set_clip_text(true);
add_child(property);
@@ -604,7 +604,7 @@ public:
Vector<String> tooltips;
virtual Size2 get_minimum_size() const {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return Vector2(0, font->get_height() * 2);
}
@@ -646,7 +646,7 @@ public:
int h = bsize * 2 + 1;
int vofs = (rect.size.height - h) / 2;
- Color color = get_color("highlight_color", "Editor");
+ Color color = get_theme_color("highlight_color", "Editor");
for (int i = 0; i < 2; i++) {
Point2 ofs(4, vofs);
@@ -749,10 +749,10 @@ void EditorPropertyLayers::_button_pressed() {
layers->set_item_checked(idx, grid->value & (1 << i));
}
- Rect2 gp = button->get_global_rect();
+ Rect2 gp = button->get_screen_rect();
layers->set_as_minsize();
- Vector2 popup_pos = gp.position - Vector2(layers->get_combined_minimum_size().x, 0);
- layers->set_global_position(popup_pos);
+ Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0);
+ layers->set_position(popup_pos);
layers->popup();
}
@@ -920,7 +920,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
}
if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
- preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
+ preset->set_position(easing_draw->get_screen_transform().xform(mb->get_position()));
preset->popup();
// Ensure the easing doesn't appear as being dragged
@@ -976,13 +976,13 @@ void EditorPropertyEasing::_draw_easing() {
float prev = 1.0;
const float exp = get_edited_object()->get(get_edited_property());
- const Ref<Font> f = get_font("font", "Label");
- const Color font_color = get_color("font_color", "Label");
+ const Ref<Font> f = get_theme_font("font", "Label");
+ const Color font_color = get_theme_color("font_color", "Label");
Color line_color;
if (dragging) {
- line_color = get_color("accent_color", "Editor");
+ line_color = get_theme_color("accent_color", "Editor");
} else {
- line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9);
+ line_color = get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.9);
}
Vector<Point2> lines;
@@ -1058,15 +1058,15 @@ void EditorPropertyEasing::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
preset->clear();
- preset->add_icon_item(get_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO);
- preset->add_icon_item(get_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR);
- preset->add_icon_item(get_icon("CurveIn", "EditorIcons"), "In", EASING_IN);
- preset->add_icon_item(get_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT);
+ preset->add_icon_item(get_theme_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO);
+ preset->add_icon_item(get_theme_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR);
+ preset->add_icon_item(get_theme_icon("CurveIn", "EditorIcons"), "In", EASING_IN);
+ preset->add_icon_item(get_theme_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT);
if (full) {
- preset->add_icon_item(get_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT);
- preset->add_icon_item(get_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN);
+ preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT);
+ preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN);
}
- easing_draw->set_custom_minimum_size(Size2(0, get_font("font", "Label")->get_height() * 2));
+ easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height() * 2));
} break;
}
}
@@ -1126,7 +1126,7 @@ void EditorPropertyVector2::update_property() {
void EditorPropertyVector2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 2; i++) {
Color c = base;
@@ -1208,7 +1208,7 @@ void EditorPropertyRect2::update_property() {
}
void EditorPropertyRect2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 4; i++) {
Color c = base;
@@ -1288,7 +1288,7 @@ void EditorPropertyVector3::update_property() {
}
void EditorPropertyVector3::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1368,7 +1368,7 @@ void EditorPropertyPlane::update_property() {
}
void EditorPropertyPlane::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1450,7 +1450,7 @@ void EditorPropertyQuat::update_property() {
}
void EditorPropertyQuat::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1537,7 +1537,7 @@ void EditorPropertyAABB::update_property() {
}
void EditorPropertyAABB::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
Color c = base;
@@ -1611,7 +1611,7 @@ void EditorPropertyTransform2D::update_property() {
}
void EditorPropertyTransform2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
Color c = base;
@@ -1690,7 +1690,7 @@ void EditorPropertyBasis::update_property() {
}
void EditorPropertyBasis::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 9; i++) {
Color c = base;
@@ -1775,7 +1775,7 @@ void EditorPropertyTransform::update_property() {
}
void EditorPropertyTransform::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 12; i++) {
Color c = base;
@@ -1882,7 +1882,7 @@ EditorPropertyColor::EditorPropertyColor() {
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
NodePath path = p_path;
- Node *base_node = NULL;
+ Node *base_node = nullptr;
if (!use_path_from_scene_root) {
base_node = Object::cast_to<Node>(get_edited_object());
@@ -1945,7 +1945,7 @@ void EditorPropertyNodePath::update_property() {
}
assign->set_flat(true);
- Node *base_node = NULL;
+ Node *base_node = nullptr;
if (base_hint != NodePath()) {
if (get_tree()->get_root()->has_node(base_hint)) {
base_node = get_tree()->get_root()->get_node(base_hint);
@@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam
void EditorPropertyNodePath::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
+ Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}
@@ -2008,7 +2008,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
hbc->add_child(clear);
use_path_from_scene_root = false;
- scene_tree = NULL; //do not allocate unnecessarily
+ scene_tree = nullptr; //do not allocate unnecessarily
}
///////////////////// RID /////////////////////////
@@ -2074,7 +2074,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
file->connect("file_selected", callable_mp(this, &EditorPropertyResource::_file_selected));
add_child(file);
}
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
String type = base_type;
List<String> extensions;
@@ -2121,7 +2121,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
- List<Pair<String, Variant> > propvalues;
+ List<Pair<String, Variant>> propvalues;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
@@ -2144,7 +2144,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
ERR_FAIL_COND(res.is_null());
- for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) {
+ for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) {
Pair<String, Variant> &p = E->get();
res->set(p.first, p.second);
@@ -2196,7 +2196,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
file_system_dock->navigate_to_path(res->get_path());
// Ensure that the FileSystem dock is visible.
TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
- tab_container->set_current_tab(file_system_dock->get_position_in_parent());
+ tab_container->set_current_tab(file_system_dock->get_index());
} break;
default: {
@@ -2206,7 +2206,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
int to_type = p_which - CONVERT_BASE_ID;
- Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
+ Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
ERR_FAIL_INDEX(to_type, conversions.size());
@@ -2248,7 +2248,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
return;
}
- Object *obj = NULL;
+ Object *obj = nullptr;
if (ScriptServer::is_global_class(intype)) {
obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype));
@@ -2294,7 +2294,7 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T
}
if (p_preview.is_valid()) {
- preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button"));
+ preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_theme_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_theme_constant("hseparation", "Button"));
if (type == "GradientTexture") {
preview->set_stretch_mode(TextureRect::STRETCH_SCALE);
assign->set_custom_minimum_size(Size2(1, 1));
@@ -2318,8 +2318,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("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_icon_item(get_theme_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_theme_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
menu->add_separator();
} else if (base_type != "") {
int idx = 0;
@@ -2381,7 +2381,7 @@ void EditorPropertyResource::_update_menu_items() {
inheritors_array.push_back(t);
if (!icon.is_valid())
- icon = get_icon(has_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
+ icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
int id = TYPE_BASE_ID + idx;
menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
@@ -2394,14 +2394,14 @@ void EditorPropertyResource::_update_menu_items() {
menu->add_separator();
}
- menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
+ menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
if (!res.is_null()) {
- menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
- menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
- menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
- menu->add_icon_item(get_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE);
+ menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
+ menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
+ menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
+ menu->add_icon_item(get_theme_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE);
RES r = res;
if (r.is_valid() && r->get_path().is_resource_file()) {
menu->add_separator();
@@ -2438,19 +2438,19 @@ void EditorPropertyResource::_update_menu_items() {
if (!res.is_null()) {
- Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
+ Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
if (conversions.size()) {
menu->add_separator();
}
for (int i = 0; i < conversions.size(); i++) {
String what = conversions[i]->converts_to();
Ref<Texture2D> icon;
- if (has_icon(what, "EditorIcons")) {
+ if (has_theme_icon(what, "EditorIcons")) {
- icon = get_icon(what, "EditorIcons");
+ icon = get_theme_icon(what, "EditorIcons");
} else {
- icon = get_icon(what, "Resource");
+ icon = get_theme_icon(what, "Resource");
}
menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
@@ -2462,11 +2462,11 @@ void EditorPropertyResource::_update_menu() {
_update_menu_items();
- Rect2 gt = edit->get_global_rect();
+ Rect2 gt = edit->get_screen_rect();
menu->set_as_minsize();
- int ms = menu->get_combined_minimum_size().width;
+ int ms = menu->get_contents_minimum_size().width;
Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0);
- menu->set_global_position(popup_pos);
+ menu->set_position(popup_pos);
menu->popup();
}
@@ -2490,10 +2490,10 @@ void EditorPropertyResource::_button_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid()) {
if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
_update_menu_items();
- Vector2 pos = mb->get_global_position();
+ Vector2 pos = get_screen_position() + mb->get_position();
//pos = assign->get_global_transform().xform(pos);
menu->set_as_minsize();
- menu->set_global_position(pos);
+ menu->set_position(pos);
menu->popup();
}
}
@@ -2598,10 +2598,10 @@ void EditorPropertyResource::update_property() {
sub_inspector->refresh();
} else {
if (sub_inspector) {
- set_bottom_editor(NULL);
+ set_bottom_editor(nullptr);
memdelete(sub_inspector_vbox);
- sub_inspector = NULL;
- sub_inspector_vbox = NULL;
+ sub_inspector = nullptr;
+ sub_inspector_vbox = nullptr;
if (opened_editor) {
EditorNode::get_singleton()->hide_top_editors();
opened_editor = false;
@@ -2663,7 +2663,7 @@ void EditorPropertyResource::setup(const String &p_base_type) {
void EditorPropertyResource::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_icon("select_arrow", "Tree");
+ Ref<Texture2D> t = get_theme_icon("select_arrow", "Tree");
edit->set_icon(t);
}
@@ -2718,7 +2718,7 @@ void EditorPropertyResource::expand_all_folding() {
void EditorPropertyResource::_button_draw() {
if (dropping) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false);
}
}
@@ -2823,8 +2823,8 @@ void EditorPropertyResource::_bind_methods() {
EditorPropertyResource::EditorPropertyResource() {
opened_editor = false;
- sub_inspector = NULL;
- sub_inspector_vbox = NULL;
+ sub_inspector = nullptr;
+ sub_inspector_vbox = nullptr;
use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector"));
HBoxContainer *hbc = memnew(HBoxContainer);
@@ -2860,8 +2860,8 @@ EditorPropertyResource::EditorPropertyResource() {
edit->connect("gui_input", callable_mp(this, &EditorPropertyResource::_button_input));
add_focusable(edit);
- file = NULL;
- scene_tree = NULL;
+ file = nullptr;
+ scene_tree = nullptr;
dropping = false;
add_to_group("_editor_resource_properties");