fix bug with layout updates

This commit is contained in:
Will McGugan
2022-08-07 21:16:59 +01:00
parent c4ac2cce95
commit f9828fba71
5 changed files with 13 additions and 4 deletions

View File

@@ -27,6 +27,10 @@ class CenterApp(App):
margin: 2 4;
}
#sidebar.hidden {
width: 0;
}
Static {
background: $panel;
color: $text-panel;
@@ -35,6 +39,9 @@ class CenterApp(App):
"""
def on_mount(self) -> None:
self.bind("t", "toggle_class('#sidebar', 'hidden')")
def compose(self):
yield Static("Sidebar", id="sidebar")
yield Vertical(
@@ -45,4 +52,4 @@ class CenterApp(App):
)
app = CenterApp()
app = CenterApp(log_verbosity=3)

View File

@@ -632,6 +632,7 @@ class Compositor:
update_regions: set[Region] = set()
else:
update_regions = self._dirty_regions.copy()
if screen_region in update_regions:
# If one of the updates is the entire screen, then we only need one update
full = True

View File

@@ -81,7 +81,7 @@ def get_box_model(
)
content_width = min(content_width, max_width)
content_width = max(Fraction(1), content_width)
content_width = max(Fraction(0), content_width)
if styles.height is None:
# No height specified, fill the available space

View File

@@ -170,7 +170,6 @@ class Screen(Widget):
self.update_timer.pause()
try:
hidden, shown, resized = self._compositor.reflow(self, size)
Hide = events.Hide
Show = events.Show
for widget in hidden:

View File

@@ -1040,7 +1040,9 @@ class Widget(DOMNode):
if layout:
self._layout_required = True
self._clear_arrangement_cache()
if isinstance(self._parent, Widget):
self._parent._clear_arrangement_cache()
if repaint:
self._set_dirty(*regions)
self._content_width_cache = (None, 0)