This commit is contained in:
Will McGugan
2022-08-14 21:29:17 +01:00
4 changed files with 26 additions and 2 deletions

8
sandbox/will/fill.css Normal file
View File

@@ -0,0 +1,8 @@
App Static {
border: heavy white;
background: blue;
color: white;
height: 100%;
box-sizing: border-box;
}

10
sandbox/will/fill.py Normal file
View File

@@ -0,0 +1,10 @@
from textual.app import App, ComposeResult
from textual.widgets import Static
class FillApp(App):
def compose(self) -> ComposeResult:
yield Static("Hello")
app = FillApp(css_path="fill.css")

View File

@@ -67,7 +67,7 @@ def get_box_model(
content_width = styles_width.resolve_dimension(
sizing_container - styles.margin.totals, viewport, fraction_unit
)
if is_border_box and not styles_width.is_percent:
if is_border_box and styles_width.excludes_border:
content_width -= gutter.width
if styles.min_width is not None:
@@ -99,7 +99,7 @@ def get_box_model(
content_height = styles_height.resolve_dimension(
sizing_container - styles.margin.totals, viewport, fraction_unit
)
if is_border_box and not styles_height.is_percent:
if is_border_box and styles_height.excludes_border:
content_height -= gutter.height
if styles.min_height is not None:

View File

@@ -37,6 +37,8 @@ class Unit(Enum):
AUTO = 8
UNIT_EXCLUDES_BORDER = {Unit.CELLS, Unit.FRACTION, Unit.VIEW_WIDTH, Unit.VIEW_HEIGHT}
UNIT_SYMBOL = {
Unit.CELLS: "",
Unit.FRACTION: "fr",
@@ -204,6 +206,10 @@ class Scalar(NamedTuple):
"""Check if the unit is a fraction."""
return self.unit == Unit.FRACTION
@property
def excludes_border(self) -> bool:
return self.unit in UNIT_EXCLUDES_BORDER
@property
def cells(self) -> int | None:
"""Check if the unit is explicit cells."""