diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b698532b4..e12740281b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Removed + +- Removed renderables/align.py which was no longer used + +## [0.44.1] - 2023-12-4 + +### Fixed + +- Fixed slow scrolling when there are many widgets https://github.com/Textualize/textual/pull/3801 + ## [0.44.0] - 2023-12-1 ### Changed @@ -1494,6 +1506,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040 - New handler system for messages that doesn't require inheritance - Improved traceback handling +[0.44.1]: https://github.com/Textualize/textual/compare/v0.44.0...v0.44.1 [0.44.0]: https://github.com/Textualize/textual/compare/v0.43.2...v0.44.0 [0.43.2]: https://github.com/Textualize/textual/compare/v0.43.1...v0.43.2 [0.43.1]: https://github.com/Textualize/textual/compare/v0.43.0...v0.43.1 diff --git a/pyproject.toml b/pyproject.toml index 5ee266d714..eb0cda9f5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual" -version = "0.44.0" +version = "0.44.1" homepage = "https://github.com/Textualize/textual" repository = "https://github.com/Textualize/textual" documentation = "https://textual.textualize.io/" diff --git a/src/textual/_compositor.py b/src/textual/_compositor.py index e3e5ab3021..176011dda3 100644 --- a/src/textual/_compositor.py +++ b/src/textual/_compositor.py @@ -597,9 +597,6 @@ def add_widget( # The region that contains the content (container region minus scrollbars) child_region = widget._get_scrollable_region(container_region) - # Adjust the clip region accordingly - sub_clip = clip.intersection(child_region) - # The region covered by children relative to parent widget total_region = child_region.reset_offset @@ -609,9 +606,12 @@ def add_widget( arranged_widgets = arrange_result.widgets widgets.update(arranged_widgets) + # Get the region that will be updated + sub_clip = clip.intersection(child_region) + if visible_only: placements = arrange_result.get_visible_placements( - container_size.region + widget.scroll_offset + sub_clip - child_region.offset + widget.scroll_offset ) else: placements = arrange_result.placements @@ -621,9 +621,9 @@ def add_widget( placement_offset = container_region.offset placement_scroll_offset = placement_offset - widget.scroll_offset - _layers = widget.layers layers_to_index = { - layer_name: index for index, layer_name in enumerate(_layers) + layer_name: index + for index, layer_name in enumerate(widget.layers) } get_layer_index = layers_to_index.get @@ -661,7 +661,10 @@ def add_widget( if visible: # Add any scrollbars - if any(widget.scrollbars_enabled): + if ( + widget.show_vertical_scrollbar + or widget.show_horizontal_scrollbar + ): for chrome_widget, chrome_region in widget._arrange_scrollbars( container_region ): diff --git a/src/textual/_layout.py b/src/textual/_layout.py index 921d1abbd4..b26e76aca4 100644 --- a/src/textual/_layout.py +++ b/src/textual/_layout.py @@ -65,6 +65,9 @@ def get_visible_placements(self, region: Region) -> list[WidgetPlacement]: Returns: Set of placements. """ + if self.total_region in region: + # Short circuit for when we want all the placements + return self.placements visible_placements = self.spatial_map.get_values_in_region(region) return visible_placements diff --git a/src/textual/renderables/align.py b/src/textual/renderables/align.py deleted file mode 100644 index d97dfc4348..0000000000 --- a/src/textual/renderables/align.py +++ /dev/null @@ -1,56 +0,0 @@ -from __future__ import annotations - -from rich.console import Console, ConsoleOptions, RenderableType, RenderResult -from rich.measure import Measurement -from rich.segment import Segment -from rich.style import Style - -from .._segment_tools import align_lines -from ..css.types import AlignHorizontal, AlignVertical -from ..geometry import Size - - -class Align: - def __init__( - self, - renderable: RenderableType, - size: Size, - style: Style, - horizontal: AlignHorizontal, - vertical: AlignVertical, - ) -> None: - """Align a child renderable - - Args: - renderable: Renderable to align. - size: Size of container. - style: Style of any padding. - horizontal: Horizontal alignment. - vertical: Vertical alignment. - """ - self.renderable = renderable - self.size = size - self.style = style - self.horizontal = horizontal - self.vertical = vertical - - def __rich_console__( - self, console: Console, options: ConsoleOptions - ) -> RenderResult: - lines = console.render_lines(self.renderable, options, pad=False) - new_line = Segment.line() - for line in align_lines( - lines, - self.style, - self.size, - self.horizontal, - self.vertical, - ): - yield from line - yield new_line - - def __rich_measure__( - self, console: "Console", options: "ConsoleOptions" - ) -> Measurement: - width, _ = self.size - return Measurement(width, width) diff --git a/src/textual/scrollbar.py b/src/textual/scrollbar.py index 4e86b3310d..f5d5ff9c95 100644 --- a/src/textual/scrollbar.py +++ b/src/textual/scrollbar.py @@ -49,6 +49,8 @@ class ScrollRight(ScrollMessage, verbose=True): class ScrollTo(ScrollMessage, verbose=True): """Message sent when click and dragging handle.""" + __slots__ = ["x", "y", "animate"] + def __init__( self, x: float | None = None,