Skip to content

Commit

Permalink
Merge pull request #5088 from Textualize/allow-maximize
Browse files Browse the repository at this point in the history
Allow tooltips in maximize view
  • Loading branch information
willmcgugan authored Oct 7, 2024
2 parents 1e208b4 + 459efab commit ded24b1
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 6 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added

- Added support for A-F to Digits widget https://github.com/Textualize/textual/pull/5094

### 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
- Digits are now thin by default, style with text-style: bold to get bold digits https://github.com/Textualize/textual/pull/5094

### Added

- Added support for A-F to Digits widget https://github.com/Textualize/textual/pull/5094

## [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

0 comments on commit ded24b1

Please sign in to comment.