Skip to content

Commit 9a36c90

Browse files
committed
simplify
1 parent 925c520 commit 9a36c90

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/textual/_compositor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ def add_widget(
569569
"""
570570
if not widget._is_mounted:
571571
return
572+
if self._widget_follow is None:
573+
return
572574
styles = widget.styles
573575

574576
if (visibility := styles.get_rule("visibility")) is not None:

src/textual/layouts/stream.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,55 @@
1111

1212

1313
class StreamLayout(Layout):
14+
"""A cut down version of the vertical layout.
15+
16+
Faster, but with fewer supported "features".
17+
18+
"""
19+
1420
name = "stream"
1521

1622
def arrange(
1723
self, parent: Widget, children: list[Widget], size: Size, greedy: bool = True
1824
) -> ArrangeResult:
1925
parent.pre_layout(self)
26+
if not children:
27+
return []
2028
viewport = parent.app.size
2129

30+
_Region = Region
31+
_WidgetPlacement = WidgetPlacement
32+
2233
placements: list[WidgetPlacement] = []
23-
if not children:
24-
return []
2534
width = size.width
2635
first_child_styles = children[0].styles
2736
y = first_child_styles.margin.top
2837
previous_margin = 0
2938
null_offset = NULL_OFFSET
3039

3140
for widget in children:
32-
styles = widget.styles
33-
overlay = styles.overlay == "screen"
34-
absolute = styles.has_rule("position") and styles.position == "absolute"
41+
styles = widget.styles.base
3542
margin = styles.margin
43+
gutter_width, gutter_height = styles.gutter.totals
3644
top, right, bottom, left = margin
37-
margin_width = left + right
3845
y += max(top, previous_margin)
3946
previous_margin = bottom
40-
height = widget.get_content_height(size, viewport, width - margin_width)
41-
height += styles.gutter.height
47+
height = (
48+
widget.get_content_height(size, viewport, width - gutter_width)
49+
+ gutter_height
50+
)
4251
if (max_height := styles.max_height) is not None and max_height.is_cells:
4352
height = min(height, int(max_height.value))
4453
placements.append(
45-
WidgetPlacement(
46-
Region(left, y, width - margin_width, height),
54+
_WidgetPlacement(
55+
_Region(left, y, width - (left + right), height),
4756
null_offset,
4857
margin,
4958
widget,
5059
0,
5160
False,
52-
overlay,
53-
absolute,
61+
False,
62+
False,
5463
)
5564
)
5665
y += height

0 commit comments

Comments
 (0)