Merge pull request #72559 from Maran23/4-x-improve-layout-dialog
Improve editor layout dialog
This commit is contained in:
commit
2e506516ee
2 changed files with 23 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -44,6 +44,8 @@ class EditorLayoutsDialog : public ConfirmationDialog {
|
|||
VBoxContainer *makevb = nullptr;
|
||||
|
||||
void _line_gui_input(const Ref<InputEvent> &p_event);
|
||||
void _update_ok_disable_state();
|
||||
void _deselect_layout_names();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
Loading…
Reference in a new issue