Browse Source

Merge pull request #76684 from KoBeWi/this_branch_is_meta

Add background panel to new meta dialog
Rémi Verschelde 2 năm trước cách đây
mục cha
commit
f868b4781b
2 tập tin đã thay đổi với 23 bổ sung1 xóa
  1. 22 1
      editor/editor_inspector.cpp
  2. 1 0
      editor/editor_inspector.h

+ 22 - 1
editor/editor_inspector.cpp

@@ -3923,6 +3923,12 @@ void EditorInspector::_notification(int p_what) {
 			}
 		} break;
 
+		case NOTIFICATION_THEME_CHANGED: {
+			if (add_meta_error_panel) {
+				add_meta_error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
+			}
+		} break;
+
 		case NOTIFICATION_PREDELETE: {
 			edit(nullptr); //just in case
 		} break;
@@ -4103,13 +4109,16 @@ void EditorInspector::_show_add_meta_dialog() {
 
 		VBoxContainer *vbc = memnew(VBoxContainer);
 		add_meta_dialog->add_child(vbc);
+
 		HBoxContainer *hbc = memnew(HBoxContainer);
 		vbc->add_child(hbc);
 		hbc->add_child(memnew(Label(TTR("Name:"))));
+
 		add_meta_name = memnew(LineEdit);
 		add_meta_name->set_custom_minimum_size(Size2(200 * EDSCALE, 1));
 		hbc->add_child(add_meta_name);
 		hbc->add_child(memnew(Label(TTR("Type:"))));
+
 		add_meta_type = memnew(OptionButton);
 		for (int i = 0; i < Variant::VARIANT_MAX; i++) {
 			if (i == Variant::NIL || i == Variant::RID || i == Variant::CALLABLE || i == Variant::SIGNAL) {
@@ -4120,12 +4129,24 @@ void EditorInspector::_show_add_meta_dialog() {
 			add_meta_type->add_icon_item(get_theme_icon(type, "EditorIcons"), type, i);
 		}
 		hbc->add_child(add_meta_type);
+
+		Control *spacing = memnew(Control);
+		vbc->add_child(spacing);
+		spacing->set_custom_minimum_size(Size2(0, 10 * EDSCALE));
+
 		add_meta_dialog->set_ok_button_text(TTR("Add"));
 		add_child(add_meta_dialog);
 		add_meta_dialog->register_text_enter(add_meta_name);
 		add_meta_dialog->connect("confirmed", callable_mp(this, &EditorInspector::_add_meta_confirm));
+
+		add_meta_error_panel = memnew(PanelContainer);
+		vbc->add_child(add_meta_error_panel);
+		if (is_inside_tree()) {
+			add_meta_error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
+		}
+
 		add_meta_error = memnew(Label);
-		vbc->add_child(add_meta_error);
+		add_meta_error_panel->add_child(add_meta_error);
 
 		add_meta_name->connect("text_changed", callable_mp(this, &EditorInspector::_check_meta_name));
 	}

+ 1 - 0
editor/editor_inspector.h

@@ -540,6 +540,7 @@ class EditorInspector : public ScrollContainer {
 	ConfirmationDialog *add_meta_dialog = nullptr;
 	LineEdit *add_meta_name = nullptr;
 	OptionButton *add_meta_type = nullptr;
+	PanelContainer *add_meta_error_panel = nullptr;
 	Label *add_meta_error = nullptr;
 
 	void _add_meta_confirm();