Skip to content

Commit

Permalink
order logic
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 3, 2024
1 parent 52c6e5f commit 6002960
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 116 deletions.
23 changes: 0 additions & 23 deletions src/textual/_unique.py

This file was deleted.

31 changes: 25 additions & 6 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
_make_path_object_relative,
)
from textual._types import CallbackType
from textual._unique import unique_ordered
from textual.await_complete import AwaitComplete
from textual.binding import ActiveBinding, Binding, BindingsMap
from textual.css.match import match
Expand Down Expand Up @@ -441,14 +440,34 @@ def _arrange(self, size: Size) -> DockArrangeResult:
if self.ALLOW_IN_MAXIMIZED_VIEW is None
else self.ALLOW_IN_MAXIMIZED_VIEW
)

def get_maximize_widgets(maximized: Widget) -> list[Widget]:
"""Get widgets to display in maximized view.
Returns:
A list of widgets.
"""
# De-duplicate with a set
widgets = {
*self.query_children(allow_in_maximized_view),
*self.query_children(".-textual-system"),
}
# Restore order of widgets.
maximize_widgets = [
widget
for widget in self.children
if widget in widgets or widget is maximized
]
# Add the maximized widget, if its not already included
if maximized not in maximize_widgets:
maximize_widgets.insert(0, maximized)
return maximize_widgets

arrangement = self._arrangement_cache[cache_key] = arrange(
self,
(
unique_ordered(
self.query_children(allow_in_maximized_view),
self.query_children(".-textual-system"),
[self.maximized],
)
get_maximize_widgets(self.maximized)
if self.maximized is not None
else self._nodes
),
Expand Down
Loading

0 comments on commit 6002960

Please sign in to comment.