mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docstringd and comments
This commit is contained in:
@@ -63,6 +63,7 @@ class MapGeometry(NamedTuple):
|
||||
return self.clip.intersection(self.region)
|
||||
|
||||
|
||||
# Maps a widget on to its geometry (information that describes its position in the composition)
|
||||
CompositorMap: TypeAlias = "dict[Widget, MapGeometry]"
|
||||
|
||||
|
||||
@@ -171,10 +172,11 @@ class Compositor:
|
||||
Iterable[tuple[int, int, int]]: Yields tuples of (Y, X1, X2)
|
||||
"""
|
||||
inline_ranges: dict[int, list[tuple[int, int]]] = {}
|
||||
setdefault = inline_ranges.setdefault
|
||||
for region_x, region_y, width, height in regions:
|
||||
span = (region_x, region_x + width)
|
||||
for y in range(region_y, region_y + height):
|
||||
inline_ranges.setdefault(y, []).append(span)
|
||||
setdefault(y, []).append(span)
|
||||
|
||||
for y, ranges in sorted(inline_ranges.items()):
|
||||
if len(ranges) == 1:
|
||||
|
||||
@@ -484,13 +484,13 @@ class Region(NamedTuple):
|
||||
)
|
||||
|
||||
def intersection(self, region: Region) -> Region:
|
||||
"""Get that covers both regions.
|
||||
"""Get the overlapping portion of the two regions.
|
||||
|
||||
Args:
|
||||
region (Region): A region that overlaps this region.
|
||||
|
||||
Returns:
|
||||
Region: A new region that fits within ``region``.
|
||||
Region: A new region that covers when the two regions overlap.
|
||||
"""
|
||||
# Unrolled because this method is used a lot
|
||||
x1, y1, w1, h1 = self
|
||||
@@ -511,10 +511,10 @@ class Region(NamedTuple):
|
||||
"""Get a new region that contains both regions.
|
||||
|
||||
Args:
|
||||
region (Region): [description]
|
||||
region (Region): Another region.
|
||||
|
||||
Returns:
|
||||
Region: [description]
|
||||
Region: An optimally sized region to cover both regions.
|
||||
"""
|
||||
x1, y1, x2, y2 = self.corners
|
||||
ox1, oy1, ox2, oy2 = region.corners
|
||||
|
||||
Reference in New Issue
Block a user