Skip to content

Commit 1937eda

Browse files
committed
Add optional refresh to resume message
1 parent a604748 commit 1937eda

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- `Node.update_node_styles` has grown a `animate` parameter
1313

14+
### Added
15+
16+
- Adde atom-one-dark and atom-one-light themes @NSPC911 https://github.com/Textualize/textual/pull/6301
17+
1418
## [6.12.0] - 2026-01-02
1519

1620
### Fixed

src/textual/_resolve.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ def resolve_box_models(
246246

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

249+
print("--", size, margin)
250+
print(widgets)
249251
# Fixed box models
250252
box_models: list[BoxModel | None] = [
251253
(
@@ -272,6 +274,10 @@ def resolve_box_models(
272274
)
273275
]
274276

277+
from textual import log
278+
279+
log(box_models)
280+
275281
if None not in box_models:
276282
# No fr units, so we're done
277283
return cast("list[BoxModel]", box_models)
@@ -316,14 +322,19 @@ def resolve_box_models(
316322
)
317323
)
318324

325+
print("MARGINS")
326+
log(margins)
327+
319328
remaining_space = int(max(0, size.height - total_remaining - margin_height))
320329
fraction_unit = resolve_fraction_unit(
321330
[
322331
styles
323332
for styles in widget_styles
324-
if styles.height is not None
325-
and styles.height.is_fraction
326-
and styles.overlay != "screen"
333+
if (
334+
styles.height is not None
335+
and styles.height.is_fraction
336+
and styles.overlay != "screen"
337+
)
327338
],
328339
size,
329340
viewport_size,

src/textual/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2979,7 +2979,9 @@ def pop_screen(self) -> AwaitComplete:
29792979

29802980
previous_screen = screen_stack.pop()
29812981
previous_screen._pop_result_callback()
2982-
self.screen.post_message(events.ScreenResume())
2982+
self.screen.post_message(
2983+
events.ScreenResume(refresh_styles=previous_screen.styles.background.a < 0)
2984+
)
29832985
self.log.system(f"{self.screen} is active")
29842986

29852987
async def do_pop() -> None:

src/textual/events.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,20 @@ def __rich_repr__(self) -> rich.repr.Result:
901901
yield "text", self.text
902902

903903

904+
@dataclass
904905
class ScreenResume(Event, bubble=False):
905906
"""Sent to screen that has been made active.
906907
907908
- [ ] Bubbles
908909
- [ ] Verbose
909910
"""
910911

912+
refresh_styles: bool = True
913+
"""Should the resuming screen refresh its styles?"""
914+
915+
def __rich_repr__(self) -> rich.repr.Result:
916+
yield self.refresh_styles
917+
911918

912919
class ScreenSuspend(Event, bubble=False):
913920
"""Sent to screen when it is no longer active.

src/textual/layouts/vertical.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def arrange(
5050
else:
5151
resolve_margin = Size(0, 0)
5252

53+
print("!!", parent)
54+
5355
box_models = resolve_box_models(
5456
[styles.height for styles in child_styles],
5557
children,

src/textual/screen.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ def _screen_resized(self, size: Size) -> None:
14271427
if self.stack_updates and self.is_attached:
14281428
self._refresh_layout(size)
14291429

1430-
def _on_screen_resume(self) -> None:
1430+
def _on_screen_resume(self, event: events.ScreenResume) -> None:
14311431
"""Screen has resumed."""
14321432
if self.app.SUSPENDED_SCREEN_CLASS:
14331433
self.remove_class(self.app.SUSPENDED_SCREEN_CLASS)
@@ -1441,8 +1441,10 @@ def _on_screen_resume(self) -> None:
14411441

14421442
if self.is_attached:
14431443
self._compositor_refresh()
1444-
self.update_node_styles(animate=False)
1445-
self._refresh_layout(size)
1444+
if event.refresh_styles:
1445+
self.update_node_styles(animate=False)
1446+
if self._size != size:
1447+
self._refresh_layout(size)
14461448
self.refresh()
14471449

14481450
async def _compose(self) -> None:

src/textual/widgets/_collapsible.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class CollapsibleTitle(Static, can_focus=True):
2121
DEFAULT_CSS = """
2222
CollapsibleTitle {
2323
width: auto;
24-
height: auto;
25-
padding: 0 1;
24+
height: auto;
25+
padding: 0 1;
2626
text-style: $block-cursor-blurred-text-style;
2727
color: $block-cursor-blurred-foreground;
2828

0 commit comments

Comments
 (0)