diff options
Diffstat (limited to 'editor/editor_layouts_dialog.cpp')
-rw-r--r-- | editor/editor_layouts_dialog.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 3f788627f4..57a0a88810 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -65,6 +65,20 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { } } +void EditorLayoutsDialog::_update_ok_disable_state() { + if (layout_names->is_anything_selected()) { + get_ok_button()->set_disabled(false); + } else { + get_ok_button()->set_disabled(!name->is_visible() || name->get_text().is_empty()); + } +} + +void EditorLayoutsDialog::_deselect_layout_names() { + // The deselect method does not emit any signal, therefore we need update the disable state as well. + layout_names->deselect_all(); + _update_ok_disable_state(); +} + void EditorLayoutsDialog::_bind_methods() { ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name"))); } @@ -82,8 +96,8 @@ void EditorLayoutsDialog::ok_pressed() { void EditorLayoutsDialog::_post_popup() { ConfirmationDialog::_post_popup(); - name->clear(); layout_names->clear(); + name->clear(); Ref<ConfigFile> config; config.instantiate(); @@ -112,9 +126,9 @@ EditorLayoutsDialog::EditorLayoutsDialog() { makevb->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5); layout_names = memnew(ItemList); - layout_names->set_auto_height(true); makevb->add_margin_child(TTR("Select existing layout:"), layout_names); - layout_names->set_custom_minimum_size(Size2(300 * EDSCALE, 1)); + layout_names->set_auto_height(true); + layout_names->set_custom_minimum_size(Size2(300 * EDSCALE, 50 * EDSCALE)); layout_names->set_visible(true); layout_names->set_offset(SIDE_TOP, 5); layout_names->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5); @@ -122,16 +136,17 @@ EditorLayoutsDialog::EditorLayoutsDialog() { layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL); layout_names->set_select_mode(ItemList::SELECT_MULTI); layout_names->set_allow_rmb_select(true); + layout_names->connect("multi_selected", callable_mp(this, &EditorLayoutsDialog::_update_ok_disable_state).unbind(2)); name = memnew(LineEdit); - name->set_placeholder("Or enter new layout name"); makevb->add_child(name); + name->set_placeholder("Or enter new layout name"); name->set_offset(SIDE_TOP, 5); - name->set_custom_minimum_size(Size2(300 * EDSCALE, 1)); name->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5); name->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5); name->connect("gui_input", callable_mp(this, &EditorLayoutsDialog::_line_gui_input)); - name->connect("focus_entered", callable_mp(layout_names, &ItemList::deselect_all)); + name->connect("focus_entered", callable_mp(this, &EditorLayoutsDialog::_deselect_layout_names)); + name->connect("text_changed", callable_mp(this, &EditorLayoutsDialog::_update_ok_disable_state).unbind(1)); } void EditorLayoutsDialog::set_name_line_enabled(bool p_enabled) { |