|
58 | 58 | #include "editor/gui/window_wrapper.h" |
59 | 59 | #include "editor/inspector/editor_context_menu_plugin.h" |
60 | 60 | #include "editor/run/editor_run_bar.h" |
| 61 | +#include "editor/scene/editor_scene_tabs.h" |
61 | 62 | #include "editor/script/editor_script.h" |
62 | 63 | #include "editor/script/find_in_files.h" |
63 | 64 | #include "editor/settings/editor_command_palette.h" |
@@ -1864,8 +1865,54 @@ void ScriptEditor::_notification(int p_what) { |
1864 | 1865 |
|
1865 | 1866 | EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed)); |
1866 | 1867 | EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed)); |
| 1868 | +#ifdef ANDROID_ENABLED |
| 1869 | + set_process(true); |
| 1870 | +#endif |
1867 | 1871 | } break; |
1868 | 1872 |
|
| 1873 | +#ifdef ANDROID_ENABLED |
| 1874 | + case NOTIFICATION_VISIBILITY_CHANGED: { |
| 1875 | + set_process(is_visible_in_tree()); |
| 1876 | + } break; |
| 1877 | + |
| 1878 | + case NOTIFICATION_PROCESS: { |
| 1879 | + const int kb_height = DisplayServer::get_singleton()->virtual_keyboard_get_height(); |
| 1880 | + if (kb_height == last_kb_height) { |
| 1881 | + break; |
| 1882 | + } |
| 1883 | + |
| 1884 | + last_kb_height = kb_height; |
| 1885 | + float spacer_height = 0.0f; |
| 1886 | + const float status_bar_height = 28 * EDSCALE; // Magic number |
| 1887 | + const bool kb_visible = kb_height > 0; |
| 1888 | + |
| 1889 | + if (kb_visible) { |
| 1890 | + if (ScriptEditorBase *editor = _get_current_editor()) { |
| 1891 | + if (CodeTextEditor *code_editor = editor->get_code_editor()) { |
| 1892 | + if (CodeEdit *text_editor = code_editor->get_text_editor()) { |
| 1893 | + if (!text_editor->has_focus()) { |
| 1894 | + break; |
| 1895 | + } |
| 1896 | + text_editor->adjust_viewport_to_caret(); |
| 1897 | + } |
| 1898 | + } |
| 1899 | + } |
| 1900 | + |
| 1901 | + const float control_bottom = get_global_position().y + get_size().y; |
| 1902 | + const float extra_bottom = get_viewport_rect().size.y - control_bottom; |
| 1903 | + spacer_height = float(kb_height) - extra_bottom - status_bar_height; |
| 1904 | + |
| 1905 | + if (spacer_height < 0.0f) { |
| 1906 | + spacer_height = 0.0f; |
| 1907 | + } |
| 1908 | + } |
| 1909 | + |
| 1910 | + virtual_keyboard_spacer->set_custom_minimum_size(Size2(0, spacer_height)); |
| 1911 | + EditorSceneTabs::get_singleton()->set_visible(!kb_height); |
| 1912 | + menu_hb->set_visible(!kb_visible); |
| 1913 | + } break; |
| 1914 | +#endif |
| 1915 | + |
1869 | 1916 | case NOTIFICATION_EXIT_TREE: { |
1870 | 1917 | EditorRunBar::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); |
1871 | 1918 | } break; |
@@ -4187,6 +4234,12 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { |
4187 | 4234 | main_container->add_child(script_split); |
4188 | 4235 | script_split->set_v_size_flags(SIZE_EXPAND_FILL); |
4189 | 4236 |
|
| 4237 | +#ifdef ANDROID_ENABLED |
| 4238 | + virtual_keyboard_spacer = memnew(Control); |
| 4239 | + virtual_keyboard_spacer->set_h_size_flags(SIZE_EXPAND_FILL); |
| 4240 | + main_container->add_child(virtual_keyboard_spacer); |
| 4241 | +#endif |
| 4242 | + |
4190 | 4243 | list_split = memnew(VSplitContainer); |
4191 | 4244 | script_split->add_child(list_split); |
4192 | 4245 | list_split->set_v_size_flags(SIZE_EXPAND_FILL); |
|
0 commit comments