mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
optimized property
This commit is contained in:
@@ -93,7 +93,7 @@ class StylesCache:
|
|||||||
Returns:
|
Returns:
|
||||||
Lines: Rendered lines.
|
Lines: Rendered lines.
|
||||||
"""
|
"""
|
||||||
base_background, _base_color, background, _color = widget.colors
|
base_background, background = widget.background_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,
|
||||||
|
|||||||
@@ -370,6 +370,24 @@ class DOMNode(MessagePump):
|
|||||||
)
|
)
|
||||||
return style
|
return style
|
||||||
|
|
||||||
|
@property
|
||||||
|
def background_colors(self) -> tuple[Color, Color]:
|
||||||
|
"""Get the background color and the color of the parent's background.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple[Color, Color]: Tuple of (base background, background)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
base_background = background = Color(0, 0, 0, 0)
|
||||||
|
|
||||||
|
for node in reversed(self.ancestors):
|
||||||
|
styles = node.styles
|
||||||
|
if styles.has_rule("background"):
|
||||||
|
base_background = background
|
||||||
|
background += styles.background
|
||||||
|
return (base_background, background)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def colors(self) -> tuple[Color, Color, Color, Color]:
|
def colors(self) -> tuple[Color, Color, Color, Color]:
|
||||||
"""Gets the Widgets foreground and background colors, and its parent's (base) colors.
|
"""Gets the Widgets foreground and background colors, and its parent's (base) colors.
|
||||||
|
|||||||
Reference in New Issue
Block a user