mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
box mode
This commit is contained in:
@@ -43,18 +43,15 @@ def get_box_model(
|
||||
gutter = styles.gutter
|
||||
margin = styles.margin
|
||||
|
||||
styles_width = styles.width
|
||||
styles_height = styles.height
|
||||
|
||||
is_auto_width = styles_width and styles_width.is_auto
|
||||
is_auto_height = styles_height and styles_height.is_auto
|
||||
is_auto_width = styles.width and styles.width.is_auto
|
||||
is_auto_height = styles.height and styles.height.is_auto
|
||||
|
||||
# Container minus padding and border
|
||||
content_container = container - gutter.totals
|
||||
# The container including the content
|
||||
sizing_container = content_container if is_border_box else container
|
||||
|
||||
if styles_width is None:
|
||||
if styles.width is None:
|
||||
# No width specified, fill available space
|
||||
content_width = Fraction(content_container.width - margin.width)
|
||||
elif is_auto_width:
|
||||
@@ -64,6 +61,7 @@ def get_box_model(
|
||||
)
|
||||
else:
|
||||
# An explicit width
|
||||
styles_width = styles.width
|
||||
content_width = styles_width.resolve_dimension(
|
||||
sizing_container - styles.margin.totals, viewport, fraction_unit
|
||||
)
|
||||
@@ -86,7 +84,7 @@ def get_box_model(
|
||||
|
||||
content_width = max(Fraction(0), content_width)
|
||||
|
||||
if styles_height is None:
|
||||
if styles.height is None:
|
||||
# No height specified, fill the available space
|
||||
content_height = Fraction(content_container.height - margin.height)
|
||||
elif is_auto_height:
|
||||
@@ -95,6 +93,7 @@ def get_box_model(
|
||||
get_content_height(content_container, viewport, int(content_width))
|
||||
)
|
||||
else:
|
||||
styles_height = styles.height
|
||||
# Explicit height set
|
||||
content_height = styles_height.resolve_dimension(
|
||||
sizing_container - styles.margin.totals, viewport, fraction_unit
|
||||
|
||||
Reference in New Issue
Block a user