#nullable enable
namespace Terminal.Gui;
public static partial class Application // Screen related stuff
{
/// Invoked when the terminal's size changed. The new size of the terminal is provided.
///
/// Event handlers can set to to prevent
/// from changing it's size to match the new terminal size.
///
public static event EventHandler? SizeChanging;
///
/// Called when the application's size changes. Sets the size of all s and fires the
/// event.
///
/// The new size.
/// if the size was changed.
public static bool OnSizeChanging (SizeChangedEventArgs args)
{
SizeChanging?.Invoke (null, args);
if (args.Cancel || args.Size is null)
{
return false;
}
foreach (Toplevel t in TopLevels)
{
t.SetRelativeLayout (args.Size.Value);
t.LayoutSubviews ();
t.PositionToplevels ();
t.OnSizeChanging (new (args.Size));
if (PositionCursor (t))
{
Driver?.UpdateCursor ();
}
}
Refresh ();
return true;
}
}