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
|
gutter = styles.gutter
|
||||||
margin = styles.margin
|
margin = styles.margin
|
||||||
|
|
||||||
styles_width = styles.width
|
is_auto_width = styles.width and styles.width.is_auto
|
||||||
styles_height = styles.height
|
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
|
# Container minus padding and border
|
||||||
content_container = container - gutter.totals
|
content_container = container - gutter.totals
|
||||||
# The container including the content
|
# The container including the content
|
||||||
sizing_container = content_container if is_border_box else container
|
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
|
# No width specified, fill available space
|
||||||
content_width = Fraction(content_container.width - margin.width)
|
content_width = Fraction(content_container.width - margin.width)
|
||||||
elif is_auto_width:
|
elif is_auto_width:
|
||||||
@@ -64,6 +61,7 @@ def get_box_model(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# An explicit width
|
# An explicit width
|
||||||
|
styles_width = styles.width
|
||||||
content_width = styles_width.resolve_dimension(
|
content_width = styles_width.resolve_dimension(
|
||||||
sizing_container - styles.margin.totals, viewport, fraction_unit
|
sizing_container - styles.margin.totals, viewport, fraction_unit
|
||||||
)
|
)
|
||||||
@@ -86,7 +84,7 @@ def get_box_model(
|
|||||||
|
|
||||||
content_width = max(Fraction(0), content_width)
|
content_width = max(Fraction(0), content_width)
|
||||||
|
|
||||||
if styles_height is None:
|
if styles.height is None:
|
||||||
# No height specified, fill the available space
|
# No height specified, fill the available space
|
||||||
content_height = Fraction(content_container.height - margin.height)
|
content_height = Fraction(content_container.height - margin.height)
|
||||||
elif is_auto_height:
|
elif is_auto_height:
|
||||||
@@ -95,6 +93,7 @@ def get_box_model(
|
|||||||
get_content_height(content_container, viewport, int(content_width))
|
get_content_height(content_container, viewport, int(content_width))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
styles_height = styles.height
|
||||||
# Explicit height set
|
# Explicit height set
|
||||||
content_height = styles_height.resolve_dimension(
|
content_height = styles_height.resolve_dimension(
|
||||||
sizing_container - styles.margin.totals, viewport, fraction_unit
|
sizing_container - styles.margin.totals, viewport, fraction_unit
|
||||||
|
|||||||
Reference in New Issue
Block a user