simplify colors property

This commit is contained in:
Will McGugan
2022-07-29 11:11:39 +01:00
parent 001139b18d
commit 631685e373
2 changed files with 6 additions and 6 deletions

View File

@@ -93,7 +93,7 @@ class StylesCache:
Returns: Returns:
Lines: Rendered lines. Lines: Rendered lines.
""" """
(base_background, base_color), (background, color) = widget.colors base_background, _base_color, background, _color = widget.colors
padding = widget.styles.padding + widget.scrollbar_gutter padding = widget.styles.padding + widget.scrollbar_gutter
lines = self.render( lines = self.render(
widget.styles, widget.styles,

View File

@@ -364,18 +364,18 @@ class DOMNode(MessagePump):
@property @property
def rich_style(self) -> Style: def rich_style(self) -> Style:
"""Get a Rich Style object for this DOMNode.""" """Get a Rich Style object for this DOMNode."""
_, (background, color) = self.colors _, _, background, color = self.colors
style = ( style = (
Style.from_color(color.rich_color, background.rich_color) + self.text_style Style.from_color(color.rich_color, background.rich_color) + self.text_style
) )
return style return style
@property @property
def colors(self) -> tuple[tuple[Color, Color], tuple[Color, Color]]: def colors(self) -> tuple[Color, Color, Color, Color]:
"""Gets the Widgets foreground and background colors, and its parent's colors. """Gets the Widgets foreground and background colors, and its parent's (base) colors.
Returns: Returns:
tuple[tuple[Color, Color], tuple[Color, Color]]: Base colors and widget colors tuple[Color, Color, Color, Color]: Tuple of (base background, base color, background, color)
""" """
base_background = background = Color(0, 0, 0, 0) base_background = background = Color(0, 0, 0, 0)
base_color = color = Color(255, 255, 255, 0) base_color = color = Color(255, 255, 255, 0)
@@ -387,7 +387,7 @@ class DOMNode(MessagePump):
if styles.has_rule("color"): if styles.has_rule("color"):
base_color = color base_color = color
color = styles.color color = styles.color
return (base_background, base_color), (background, color) return (base_background, base_color, background, color)
@property @property
def ancestors(self) -> list[DOMNode]: def ancestors(self) -> list[DOMNode]: