feat(term): add "size_changed" signal

Will be emitted when the number of cols or rows changes.
This commit is contained in:
Leroy Hopson 2024-02-25 22:32:09 +13:00
parent ee920a45fd
commit 1da42501af
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA

View file

@ -27,6 +27,7 @@ void Terminal::_bind_methods()
{
ADD_SIGNAL(MethodInfo("data_sent", PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data")));
ADD_SIGNAL(MethodInfo("key_pressed", PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data"), PropertyInfo(Variant::OBJECT, "event")));
ADD_SIGNAL(MethodInfo("size_changed", PropertyInfo(Variant::VECTOR2I, "new_size")));
ClassDB::bind_method(D_METHOD("get_cols"), &Terminal::get_cols);
ClassDB::bind_method(D_METHOD("set_cols", "cols"), &Terminal::set_cols);
@ -444,6 +445,9 @@ void Terminal::update_sizes(bool force)
update_shader_parameters(back_material);
update_shader_parameters(fore_material);
if (prev_cols != cols || prev_rows != rows)
emit_signal("size_changed", Vector2i(cols, rows));
refresh();
}