You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Android Editor: Adjust script editor size for virtual keyboard
This commit is contained in:
@@ -1864,8 +1864,51 @@ void ScriptEditor::_notification(int p_what) {
|
|||||||
|
|
||||||
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed));
|
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed));
|
||||||
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed));
|
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed));
|
||||||
|
#ifdef ANDROID_ENABLED
|
||||||
|
set_process(true);
|
||||||
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
#ifdef ANDROID_ENABLED
|
||||||
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
set_process(is_visible_in_tree());
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_PROCESS: {
|
||||||
|
const int kb_height = DisplayServer::get_singleton()->virtual_keyboard_get_height();
|
||||||
|
if (kb_height == last_kb_height) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_kb_height = kb_height;
|
||||||
|
float spacer_height = 0.0f;
|
||||||
|
const float status_bar_height = 28 * EDSCALE; // Magic number
|
||||||
|
|
||||||
|
if (kb_height > 0) {
|
||||||
|
if (ScriptEditorBase *editor = _get_current_editor()) {
|
||||||
|
if (CodeTextEditor *code_editor = editor->get_code_editor()) {
|
||||||
|
if (CodeEdit *text_editor = code_editor->get_text_editor()) {
|
||||||
|
if (!text_editor->has_focus()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
text_editor->adjust_viewport_to_caret();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const float control_bottom = get_global_position().y + get_size().y;
|
||||||
|
const float extra_bottom = get_viewport_rect().size.y - control_bottom;
|
||||||
|
spacer_height = float(kb_height) - extra_bottom - status_bar_height;
|
||||||
|
|
||||||
|
if (spacer_height < 0.0f) {
|
||||||
|
spacer_height = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual_keyboard_spacer->set_custom_minimum_size(Size2(0, spacer_height));
|
||||||
|
} break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
EditorRunBar::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
|
EditorRunBar::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
|
||||||
} break;
|
} break;
|
||||||
@@ -4187,6 +4230,12 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||||||
main_container->add_child(script_split);
|
main_container->add_child(script_split);
|
||||||
script_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
script_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
|
#ifdef ANDROID_ENABLED
|
||||||
|
virtual_keyboard_spacer = memnew(Control);
|
||||||
|
virtual_keyboard_spacer->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
main_container->add_child(virtual_keyboard_spacer);
|
||||||
|
#endif
|
||||||
|
|
||||||
list_split = memnew(VSplitContainer);
|
list_split = memnew(VSplitContainer);
|
||||||
script_split->add_child(list_split);
|
script_split->add_child(list_split);
|
||||||
list_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
list_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|||||||
@@ -372,6 +372,11 @@ class ScriptEditor : public PanelContainer {
|
|||||||
|
|
||||||
WindowWrapper *window_wrapper = nullptr;
|
WindowWrapper *window_wrapper = nullptr;
|
||||||
|
|
||||||
|
#ifdef ANDROID_ENABLED
|
||||||
|
Control *virtual_keyboard_spacer = nullptr;
|
||||||
|
int last_kb_height = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SCRIPT_EDITOR_FUNC_MAX = 32,
|
SCRIPT_EDITOR_FUNC_MAX = 32,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user