Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 14, 2024
1 parent bcaad58 commit 11122f9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/textual/_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def resolve_box_models(
fraction_zero = Fraction(0)
margin_size = size - margin

margins = [widget.styles.margin.totals for widget in widgets]

# Fixed box models
box_models: list[BoxModel | None] = [
(
Expand All @@ -211,11 +213,13 @@ def resolve_box_models(
else widget._get_box_model(
size,
viewport_size,
max(fraction_zero, fraction_width - widget.styles.margin.width),
max(fraction_zero, fraction_height - widget.styles.margin.height),
max(fraction_zero, fraction_width - margin_width),
max(fraction_zero, fraction_height - margin_height),
)
)
for (_dimension, widget) in zip(dimensions, widgets)
for (_dimension, widget, (margin_width, margin_height)) in zip(
dimensions, widgets, margins
)
]

if None not in box_models:
Expand Down

0 comments on commit 11122f9

Please sign in to comment.