10
10
11
11
class UIContainer (UIElement , IUIContainerInterface , IContainerLikeInterface ):
12
12
"""
13
- A UI Container holds any number of other UI elements inside of a rectangle. When we move the
13
+ A UI Container holds any number of other UI elements inside a rectangle. When we move the
14
14
UIContainer all the UI elements contained within it can be moved as well.
15
15
16
16
This class helps us make UI Windows, but likely will have wider uses as well as the GUI
17
17
system develops.
18
18
19
19
:param relative_rect: A pygame.Rect whose position is relative to whatever UIContainer it is
20
- inside of , if any.
20
+ inside, if any.
21
21
:param manager: The UIManager that manages this UIElement.
22
- :param starting_height: The starting layer height for this element above it's container.
22
+ :param starting_height: The starting layer height for this element above its container.
23
23
:param is_window_root_container: True/False flag for whether this container is the root
24
24
container for a UI window.
25
25
:param container: The UIContainer that this UIElement is contained within.
26
26
:param parent_element: The element this element 'belongs to' in the theming hierarchy.
27
- :param object_id: A custom defined ID for fine tuning of theming.
27
+ :param object_id: A custom defined ID for fine- tuning of theming.
28
28
:param anchors: A dictionary describing what this element's relative_rect is relative to.
29
29
:param visible: Whether the container and its children are visible by default.
30
30
Warning - it's parent container visibility may override this.
@@ -132,7 +132,7 @@ def recalculate_container_layer_thickness(self):
132
132
if new_thickness != self .layer_thickness :
133
133
self .layer_thickness = new_thickness
134
134
if self .ui_container is not None and self .ui_container != self :
135
- self .ui_container .recalculate_container_layer_thickness ()
135
+ self .ui_container .get_container (). recalculate_container_layer_thickness ()
136
136
137
137
def calc_add_element_changes_thickness (self , element : IUIElementInterface ):
138
138
"""
@@ -148,7 +148,7 @@ def calc_add_element_changes_thickness(self, element: IUIElementInterface):
148
148
self .max_element_top_layer = element .get_top_layer ()
149
149
self .layer_thickness = self .max_element_top_layer - self ._layer
150
150
if self .ui_container is not None and self .ui_container != self :
151
- self .ui_container .calc_add_element_changes_thickness (self )
151
+ self .ui_container .get_container (). calc_add_element_changes_thickness (self )
152
152
153
153
def change_layer (self , new_layer : int ):
154
154
"""
@@ -292,7 +292,7 @@ def check_hover(self, time_delta: float, hovered_higher_element: bool) -> bool:
292
292
293
293
def disable (self ):
294
294
"""
295
- Disables all elements in the container so they are no longer interactive.
295
+ Disables all elements in the container, so they are no longer interactive.
296
296
"""
297
297
if self .is_enabled :
298
298
self .is_enabled = False
@@ -301,7 +301,7 @@ def disable(self):
301
301
302
302
def enable (self ):
303
303
"""
304
- Enables all elements in the container so they are interactive again.
304
+ Enables all elements in the container, so they are interactive again.
305
305
"""
306
306
if not self .is_enabled :
307
307
self .is_enabled = True
@@ -334,13 +334,14 @@ def hide(self):
334
334
335
335
self .visible = False
336
336
337
- def on_anchor_target_changed (self , target : IUIElementInterface ):
337
+ def on_contained_elements_changed (self , target : IUIElementInterface ) -> None :
338
338
"""
339
- Update the contents of this container that one of their layout anchors may have moved, or
340
- been resized.
339
+ Update the positioning of the contained elements of this container. To be called when one of the contained
340
+ elements may have moved, been resized or changed its anchors .
341
341
342
- :param target: the UI element that has been benn moved or resized .
342
+ :param target: the UI element that has been benn moved resized or changed its anchors .
343
343
"""
344
344
for element in self .elements :
345
345
if target in element .get_anchor_targets ():
346
346
element .update_containing_rect_position ()
347
+ self .on_contained_elements_changed (element )
0 commit comments