You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Focus shader text editor when opened with quick open dialog
This commit is contained in:
@@ -146,7 +146,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
if (edited_shaders[i].shader_inc.ptr() == shader_include) {
|
if (edited_shaders[i].shader_inc.ptr() == shader_include) {
|
||||||
shader_tabs->set_current_tab(i);
|
shader_tabs->set_current_tab(i);
|
||||||
shader_list->select(i);
|
shader_list->select(i);
|
||||||
_switch_to_editor(edited_shaders[i].shader_editor);
|
_switch_to_editor(edited_shaders[i].shader_editor, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
if (edited_shaders[i].shader.ptr() == shader) {
|
if (edited_shaders[i].shader.ptr() == shader) {
|
||||||
shader_tabs->set_current_tab(i);
|
shader_tabs->set_current_tab(i);
|
||||||
shader_list->select(i);
|
shader_list->select(i);
|
||||||
_switch_to_editor(edited_shaders[i].shader_editor);
|
_switch_to_editor(edited_shaders[i].shader_editor, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
shader_tabs->set_current_tab(shader_tabs->get_tab_count() - 1);
|
shader_tabs->set_current_tab(shader_tabs->get_tab_count() - 1);
|
||||||
edited_shaders.push_back(es);
|
edited_shaders.push_back(es);
|
||||||
_update_shader_list();
|
_update_shader_list();
|
||||||
_switch_to_editor(es.shader_editor);
|
_switch_to_editor(es.shader_editor, !restoring_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderEditorPlugin::handles(Object *p_object) const {
|
bool ShaderEditorPlugin::handles(Object *p_object) const {
|
||||||
@@ -221,6 +221,8 @@ ShaderEditor *ShaderEditorPlugin::get_shader_editor(const Ref<Shader> &p_for_sha
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
|
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")) {
|
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(
|
window_wrapper->restore_window_from_saved_position(
|
||||||
p_layout->get_value("ShaderEditor", "window_rect", Rect2i()),
|
p_layout->get_value("ShaderEditor", "window_rect", Rect2i()),
|
||||||
@@ -263,6 +265,8 @@ void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
|
|||||||
_shader_selected(selected_shader_idx, false);
|
_shader_selected(selected_shader_idx, false);
|
||||||
|
|
||||||
_set_text_shader_zoom_factor(p_layout->get_value("ShaderEditor", "text_shader_zoom_factor", 1.0f));
|
_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) {
|
void ShaderEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
|
||||||
@@ -778,7 +782,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);
|
ERR_FAIL_NULL(p_editor);
|
||||||
if (file_menu->get_parent() != nullptr) {
|
if (file_menu->get_parent() != nullptr) {
|
||||||
file_menu->get_parent()->remove_child(file_menu);
|
file_menu->get_parent()->remove_child(file_menu);
|
||||||
@@ -788,6 +792,12 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
|
|||||||
}
|
}
|
||||||
empty_menu->set_visible(false);
|
empty_menu->set_visible(false);
|
||||||
p_editor->use_menu_bar_items(file_menu, make_floating);
|
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) {
|
void ShaderEditorPlugin::_file_removed(const String &p_removed_file) {
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ class ShaderEditorPlugin : public EditorPlugin {
|
|||||||
ShaderCreateDialog *shader_create_dialog = nullptr;
|
ShaderCreateDialog *shader_create_dialog = nullptr;
|
||||||
|
|
||||||
float text_shader_zoom_factor = 1.0f;
|
float text_shader_zoom_factor = 1.0f;
|
||||||
|
bool restoring_layout = false;
|
||||||
|
|
||||||
Ref<Resource> _get_current_shader();
|
Ref<Resource> _get_current_shader();
|
||||||
void _update_shader_list();
|
void _update_shader_list();
|
||||||
@@ -127,7 +128,7 @@ class ShaderEditorPlugin : public EditorPlugin {
|
|||||||
void _set_text_shader_zoom_factor(float p_zoom_factor);
|
void _set_text_shader_zoom_factor(float p_zoom_factor);
|
||||||
void _update_shader_editor_zoom_factor(CodeTextEditor *p_shader_editor) const;
|
void _update_shader_editor_zoom_factor(CodeTextEditor *p_shader_editor) const;
|
||||||
|
|
||||||
void _switch_to_editor(ShaderEditor *p_editor);
|
void _switch_to_editor(ShaderEditor *p_editor, bool p_focus = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|||||||
Reference in New Issue
Block a user