Skip to content

Commit

Permalink
docs and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Apr 22, 2024
1 parent fb05a51 commit 17d4c96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,11 @@ async def _on_css_change(self) -> None:
self.stylesheet.update(screen)

def render(self) -> RenderResult:
"""Render method inherited from widget, to render the screen's background.
May be override to customize background visuals.
"""
return Blank(self.styles.background)

ExpectType = TypeVar("ExpectType", bound=Widget)
Expand Down
8 changes: 8 additions & 0 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,25 @@ def layers(self) -> tuple[str, ...]:
return (*super().layers, *extras)

def render(self) -> RenderableType:
"""Render method inherited from widget, used to render the screen's background.
Returns:
Background renderable.
"""
background = self.styles.background
try:
base_screen = visible_screen_stack.get().pop()
except IndexError:
base_screen = None

if base_screen is not None and background.a < 1:
# If background is translucent, render a background screen
return BackgroundScreen(base_screen, background)

if background.is_transparent:
# If the background is transparent, defer to App.render
return self.app.render()
# Render a screen of a solid color.
return Blank(background)

def get_offset(self, widget: Widget) -> Offset:
Expand Down

0 comments on commit 17d4c96

Please sign in to comment.