Skip to content

Commit

Permalink
Merge pull request #648 from MyreMylar/show_hide_options_2
Browse files Browse the repository at this point in the history
Add better option to disable hiding/showing contained elements of containers
  • Loading branch information
MyreMylar authored Nov 3, 2024
2 parents 9872980 + ca740d1 commit 45de6bd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
20 changes: 16 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,15 @@ 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)

self._root_container.show(show_contents=False)
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 @@ -537,9 +544,14 @@ def hide(self, hide_contents: bool = True):
"""
if not self.visible:
return
self._root_container.hide(hide_contents=False)
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._root_container is not None:
self._root_container.hide(hide_contents)
if self._view_container is not None:
self._view_container.hide(hide_contents)
super().hide()

def __iter__(self) -> Iterator[IUIElementInterface]:
Expand Down
18 changes: 14 additions & 4 deletions pygame_gui/elements/ui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,13 @@ 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()
self._window_root_container.show(show_contents=False)
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 +777,13 @@ 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)
self._window_root_container.hide(hide_contents=False)
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 45de6bd

Please sign in to comment.