Skip to content

Commit ded24b1

Browse files
authored
Merge pull request #5088 from Textualize/allow-maximize
Allow tooltips in maximize view
2 parents 1e208b4 + 459efab commit ded24b1

File tree

5 files changed

+220
-6
lines changed

5 files changed

+220
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
99

10-
### Added
11-
12-
- Added support for A-F to Digits widget https://github.com/Textualize/textual/pull/5094
1310

1411
### Changed
1512

13+
- `Screen.ALLOW_IN_MAXIMIZED_VIEW` will now default to `App.ALLOW_IN_MAXIMIZED_VIEW` https://github.com/Textualize/textual/pull/5088
14+
- Widgets matching `.-textual-system` will now be included in the maximize view by default https://github.com/Textualize/textual/pull/5088
1615
- Digits are now thin by default, style with text-style: bold to get bold digits https://github.com/Textualize/textual/pull/5094
1716

17+
### Added
18+
19+
- Added support for A-F to Digits widget https://github.com/Textualize/textual/pull/5094
20+
1821
## [0.82.0] - 2024-10-03
1922

2023
### Fixed

src/textual/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ class MyApp(App[None]):
461461
COMMAND_PALETTE_DISPLAY: ClassVar[str | None] = None
462462
"""How the command palette key should be displayed in the footer (or `None` for default)."""
463463

464+
ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str] = "Footer"
465+
"""The default value of [Screen.ALLOW_IN_MAXIMIZED_VIEW][textual.screen.Screen.ALLOW_IN_MAXIMIZED_VIEW]."""
466+
464467
BINDINGS: ClassVar[list[BindingType]] = [
465468
Binding("ctrl+c", "quit", "Quit", show=False, priority=True)
466469
]

src/textual/screen.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ class Screen(Generic[ScreenResultType], Widget):
204204
205205
Should be a set of [`command.Provider`][textual.command.Provider] classes.
206206
"""
207-
ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str] = ".-textual-system,Footer"
208-
"""A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget)."""
207+
ALLOW_IN_MAXIMIZED_VIEW: ClassVar[str | None] = None
208+
"""A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget). Or
209+
`None` to default to [App.ALLOW_IN_MAXIMIZED_VIEW][textual.app.App.ALLOW_IN_MAXIMIZED_VIEW]"""
209210

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

438+
allow_in_maximized_view = (
439+
self.app.ALLOW_IN_MAXIMIZED_VIEW
440+
if self.ALLOW_IN_MAXIMIZED_VIEW is None
441+
else self.ALLOW_IN_MAXIMIZED_VIEW
442+
)
443+
444+
def get_maximize_widgets(maximized: Widget) -> list[Widget]:
445+
"""Get widgets to display in maximized view.
446+
447+
Returns:
448+
A list of widgets.
449+
450+
"""
451+
# De-duplicate with a set
452+
widgets = {
453+
maximized,
454+
*self.query_children(allow_in_maximized_view),
455+
*self.query_children(".-textual-system"),
456+
}
457+
# Restore order of widgets.
458+
maximize_widgets = [widget for widget in self.children if widget in widgets]
459+
# Add the maximized widget, if its not already included
460+
if maximized not in maximize_widgets:
461+
maximize_widgets.insert(0, maximized)
462+
return maximize_widgets
463+
437464
arrangement = self._arrangement_cache[cache_key] = arrange(
438465
self,
439466
(
440-
[self.maximized, *self.query_children(self.ALLOW_IN_MAXIMIZED_VIEW)]
467+
get_maximize_widgets(self.maximized)
441468
if self.maximized is not None
442469
else self._nodes
443470
),

0 commit comments

Comments
 (0)