Make horizontal scrollbar go above caption

Before, the horizontal scrollbar went below the caption, offsetting it,
although the caption didn't scroll with the content, to be clear.
At any rate, it looks much better for the caption to stay in one place,
and be grouped outside the scrollable container which doesn't scroll it.
This commit is contained in:
Isaiah Odhner 2023-09-06 22:44:07 -04:00
parent 938fc2a8ef
commit 4d61aa3a17
2 changed files with 6 additions and 3 deletions

View File

@ -1,10 +1,13 @@
GalleryItem {
layout: vertical;
width: 100%;
align: center middle;
dock: top;
}
.image_container {
align: center middle;
}
.image {
width: auto;
height: auto;

View File

@ -32,7 +32,7 @@ def _(text: str) -> str:
"""Placeholder for localization function."""
return text
class GalleryItem(ScrollableContainer):
class GalleryItem(Container):
"""An image with a caption."""
position: Reactive[float] = var(0)
@ -47,7 +47,7 @@ class GalleryItem(ScrollableContainer):
"""Add widgets to the layout."""
text = self.image.get_renderable()
text.no_wrap = True
yield Static(text, classes="image")
yield ScrollableContainer(Static(text, classes="image"), classes="image_container")
yield Static(self.caption, classes="caption")
def watch_position(self, value: float) -> None: