Merge pull request #16455 from volzhs/close-docs
Keep to show current script when closing all docs
This commit is contained in:
commit
55f00d9655
4 changed files with 20 additions and 13 deletions
|
@ -505,7 +505,7 @@ void ScriptEditor::_show_error_dialog(String p_path) {
|
|||
error_dialog->popup_centered_minsize();
|
||||
}
|
||||
|
||||
void ScriptEditor::_close_tab(int p_idx, bool p_save) {
|
||||
void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
|
||||
|
||||
int selected = p_idx;
|
||||
if (selected < 0 || selected >= tab_container->get_child_count())
|
||||
|
@ -521,7 +521,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
|
|||
}
|
||||
|
||||
// roll back to previous tab
|
||||
_history_back();
|
||||
if (p_history_back) {
|
||||
_history_back();
|
||||
}
|
||||
|
||||
//remove from history
|
||||
history.resize(history_pos + 1);
|
||||
|
@ -579,7 +581,7 @@ void ScriptEditor::_close_docs_tab() {
|
|||
EditorHelp *se = Object::cast_to<EditorHelp>(tab_container->get_child(i));
|
||||
|
||||
if (se) {
|
||||
_close_tab(i);
|
||||
_close_tab(i, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ class ScriptEditor : public PanelContainer {
|
|||
|
||||
void _show_error_dialog(String p_path);
|
||||
|
||||
void _close_tab(int p_idx, bool p_save = true);
|
||||
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
|
||||
|
||||
void _close_current_tab();
|
||||
void _close_discard_current_tab(const String &p_str);
|
||||
|
|
|
@ -474,21 +474,24 @@ void TabContainer::remove_child_notify(Node *p_child) {
|
|||
|
||||
Control::remove_child_notify(p_child);
|
||||
|
||||
int tc = get_tab_count();
|
||||
if (current == tc - 1) {
|
||||
current--;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
else {
|
||||
call_deferred("set_current_tab", current);
|
||||
}
|
||||
}
|
||||
call_deferred("_update_current_tab");
|
||||
|
||||
p_child->disconnect("renamed", this, "_child_renamed_callback");
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void TabContainer::_update_current_tab() {
|
||||
|
||||
int tc = get_tab_count();
|
||||
if (current >= tc)
|
||||
current = tc - 1;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
else
|
||||
set_current_tab(current);
|
||||
}
|
||||
|
||||
void TabContainer::set_tab_align(TabAlign p_align) {
|
||||
|
||||
ERR_FAIL_INDEX(p_align, 3);
|
||||
|
@ -664,6 +667,7 @@ void TabContainer::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
|
||||
ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed);
|
||||
ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
|
||||
ADD_SIGNAL(MethodInfo("tab_selected", PropertyInfo(Variant::INT, "tab")));
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
Vector<Control *> _get_tabs() const;
|
||||
int _get_tab_width(int p_index) const;
|
||||
void _on_theme_changed();
|
||||
void _update_current_tab();
|
||||
|
||||
protected:
|
||||
void _child_renamed_callback();
|
||||
|
|
Loading…
Reference in a new issue