mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
simplify colors property
This commit is contained in:
@@ -93,7 +93,7 @@ class StylesCache:
|
||||
Returns:
|
||||
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
|
||||
lines = self.render(
|
||||
widget.styles,
|
||||
|
||||
@@ -364,18 +364,18 @@ class DOMNode(MessagePump):
|
||||
@property
|
||||
def rich_style(self) -> Style:
|
||||
"""Get a Rich Style object for this DOMNode."""
|
||||
_, (background, color) = self.colors
|
||||
_, _, background, color = self.colors
|
||||
style = (
|
||||
Style.from_color(color.rich_color, background.rich_color) + self.text_style
|
||||
)
|
||||
return style
|
||||
|
||||
@property
|
||||
def colors(self) -> tuple[tuple[Color, Color], tuple[Color, Color]]:
|
||||
"""Gets the Widgets foreground and background colors, and its parent's colors.
|
||||
def colors(self) -> tuple[Color, Color, Color, Color]:
|
||||
"""Gets the Widgets foreground and background colors, and its parent's (base) colors.
|
||||
|
||||
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_color = color = Color(255, 255, 255, 0)
|
||||
@@ -387,7 +387,7 @@ class DOMNode(MessagePump):
|
||||
if styles.has_rule("color"):
|
||||
base_color = color
|
||||
color = styles.color
|
||||
return (base_background, base_color), (background, color)
|
||||
return (base_background, base_color, background, color)
|
||||
|
||||
@property
|
||||
def ancestors(self) -> list[DOMNode]:
|
||||
|
||||
Reference in New Issue
Block a user