Skip to content

Commit

Permalink
Add better option to disable hiding/showing contained elements of con…
Browse files Browse the repository at this point in the history
…tainers
  • Loading branch information
MyreMylar committed Nov 3, 2024
1 parent 035206b commit 4031d46
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
19 changes: 15 additions & 4 deletions pygame_gui/elements/ui_scrolling_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,14 @@ def show(self, show_contents: bool = True):
:param show_contents: whether to also show the contents of the container. Defaults to True.
"""
super().show()
if self._root_container is not None:
self._root_container.show(show_contents)

if self.vert_scroll_bar is not None:
self.vert_scroll_bar.show()
if self.horiz_scroll_bar is not None:
self.horiz_scroll_bar.show()

if self._view_container is not None:
self._view_container.show(show_contents)

def hide(self, hide_contents: bool = True):
"""
Expand All @@ -538,8 +544,13 @@ def hide(self, hide_contents: bool = True):
if not self.visible:
return

if self._root_container is not None:
self._root_container.hide(hide_contents)
if self.vert_scroll_bar is not None:
self.vert_scroll_bar.hide()
if self.horiz_scroll_bar is not None:
self.horiz_scroll_bar.hide()

if self._view_container is not None:
self._view_container.hide(hide_contents)
super().hide()

def __iter__(self) -> Iterator[IUIElementInterface]:
Expand Down
16 changes: 12 additions & 4 deletions pygame_gui/elements/ui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,12 @@ def show(self, show_contents: bool = True):
:param show_contents: whether to also show the contents of the window. Defaults to True.
"""
super().show()
if self._window_root_container is not None:
self._window_root_container.show()
if self.title_bar is not None:
self.title_bar.show()
if self.close_window_button is not None:
self.close_window_button.show()
if self.window_element_container is not None:
self.window_element_container.show(show_contents)

def hide(self, hide_contents: bool = True):
"""
Expand All @@ -772,8 +776,12 @@ def hide(self, hide_contents: bool = True):
return

super().hide()
if self._window_root_container is not None:
self._window_root_container.hide(hide_contents)
if self.title_bar is not None:
self.title_bar.hide()
if self.close_window_button is not None:
self.close_window_button.hide()
if self.window_element_container is not None:
self.window_element_container.hide(hide_contents)

def get_relative_mouse_pos(self):
"""
Expand Down

0 comments on commit 4031d46

Please sign in to comment.