aboutsummaryrefslogtreecommitdiff
path: root/client/menu/smart_margin_container.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/smart_margin_container.gd')
-rw-r--r--client/menu/smart_margin_container.gd41
1 files changed, 0 insertions, 41 deletions
diff --git a/client/menu/smart_margin_container.gd b/client/menu/smart_margin_container.gd
deleted file mode 100644
index 046dc6f3..00000000
--- a/client/menu/smart_margin_container.gd
+++ /dev/null
@@ -1,41 +0,0 @@
-# Hurry Curry! - a game about cooking
-# Copyright (C) 2025 Hurry Curry! contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, version 3 of the License only.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-extends MarginContainer
-class_name SmartMarginContainer
-# A smart margin container which automatically adjusts the margin such that it doesn't cover notch on phones
-
-func _ready() -> void:
- var os := OS.get_name()
- if os == "iOS" or os == "Android":
- update_margins()
-
-func update_margins() -> void:
- var screen_safe_rect := Rect2(DisplayServer.get_display_safe_area())
- var viewport_transform := get_viewport().get_final_transform()
- var viewport_safe_rect := screen_safe_rect * viewport_transform.affine_inverse()
- var viewport_full_rect := get_viewport().get_visible_rect()
- var left := viewport_safe_rect.position.x - viewport_full_rect.position.x
- var top := viewport_safe_rect.position.y - viewport_full_rect.position.y
- var right := viewport_full_rect.end.x - viewport_safe_rect.end.x
- var bottom := viewport_full_rect.end.y - viewport_safe_rect.end.y
- # print("OLD: ", get_theme_constant("margin_left"))
- begin_bulk_theme_override()
- add_theme_constant_override('margin_left', roundi(left) + get_theme_constant("margin_left"))
- add_theme_constant_override('margin_top', roundi(top) + get_theme_constant("margin_top"))
- add_theme_constant_override('margin_right', roundi(right) + get_theme_constant("margin_right"))
- add_theme_constant_override('margin_bottom', roundi(bottom) + get_theme_constant("margin_bottom"))
- end_bulk_theme_override()
- # print("NEW: ", get_theme_constant("margin_left"))