Skip to content

Commit 8e4fb5f

Browse files
authored
UI: fix UIAnchorLayout (#1401)
1 parent 430dd3b commit 8e4fb5f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

arcade/gui/widgets/layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _place_child(
101101
new_child_rect = new_child_rect.max_size(width=shmx_w)
102102

103103
if sh_h is not None:
104-
new_child_rect = new_child_rect.resize(height=self.content_height * sh_w)
104+
new_child_rect = new_child_rect.resize(height=self.content_height * sh_h)
105105

106106
if shmn_h:
107107
new_child_rect = new_child_rect.min_size(height=shmn_h)

tests/test_gui/test_layouting_anchorlayout.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,24 @@ def test_grow_child_half(window):
8181
assert dummy.rect == (100, 100, 200, 200)
8282

8383

84-
def test_grow_child_full(window):
84+
def test_grow_child_full_width(window):
8585
subject = UIAnchorLayout(width=400, height=400)
86-
dummy = subject.add(UIDummy(width=100, height=100, size_hint=(1, 1)))
86+
dummy = subject.add(UIDummy(width=100, height=100, size_hint=(1, 0.5)))
8787

8888
subject._do_layout()
8989

9090
assert subject.rect == (0, 0, 400, 400)
91-
assert dummy.rect == (0, 0, 400, 400)
91+
assert dummy.rect == (0, 100, 400, 200)
92+
93+
94+
def test_grow_child_full_height(window):
95+
subject = UIAnchorLayout(width=400, height=400)
96+
dummy = subject.add(UIDummy(width=100, height=100, size_hint=(0.5, 1)))
97+
98+
subject._do_layout()
99+
100+
assert subject.rect == (0, 0, 400, 400)
101+
assert dummy.rect == (100, 0, 200, 400)
92102

93103

94104
def test_grow_child_to_max_size(window):
@@ -101,7 +111,7 @@ def test_grow_child_to_max_size(window):
101111
assert dummy.size == (200, 150)
102112

103113

104-
def test_shring_child_to_min_size(window):
114+
def test_shrink_child_to_min_size(window):
105115
subject = UIAnchorLayout(width=400, height=400)
106116
dummy = subject.add(UIDummy(width=100, height=100, size_hint=(0.1, 0.1), size_hint_min=(200, 150)))
107117

0 commit comments

Comments
 (0)