diff --git a/src/textual/_arrange.py b/src/textual/_arrange.py index 1484b120f..b415d8983 100644 --- a/src/textual/_arrange.py +++ b/src/textual/_arrange.py @@ -94,9 +94,7 @@ def arrange( ) dock_region = dock_region.shrink(margin).translate(align_offset) add_placement( - _WidgetPlacement( - dock_region, null_spacing, dock_widget, top_z, True, False - ) + _WidgetPlacement(dock_region, null_spacing, dock_widget, top_z, True) ) dock_spacing = Spacing(top, right, bottom, left) diff --git a/src/textual/_compositor.py b/src/textual/_compositor.py index 115dafa9f..61e4f3de8 100644 --- a/src/textual/_compositor.py +++ b/src/textual/_compositor.py @@ -592,7 +592,6 @@ class Compositor: get_layer_index = layers_to_index.get scroll_spacing = arrange_result.scroll_spacing - total_region = total_region.shrink(scroll_spacing) # Add all the widgets for sub_region, margin, sub_widget, z, fixed, overlay in reversed( @@ -622,21 +621,13 @@ class Compositor: constrain in ("y", "both"), ) - if overlay: - clip_region = no_clip - else: - if fixed: - clip_region = sub_clip - else: - clip_region = sub_clip.shrink(scroll_spacing) - add_widget( sub_widget, sub_region, widget_region, ((1, 0, 0),) if overlay else widget_order, layer_order, - clip_region, + no_clip if overlay else sub_clip, visible, ) diff --git a/src/textual/_layout.py b/src/textual/_layout.py index 40716b7f7..e0061c148 100644 --- a/src/textual/_layout.py +++ b/src/textual/_layout.py @@ -72,9 +72,9 @@ class WidgetPlacement(NamedTuple): region: Region margin: Spacing widget: Widget - order: int - fixed: bool - overlay: bool + order: int = 0 + fixed: bool = False + overlay: bool = False class Layout(ABC): diff --git a/src/textual/_partition.py b/src/textual/_partition.py index 7bb46794d..858846f54 100644 --- a/src/textual/_partition.py +++ b/src/textual/_partition.py @@ -21,9 +21,8 @@ def partition( """ result: tuple[list[T], list[T]] = ([], []) - append0 = result[0].append - append1 = result[1].append + appends = (result[0].append, result[1].append) for value in iterable: - (append1 if pred(value) else append0)(value) + appends[1 if pred(value) else 0](value) return result diff --git a/src/textual/layouts/grid.py b/src/textual/layouts/grid.py index d26752f75..3ade70ab2 100644 --- a/src/textual/layouts/grid.py +++ b/src/textual/layouts/grid.py @@ -153,7 +153,7 @@ class GridLayout(Layout): .shrink(margin) .clip_size(cell_size) ) - add_placement(WidgetPlacement(region, margin, widget, 0, False, False)) + add_placement(WidgetPlacement(region, margin, widget)) add_widget(widget) return (placements, set(widgets)) diff --git a/src/textual/screen.py b/src/textual/screen.py index d58a69031..34db473ef 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -580,10 +580,7 @@ class Screen(Generic[ScreenResultType], Widget): ) in layers: if widget in exposed_widgets: if widget._size_updated( - region.size, - virtual_size, - container_size, - layout=False, + region.size, virtual_size, container_size, layout=False ): widget.post_message( ResizeEvent( diff --git a/tests/test_arrange.py b/tests/test_arrange.py index 8014d0d31..38f5a191d 100644 --- a/tests/test_arrange.py +++ b/tests/test_arrange.py @@ -24,8 +24,10 @@ def test_arrange_dock_top(): result = arrange(container, [child, header], Size(80, 24), Size(80, 24)) assert result.placements == [ - WidgetPlacement(Region(0, 0, 80, 1), Spacing(), header, TOP_Z, True, False), - WidgetPlacement(Region(0, 1, 80, 23), Spacing(), child, 0, False, False), + WidgetPlacement( + Region(0, 0, 80, 1), Spacing(), header, order=TOP_Z, fixed=True + ), + WidgetPlacement(Region(0, 1, 80, 23), Spacing(), child, order=0, fixed=False), ] assert result.widgets == {child, header} @@ -39,8 +41,10 @@ def test_arrange_dock_left(): result = arrange(container, [child, header], Size(80, 24), Size(80, 24)) assert result.placements == [ - WidgetPlacement(Region(0, 0, 10, 24), Spacing(), header, TOP_Z, True, False), - WidgetPlacement(Region(10, 0, 70, 24), Spacing(), child, 0, False, False), + WidgetPlacement( + Region(0, 0, 10, 24), Spacing(), header, order=TOP_Z, fixed=True + ), + WidgetPlacement(Region(10, 0, 70, 24), Spacing(), child, order=0, fixed=False), ] assert result.widgets == {child, header} @@ -54,8 +58,10 @@ def test_arrange_dock_right(): result = arrange(container, [child, header], Size(80, 24), Size(80, 24)) assert result.placements == [ - WidgetPlacement(Region(70, 0, 10, 24), Spacing(), header, TOP_Z, True, False), - WidgetPlacement(Region(0, 0, 70, 24), Spacing(), child, 0, False, False), + WidgetPlacement( + Region(70, 0, 10, 24), Spacing(), header, order=TOP_Z, fixed=True + ), + WidgetPlacement(Region(0, 0, 70, 24), Spacing(), child, order=0, fixed=False), ] assert result.widgets == {child, header} @@ -69,8 +75,10 @@ def test_arrange_dock_bottom(): result = arrange(container, [child, header], Size(80, 24), Size(80, 24)) assert result.placements == [ - WidgetPlacement(Region(0, 23, 80, 1), Spacing(), header, TOP_Z, True, False), - WidgetPlacement(Region(0, 0, 80, 23), Spacing(), child, 0, False, False), + WidgetPlacement( + Region(0, 23, 80, 1), Spacing(), header, order=TOP_Z, fixed=True + ), + WidgetPlacement(Region(0, 0, 80, 23), Spacing(), child, order=0, fixed=False), ] assert result.widgets == {child, header}