Merge pull request #102668 from jkirsteins/janiskirsteins/ios-aspect-fill-splash

[iOS] Sync the boot splash and the launch screen image scale modes
This commit is contained in:
Thaddeus Crews
2025-02-12 12:56:26 -06:00
9 changed files with 117 additions and 25 deletions

View File

@ -222,6 +222,23 @@ uint64_t OS::get_embedded_pck_offset() const {
return 0;
}
// Default boot screen rect scale mode is "Keep Aspect Centered"
Rect2 OS::calculate_boot_screen_rect(const Size2 &p_window_size, const Size2 &p_imgrect_size) const {
Rect2 screenrect;
if (p_window_size.width > p_window_size.height) {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = p_imgrect_size.x * p_window_size.height / p_imgrect_size.y;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
} else {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = p_imgrect_size.y * p_window_size.width / p_imgrect_size.x;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
}
return screenrect;
}
// Helper function to ensure that a dir name/path will be valid on the OS
String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const {
String safe_dir_name = p_dir_name;

View File

@ -161,6 +161,8 @@ public:
virtual void open_midi_inputs();
virtual void close_midi_inputs();
virtual Rect2 calculate_boot_screen_rect(const Size2 &p_window_size, const Size2 &p_imgrect_size) const;
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
struct GDExtensionData {