Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tooltips in maximize view #5088

Merged
merged 12 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Changed

- `Screen.ALLOW_IN_MAXIMIZED_VIEW` will now default to `App.ALLOW_IN_MAXIMIZED_VIEW` https://github.com/Textualize/textual/pull/5088
- Widgets matching `.-textual-system` will now be included in the maximize view by default https://github.com/Textualize/textual/pull/5088


## [0.82.0] - 2024-10-03

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ class MyApp(App[None]):
COMMAND_PALETTE_DISPLAY: ClassVar[str | None] = None
"""How the command palette key should be displayed in the footer (or `None` for default)."""

ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str] = "Footer"
"""The default value of [Screen.ALLOW_IN_MAXIMIZED_VIEW][textual.screen.Screen.ALLOW_IN_MAXIMIZED_VIEW]."""

BINDINGS: ClassVar[list[BindingType]] = [
Binding("ctrl+c", "quit", "Quit", show=False, priority=True)
]
Expand Down
33 changes: 30 additions & 3 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ class Screen(Generic[ScreenResultType], Widget):

Should be a set of [`command.Provider`][textual.command.Provider] classes.
"""
ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str] = ".-textual-system,Footer"
"""A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget)."""
ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str | None] = None
"""A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget). Or
`None` to default to [App.ALLOW_IN_MAXIMIZED_VIEW][textual.app.App.ALLOW_IN_MAXIMIZED_VIEW]"""

ESCAPE_TO_MINIMIZE: ClassVar[bool | None] = None
"""Use escape key to minimize (potentially overriding bindings) or `None` to defer to [`App.ESCAPE_TO_MINIMIZE`][textual.app.App.ESCAPE_TO_MINIMIZE]."""
Expand Down Expand Up @@ -434,10 +435,36 @@ def _arrange(self, size: Size) -> DockArrangeResult:
if cached_result is not None:
return cached_result

allow_in_maximized_view = (
self.app.ALLOW_IN_MAXIMIZED_VIEW
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 = {
maximized,
*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]
# 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,
(
[self.maximized, *self.query_children(self.ALLOW_IN_MAXIMIZED_VIEW)]
get_maximize_widgets(self.maximized)
if self.maximized is not None
else self._nodes
),
Expand Down
Loading
Loading