You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Merge pull request #102193 from MartinDelille/shader-focus
Focus shader text editor when opened with quick open dialog
This commit is contained in:
@@ -147,7 +147,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
||||
if (edited_shaders[i].shader_inc.ptr() == shader_include) {
|
||||
shader_tabs->set_current_tab(i);
|
||||
shader_list->select(i);
|
||||
_switch_to_editor(edited_shaders[i].shader_editor);
|
||||
_switch_to_editor(edited_shaders[i].shader_editor, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
||||
if (edited_shaders[i].shader.ptr() == shader) {
|
||||
shader_tabs->set_current_tab(i);
|
||||
shader_list->select(i);
|
||||
_switch_to_editor(edited_shaders[i].shader_editor);
|
||||
_switch_to_editor(edited_shaders[i].shader_editor, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
||||
shader_tabs->set_current_tab(shader_tabs->get_tab_count() - 1);
|
||||
edited_shaders.push_back(es);
|
||||
_update_shader_list();
|
||||
_switch_to_editor(es.shader_editor);
|
||||
_switch_to_editor(es.shader_editor, !restoring_layout);
|
||||
}
|
||||
|
||||
bool ShaderEditorPlugin::handles(Object *p_object) const {
|
||||
@@ -226,6 +226,8 @@ ShaderEditor *ShaderEditorPlugin::get_shader_editor(const Ref<Shader> &p_for_sha
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
|
||||
restoring_layout = true;
|
||||
|
||||
if (EDITOR_GET("interface/multi_window/restore_windows_on_load") && window_wrapper->is_window_available() && p_layout->has_section_key("ShaderEditor", "window_rect")) {
|
||||
window_wrapper->restore_window_from_saved_position(
|
||||
p_layout->get_value("ShaderEditor", "window_rect", Rect2i()),
|
||||
@@ -268,6 +270,8 @@ void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
|
||||
_shader_selected(selected_shader_idx, false);
|
||||
|
||||
_set_text_shader_zoom_factor(p_layout->get_value("ShaderEditor", "text_shader_zoom_factor", 1.0f));
|
||||
|
||||
restoring_layout = false;
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
|
||||
@@ -783,7 +787,7 @@ void ShaderEditorPlugin::_update_shader_editor_zoom_factor(CodeTextEditor *p_sha
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
|
||||
void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor, bool p_focus) {
|
||||
ERR_FAIL_NULL(p_editor);
|
||||
if (file_menu->get_parent() != nullptr) {
|
||||
file_menu->get_parent()->remove_child(file_menu);
|
||||
@@ -793,6 +797,12 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
|
||||
}
|
||||
empty_menu->set_visible(false);
|
||||
p_editor->use_menu_bar_items(file_menu, make_floating);
|
||||
if (p_focus) {
|
||||
TextShaderEditor *text_shader_editor = Object::cast_to<TextShaderEditor>(p_editor);
|
||||
if (text_shader_editor) {
|
||||
text_shader_editor->get_code_editor()->get_text_editor()->grab_focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_file_removed(const String &p_removed_file) {
|
||||
|
||||
Reference in New Issue
Block a user